From 0e5cd1482976ca83a64edd3b1722b64ac3de76a3 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Wed, 29 Sep 2010 16:09:11 -0400 Subject: [PATCH] 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. :) --- tools/Forge/Bundles/MapEdit/CameraView.h | 66 +- tools/Forge/Bundles/MapEdit/CameraView.m | 301 ++++---- tools/Forge/Bundles/MapEdit/Clipper.h | 16 +- tools/Forge/Bundles/MapEdit/Clipper.m | 106 ++- tools/Forge/Bundles/MapEdit/Dict.h | 42 +- tools/Forge/Bundles/MapEdit/Dict.m | 281 +++---- tools/Forge/Bundles/MapEdit/DictList.h | 10 +- tools/Forge/Bundles/MapEdit/DictList.m | 30 +- tools/Forge/Bundles/MapEdit/Entity.h | 42 +- tools/Forge/Bundles/MapEdit/Entity.m | 235 +++--- tools/Forge/Bundles/MapEdit/EntityClass.h | 42 +- tools/Forge/Bundles/MapEdit/EntityClass.m | 104 ++- .../Forge/Bundles/MapEdit/InspectorControl.h | 26 +- .../Forge/Bundles/MapEdit/InspectorControl.m | 6 +- tools/Forge/Bundles/MapEdit/KeypairView.h | 14 +- tools/Forge/Bundles/MapEdit/KeypairView.m | 43 +- tools/Forge/Bundles/MapEdit/Map.h | 82 +- tools/Forge/Bundles/MapEdit/Map.m | 693 ++++++++--------- tools/Forge/Bundles/MapEdit/PopScrollView.h | 11 +- tools/Forge/Bundles/MapEdit/PopScrollView.m | 59 +- tools/Forge/Bundles/MapEdit/Preferences.h | 84 +- tools/Forge/Bundles/MapEdit/Preferences.m | 185 +++-- tools/Forge/Bundles/MapEdit/Project.h | 161 ++-- tools/Forge/Bundles/MapEdit/Project.m | 312 ++++---- tools/Forge/Bundles/MapEdit/QuakeEd.h | 128 +-- tools/Forge/Bundles/MapEdit/QuakeEd.m | 562 +++++++------- tools/Forge/Bundles/MapEdit/QuakeEd_main.m | 13 +- tools/Forge/Bundles/MapEdit/SetBrush.h | 126 +-- tools/Forge/Bundles/MapEdit/SetBrush.m | 731 +++++++++--------- tools/Forge/Bundles/MapEdit/Storage.h | 62 +- tools/Forge/Bundles/MapEdit/Storage.m | 135 ++-- tools/Forge/Bundles/MapEdit/TexturePalette.h | 133 ++-- tools/Forge/Bundles/MapEdit/TexturePalette.m | 440 +++++------ tools/Forge/Bundles/MapEdit/TextureView.h | 10 +- tools/Forge/Bundles/MapEdit/TextureView.m | 51 +- tools/Forge/Bundles/MapEdit/Things.h | 45 +- tools/Forge/Bundles/MapEdit/Things.m | 209 +++-- tools/Forge/Bundles/MapEdit/XYView.h | 61 +- tools/Forge/Bundles/MapEdit/XYView.m | 712 +++++++++-------- tools/Forge/Bundles/MapEdit/ZScrollView.h | 9 +- tools/Forge/Bundles/MapEdit/ZScrollView.m | 40 +- tools/Forge/Bundles/MapEdit/ZView.h | 43 +- tools/Forge/Bundles/MapEdit/ZView.m | 398 +++++----- tools/Forge/Bundles/MapEdit/misc.m | 93 ++- tools/Forge/Bundles/MapEdit/qedefs.h | 41 +- tools/Forge/Bundles/MapEdit/render.h | 22 +- tools/Forge/Bundles/MapEdit/render.m | 131 ++-- 47 files changed, 3544 insertions(+), 3602 deletions(-) diff --git a/tools/Forge/Bundles/MapEdit/CameraView.h b/tools/Forge/Bundles/MapEdit/CameraView.h index b2a26e5f9..015e8d849 100644 --- a/tools/Forge/Bundles/MapEdit/CameraView.h +++ b/tools/Forge/Bundles/MapEdit/CameraView.h @@ -9,68 +9,68 @@ #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 CameraLineto (vec3_t p); -extern BOOL timedrawing; +extern BOOL timedrawing; -@interface CameraView:NSView +@interface CameraView: NSView { - float xa, ya, za; - float move; + float xa, ya, za; + float move; - float *zbuffer; - unsigned *imagebuffer; + float *zbuffer; + unsigned *imagebuffer; - BOOL angleChange; // JR 6.8.95 + BOOL angleChange; // JR 6.8.95 - vec3_t origin; - vec3_t matrix[3]; + vec3_t origin; + vec3_t matrix[3]; - NSPoint dragspot; + NSPoint dragspot; drawmode_t drawmode; - NSBezierPath *xycamera; - NSBezierPath *xycamera_aim; - NSBezierPath *zcamera; + NSBezierPath *xycamera; + NSBezierPath *xycamera_aim; + NSBezierPath *zcamera; // UI links - id mode_radio_i; - + id mode_radio_i; } --setXYOrigin:(NSPoint *) pt; --setZOrigin:(float) pt; +- (id) setXYOrigin: (NSPoint *)pt; +- (id) setZOrigin: (float)pt; --setOrigin:(vec3_t) -org -angle:(float)angle; +- (id) setOrigin: (vec3_t)org + angle: (float)angle; --getOrigin:(vec3_t)org; +- (id) getOrigin: (vec3_t)org; --(float) yawAngle; +- (float) yawAngle; --matrixFromAngles; --_keyDown:(NSEvent *)theEvent; +- (id) matrixFromAngles; +- (id) _keyDown: (NSEvent *)theEvent; --drawMode:sender; --setDrawMode:(drawmode_t) mode; +- (id) drawMode: sender; +- (id) setDrawMode: (drawmode_t)mode; --homeView:sender; +- (id) homeView: sender; - (void) XYDrawSelf; // 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; --downFloor:sender; +- (id) upFloor: sender; +- (id) downFloor: sender; @end #endif // CameraView_h diff --git a/tools/Forge/Bundles/MapEdit/CameraView.m b/tools/Forge/Bundles/MapEdit/CameraView.m index c0fa441d0..f5b8bbf2c 100644 --- a/tools/Forge/Bundles/MapEdit/CameraView.m +++ b/tools/Forge/Bundles/MapEdit/CameraView.m @@ -1,15 +1,16 @@ #include "QF/sys.h" +#import #include "CameraView.h" #include "Map.h" #include "QuakeEd.h" #include "XYView.h" #include "ZView.h" -id cameraview_i; -extern NSBezierPath *path; +id cameraview_i; +extern NSBezierPath *path; -BOOL timedrawing = 0; +BOOL timedrawing = 0; @implementation CameraView /* @@ -17,9 +18,9 @@ BOOL timedrawing = 0; initWithFrame: ================== */ -- initWithFrame:(NSRect)frameRect +- (id) initWithFrame: (NSRect)frameRect { - int size; + int size; [super initWithFrame: frameRect]; @@ -42,9 +43,9 @@ initWithFrame: return self; } --(void)awakeFromNib +- (void) awakeFromNib { - NSBezierPath *path; + NSBezierPath *path; path = zcamera = [NSBezierPath new]; [path setLineWidth: 0.3]; @@ -77,20 +78,21 @@ initWithFrame: [path relativeLineToPoint: NSMakePoint (45, -45)]; } --setXYOrigin:(NSPoint *)pt +- (id) setXYOrigin: (NSPoint *)pt { origin[0] = pt->x; origin[1] = pt->y; return self; } --setZOrigin:(float)pt +- (id) setZOrigin: (float)pt { origin[2] = pt; return self; } --setOrigin:(vec3_t)org angle:(float)angle +- (id) setOrigin: (vec3_t)org + angle: (float)angle { VectorCopy (org, origin); ya = angle; @@ -98,18 +100,18 @@ initWithFrame: return self; } --getOrigin:(vec3_t)org +- (id) getOrigin: (vec3_t)org { VectorCopy (origin, org); return self; } --(float)yawAngle +- (float) yawAngle { return ya; } --upFloor:sender +- (id) upFloor: sender { sb_floor_dir = 1; sb_floor_dist = 99999; @@ -124,7 +126,7 @@ initWithFrame: return self; } --downFloor:sender +- (id) downFloor: sender { sb_floor_dir = -1; sb_floor_dist = -99999; @@ -152,7 +154,7 @@ UI TARGETS homeView ============ */ --homeView:sender +- (id) homeView: sender { xa = za = 0; @@ -165,14 +167,14 @@ homeView return self; } --drawMode:sender +- (id) drawMode: sender { - drawmode =[sender selectedColumn]; + drawmode = [sender selectedColumn]; [quakeed_i updateCamera]; return self; } --setDrawMode:(drawmode_t)mode +- (id) setDrawMode: (drawmode_t)mode { drawmode = mode; [mode_radio_i selectCellAtRow: 0 column: mode]; @@ -188,39 +190,40 @@ TRANSFORMATION METHODS =============================================================================== */ --matrixFromAngles +- (id) matrixFromAngles { if (xa > M_PI * 0.4) xa = M_PI * 0.4; if (xa < -M_PI * 0.4) xa = -M_PI * 0.4; -// vpn + // vpn matrix[2][0] = cos (xa) * cos (ya); matrix[2][1] = cos (xa) * sin (ya); matrix[2][2] = sin (xa); -// vup + // vup matrix[1][0] = cos (xa + M_PI / 2) * cos (ya); matrix[1][1] = cos (xa + M_PI / 2) * sin (ya); matrix[1][2] = sin (xa + M_PI / 2); -// vright + // vright CrossProduct (matrix[2], matrix[1], matrix[0]); return self; } - --inverseTransform:(vec_t *)invec to:(vec_t *)outvec +- (id) inverseTransform: (vec_t *)invec + to: (vec_t *)outvec { - vec3_t inverse[3]; - vec3_t temp; - int i, j; + vec3_t inverse[3]; + vec3_t temp; + int i, j; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) inverse[i][j] = matrix[j][i]; + } temp[0] = DotProduct (invec, inverse[0]); temp[1] = DotProduct (invec, inverse[1]); @@ -231,44 +234,42 @@ TRANSFORMATION METHODS return self; } - - /* =============================================================================== - DRAWING METHODS + DRAWING METHODS =============================================================================== */ -typedef struct { - vec3_t trans; - int clipflags; - vec3_t screen; // valid only if clipflags == 0 +typedef struct { + vec3_t trans; + int clipflags; + vec3_t screen; // valid only if clipflags == 0 } campt_t; -#define CLIP_RIGHT 1 -#define CLIP_LEFT 2 -#define CLIP_TOP 4 -#define CLIP_BOTTOM 8 -#define CLIP_FRONT 16 +#define CLIP_RIGHT 1 +#define CLIP_LEFT 2 +#define CLIP_TOP 4 +#define CLIP_BOTTOM 8 +#define CLIP_FRONT 16 int cam_cur; campt_t campts[2]; -vec3_t r_matrix[3]; -vec3_t r_origin; -float mid_x, mid_y; -float topscale = (240.0 / 3) / 160; -float bottomscale = (240.0 * 2 / 3) / 160; +vec3_t r_matrix[3]; +vec3_t r_origin; +float mid_x, mid_y; +float topscale = (240.0 / 3) / 160; +float bottomscale = (240.0 * 2 / 3) / 160; -extern plane_t rfrustum[5]; +extern plane_t rfrustum[5]; void MakeCampt (vec3_t in, campt_t * pt) { - vec3_t temp; - float scale; + vec3_t temp; + float scale; // transform the points 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[2] = DotProduct (temp, r_matrix[2]); -// check clip flags +// check clip flags if (pt->trans[2] < 1) pt->clipflags = CLIP_FRONT; else @@ -296,17 +297,16 @@ MakeCampt (vec3_t in, campt_t * pt) if (pt->clipflags) return; -// project + // project scale = mid_x / pt->trans[2]; pt->screen[0] = mid_x + pt->trans[0] * scale; pt->screen[1] = mid_y + pt->trans[1] * scale; } - void CameraMoveto (vec3_t p) { - campt_t *pt; + campt_t *pt; if ([path elementCount] > 2048) lineflush (); @@ -314,9 +314,8 @@ CameraMoveto (vec3_t p) pt = &campts[cam_cur]; cam_cur ^= 1; MakeCampt (p, pt); - if (!pt->clipflags) { - // onscreen, so move there immediately - NSPoint point = { pt->screen[0], pt->screen[1] }; + if (!pt->clipflags) { // onscreen, so move there immediately + NSPoint point = {pt->screen[0], pt->screen[1]}; [path moveToPoint: point]; } } @@ -326,12 +325,11 @@ ClipLine (vec3_t p1, vec3_t p2, int planenum) { float d, d2, frac; vec3_t new; - plane_t *pl; + plane_t *pl; float scale; NSPoint point; - if (planenum == 5) { - // draw it! + if (planenum == 5) { // draw it! scale = mid_x / p1[2]; point.x = mid_x + p1[0] * 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; 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; - } - if (d >= 0 && d2 >= 0) { // on front + if (d >= 0 && d2 >= 0) { // on front ClipLine (p1, p2, planenum + 1); return; } @@ -368,12 +365,12 @@ ClipLine (vec3_t p1, vec3_t p2, int planenum) ClipLine (new, p2, planenum + 1); } -int c_off, c_on, c_clip; +int c_off, c_on, c_clip; void CameraLineto (vec3_t p) { - campt_t *p1, *p2; + campt_t *p1, *p2; int bits; p2 = &campts[cam_cur]; @@ -381,36 +378,36 @@ CameraLineto (vec3_t p) p1 = &campts[cam_cur]; MakeCampt (p, p2); - if (p1->clipflags & p2->clipflags) { + if (p1->clipflags & p2->clipflags) { // entirely off screen c_off++; - return; // entirely off screen + return; } 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++; [path moveToPoint: point1]; [path lineToPoint: point2]; - return; // entirely on screen + return; } -// needs to be clipped + + // needs to be clipped c_clip++; ClipLine (p1->trans, p2->trans, 0); } - /* ============= drawSolid ============= */ --drawSolid +- (id) drawSolid { - unsigned char *planes[5]; + unsigned char *planes[5]; // // draw it @@ -432,7 +429,7 @@ drawSolid // // render the setbrushes -// +// [map_i makeAllPerform: @selector (CameraRenderSelf)]; // @@ -442,25 +439,21 @@ drawSolid planes[0] = (unsigned char *) imagebuffer; NSDrawBitmap (_bounds, r_width, r_height, 8, 3, 32, r_width * 4, NO, NO, - NSCalibratedRGBColorSpace, - (const unsigned char **) planes); + NSCalibratedRGBColorSpace, (const unsigned char **) planes); [[self window] setBackingType: NSBackingStoreBuffered]; - - return self; } - /* =================== 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_y = 2 * _bounds.size.height / 3; @@ -476,10 +469,10 @@ drawWire REN_BeginCamera (); -// erase window + // erase window NSEraseRect (rect); -// draw all entities + // draw all entities linestart (0, 0, 0); [map_i makeUnselectedPerform: @selector (CameraDrawSelf)]; lineflush (); @@ -492,9 +485,9 @@ drawWire drawSelf =================== */ -- (void) drawRect:(NSRect)rect +- (void) drawRect: (NSRect)rect { - float drawtime = 0; + float drawtime = 0; if (timedrawing) drawtime = Sys_DoubleTime (); @@ -513,7 +506,6 @@ drawSelf } } - /* ============= XYDrawSelf @@ -521,8 +513,8 @@ XYDrawSelf */ - (void) XYDrawSelf { - NSBezierPath *path; - NSAffineTransform *trans; + NSBezierPath *path; + NSAffineTransform *trans; [[NSColor blueColor] set]; @@ -549,8 +541,8 @@ ZDrawSelf */ - (void) ZDrawSelf { - NSBezierPath *path; - NSAffineTransform *trans; + NSBezierPath *path; + NSAffineTransform *trans; [[NSColor blueColor] set]; @@ -563,11 +555,10 @@ ZDrawSelf [path release]; } - /* =============================================================================== - XYZ mouse view methods + XYZ mouse view methods =============================================================================== */ @@ -577,10 +568,15 @@ ZDrawSelf modalMoveLoop ================ */ --modalMoveLoop:(NSPoint *)basept :(vec3_t)movemod :converter +- (id) modalMoveLoop: (NSPoint *)basept + : (vec3_t)movemod + : converter { vec3_t originbase; - NSEvent *event = 0; + NSEvent *event = 0; + unsigned eventMask = (NSLeftMouseUpMask | NSLeftMouseDraggedMask + | NSRightMouseUpMask | NSRightMouseDraggedMask + | NSApplicationDefinedMask); NSPoint newpt; vec3_t delta; int i; @@ -592,74 +588,73 @@ modalMoveLoop // modal event loop using instance drawing goto drawentry; - while ([event type] != NSLeftMouseUp &&[event type] != NSRightMouseUp) { + while ([event type] != NSLeftMouseUp && [event type] != NSRightMouseUp) { // calculate new point - newpt =[event locationInWindow]; - newpt =[converter convertPoint: newpt fromView: NULL]; + newpt = [event locationInWindow]; + newpt = [converter convertPoint: newpt fromView: NULL]; delta[0] = newpt.x - basept->x; delta[1] = newpt.y - basept->y; - delta[2] = delta[1]; // height change + delta[2] = delta[1]; // height change for (i = 0; i < 3; 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 (event->flags & NS_SHIFTMASK) { NSPoint brushpt; id ent; vec3_t temp; - ent =[quakemap_i selectedEntity]; + ent = [quakemap_i selectedEntity]; if (ent) { [ent origin: temp]; brushpt.x = temp[0]; brushpt.y = temp[1]; - } else - brushpt =[brush_i centerPoint]; - ya = atan2 (brushpt.y - newpt.y, brushpt.x - newpt.x); + } else { + brushpt = [brush_i centerPoint]; + } ya = atan2 (brushpt.y - newpt.y, brushpt.x - newpt.x); [self matrixFromAngles]; } #endif - drawentry: + drawentry: // instance draw new frame [quakeed_i newinstance]; [self display]; - event = [NSApp nextEventMatchingMask: NSLeftMouseUpMask - | NSLeftMouseDraggedMask | NSRightMouseUpMask - | NSRightMouseDraggedMask | NSApplicationDefinedMask - untilDate: [NSDate distantFuture] - inMode: NSEventTrackingRunLoopMode dequeue: YES]; + event = [NSApp nextEventMatchingMask: eventMask + untilDate: [NSDate distantFuture] + inMode: NSEventTrackingRunLoopMode dequeue: + YES]; if ([event type] == NSKeyDown) { [self _keyDown: event]; [self display]; goto drawentry; } - } return self; } -//============================================================================ +// ============================================================================ /* =============== XYmouseDown =============== */ --(BOOL) XYmouseDown:(NSPoint *)pt flags:(int)flags +- (BOOL) XYmouseDown: (NSPoint *)pt + flags: (int)flags // return YES if brush handled { - vec3_t movemod; + vec3_t movemod; if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16) return NO; #if 0 - if (flags & NSAlternateKeyMask) { // up / down drag + if (flags & NSAlternateKeyMask) { // up / down drag movemod[0] = 0; movemod[1] = 0; movemod[2] = 1; @@ -671,21 +666,21 @@ XYmouseDown movemod[2] = 0; } - [self modalMoveLoop: pt : movemod : xyview_i]; + [self modalMoveLoop: pt: movemod: xyview_i]; return YES; } - /* =============== ZmouseDown =============== */ --(BOOL) ZmouseDown:(NSPoint *)pt flags:(int)flags +- (BOOL) ZmouseDown: (NSPoint *)pt + flags: (int)flags // return YES if brush handled { - vec3_t movemod; + vec3_t movemod; if (fabs (pt->y - origin[2]) > 16 || pt->x < -8 || pt->x > 8) return NO; @@ -694,23 +689,22 @@ ZmouseDown movemod[1] = 0; movemod[2] = 1; - [self modalMoveLoop: pt : movemod : zview_i]; + [self modalMoveLoop: pt: movemod: zview_i]; return YES; } - -//============================================================================= +// ============================================================================= /* =================== viewDrag: =================== */ --viewDrag:(NSPoint *)pt +- (id) viewDrag: (NSPoint *)pt { float dx, dy; - NSEvent *event = 0; + NSEvent *event = 0; NSPoint newpt; // @@ -719,11 +713,11 @@ viewDrag: goto drawentry; while ([event type] != NSRightMouseUp) { - // + // // calculate new point - // - newpt =[event locationInWindow]; - newpt =[self convertPoint: newpt fromView: NULL]; + // + newpt = [event locationInWindow]; + newpt = [self convertPoint: newpt fromView: NULL]; dx = newpt.x - pt->x; dy = newpt.y - pt->y; @@ -734,33 +728,32 @@ viewDrag: [self matrixFromAngles]; - drawentry: + drawentry: [quakeed_i newinstance]; [self display]; event = [NSApp nextEventMatchingMask: NSRightMouseUpMask - | NSRightMouseDraggedMask - untilDate: [NSDate distantFuture] - inMode: NSEventTrackingRunLoopMode dequeue: YES]; + | NSRightMouseDraggedMask + untilDate: [NSDate distantFuture] + inMode: NSEventTrackingRunLoopMode dequeue: + YES]; if ([event type] == NSKeyDown) { - [self _keyDown:event]; + [self _keyDown: event]; [self display]; goto drawentry; } - } return self; } - -//============================================================================= +// ============================================================================= /* =================== mouseDown =================== */ --(void) mouseDown:(NSEvent *)theEvent +- (void) mouseDown: (NSEvent *)theEvent { NSPoint pt; int i; @@ -768,23 +761,24 @@ mouseDown float forward, right, up; int flags; - pt =[theEvent locationInWindow]; + pt = [theEvent locationInWindow]; - pt =[self convertPoint: pt fromView: NULL]; + pt = [self convertPoint: pt fromView: NULL]; VectorCopy (origin, p1); forward = 160; right = pt.x - 160; up = pt.y - 240 * 2 / 3; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; 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++) p2[i] = p1[i] + 100 * p2[i]; flags = - [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | - NSAlternateKeyMask | NSCommandKeyMask); + [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | + NSAlternateKeyMask | NSCommandKeyMask); // // bare click to select a texture @@ -835,7 +829,6 @@ mouseDown return; } - Sys_Printf ("bad flags for click %x\n", flags); NopSound (); @@ -847,18 +840,18 @@ mouseDown rightMouseDown =================== */ --(void) rightMouseDown:(NSEvent *)theEvent +- (void) rightMouseDown: (NSEvent *)theEvent { NSPoint pt; int flags; - pt =[theEvent locationInWindow]; + pt = [theEvent locationInWindow]; [self convertPoint: pt fromView: NULL]; - flags = - [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | - NSAlternateKeyMask | NSCommandKeyMask); + flags = [theEvent modifierFlags] + & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask + | NSCommandKeyMask); // // click = drag camera @@ -881,11 +874,10 @@ keyDown =============== */ - --_keyDown:(NSEvent *)theEvent +- (id) _keyDown: (NSEvent *)theEvent { - NSString *chars = [theEvent characters]; - unichar c = [chars length] == 1 ? [chars characterAtIndex: 0] : '\0'; + NSString *chars = [theEvent characters]; + unichar c = ([chars length] == 1) ? [chars characterAtIndex: 0] : '\0'; switch (c) { case 13: @@ -952,12 +944,9 @@ keyDown origin[2] -= move; [quakeed_i updateCamera]; break; - - } - + } /* switch */ return self; } - @end diff --git a/tools/Forge/Bundles/MapEdit/Clipper.h b/tools/Forge/Bundles/MapEdit/Clipper.h index 100be0147..3e4dde5dc 100644 --- a/tools/Forge/Bundles/MapEdit/Clipper.h +++ b/tools/Forge/Bundles/MapEdit/Clipper.h @@ -7,22 +7,22 @@ #include "SetBrush.h" -extern id clipper_i; +extern id clipper_i; -@interface Clipper:NSObject +@interface Clipper: NSObject { int num; vec3_t pos[3]; plane_t plane; } --(BOOL) hide; --XYClick:(NSPoint) pt; --(BOOL) XYDrag:(NSPoint *) pt; --ZClick:(NSPoint) pt; --carve; +- (BOOL) hide; +- (id) XYClick: (NSPoint)pt; +- (BOOL) XYDrag: (NSPoint *)pt; +- (id) ZClick: (NSPoint)pt; +- (id) carve; - (void) flipNormal; --(BOOL) getFace:(face_t *) pl; +- (BOOL) getFace: (face_t *)pl; - (void) cameraDrawSelf; - (void) XYDrawSelf; diff --git a/tools/Forge/Bundles/MapEdit/Clipper.m b/tools/Forge/Bundles/MapEdit/Clipper.m index c627bdcc0..91f8fdc50 100644 --- a/tools/Forge/Bundles/MapEdit/Clipper.m +++ b/tools/Forge/Bundles/MapEdit/Clipper.m @@ -7,21 +7,21 @@ #include "CameraView.h" #include "QuakeEd.h" -id clipper_i; -extern NSBezierPath *path; +id clipper_i; +extern NSBezierPath *path; @implementation Clipper --init +- (id) init { [super init]; clipper_i = self; return self; } --(BOOL) hide +- (BOOL) hide { - int oldnum; + int oldnum; oldnum = num; num = 0; @@ -30,7 +30,7 @@ extern NSBezierPath *path; - (void) flipNormal { - vec3_t temp; + vec3_t temp; if (num == 2) { 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; - int i; + vec3_t v1, v2, norm; + int i; VectorCopy (vec3_origin, plane.normal); plane.dist = 0; @@ -72,7 +72,7 @@ extern NSBezierPath *path; if (!norm[0] && !norm[1] && !norm[2]) return NO; - [texturepalette_i getTextureDef:&f->texture]; + [texturepalette_i getTextureDef: &f->texture]; return YES; } @@ -82,28 +82,27 @@ extern NSBezierPath *path; XYClick ================ */ --XYClick:(NSPoint) pt +- (id) XYClick: (NSPoint)pt { - int i; - vec3_t new; + int i; + vec3_t new; - new[0] =[xyview_i snapToGrid:pt.x]; - new[1] =[xyview_i snapToGrid:pt.y]; - new[2] =[map_i currentMinZ]; + new[0] = [xyview_i snapToGrid: pt.x]; + new[1] = [xyview_i snapToGrid: pt.y]; + new[2] = [map_i currentMinZ]; // see if a point is allready there for (i = 0; i < num; i++) { if (new[0] == pos[i][0] && new[1] == pos[i][1]) { - if (pos[i][2] ==[map_i currentMinZ]) - pos[i][2] =[map_i currentMaxZ]; + if (pos[i][2] == [map_i currentMinZ]) + pos[i][2] = [map_i currentMaxZ]; else - pos[i][2] =[map_i currentMinZ]; + pos[i][2] = [map_i currentMinZ]; [quakeed_i updateAll]; return self; } } - if (num == 3) num = 0; @@ -120,39 +119,36 @@ XYClick XYDrag ================ */ --(BOOL) XYDrag:(NSPoint *) pt +- (BOOL) XYDrag: (NSPoint *)pt { - int i; + int i; for (i = 0; i < 3; i++) { if (fabs (pt->x - pos[i][0] > 10) || fabs (pt->y - pos[i][1] > 10)) - continue; - // drag this point - + continue; // drag this point } return NO; } --ZClick:(NSPoint) pt +- (id) ZClick: (NSPoint)pt { return self; } -//============================================================================= +// ============================================================================= - (id) carve { - [map_i makeSelectedPerform:@selector (carveByClipper)]; + [map_i makeSelectedPerform: @selector (carveByClipper)]; num = 0; return self; } - - (void) cameraDrawSelf { - vec3_t mid; - int i; + vec3_t mid; + int i; linecolor (1, 0.5, 0); @@ -177,8 +173,8 @@ XYDrag - (void) XYDrawSelf { - int i; - NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; + int i; + NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; [[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0] set]; @@ -187,40 +183,38 @@ XYDrag [path removeAllPoints]; for (i = 0; i < num; i++) { - NSString *s = [NSString stringWithFormat: @"%i", i]; - [s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4) - withAttributes: attribs]; - //[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)]; - [path appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0], - pos[i][1]) - radius: 10 - startAngle: 0 - endAngle: 360]; + NSString *s = [NSString stringWithFormat: @"%i", i]; + [s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4) + withAttributes: attribs]; +// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)]; + [path + appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0], pos[i][1]) + radius: 10 + startAngle: 0 + endAngle: 360]; } [path stroke]; } - (void) ZDrawSelf { - int i; - NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; - - [[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0] - set]; + int i; + NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; + [[NSColor colorWithCalibratedRed: 1. green: 0.5 blue: 0. alpha: 1.] set]; [[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set]; [path removeAllPoints]; for (i = 0; i < num; i++) { - NSString *s = [NSString stringWithFormat: @"%i", i]; - [s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4) - withAttributes: attribs]; - //[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)]; - [path appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8, - pos[i][2]) - radius: 10 - startAngle: 0 - endAngle: 360]; + NSString *s = [NSString stringWithFormat: @"%i", i]; + [s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4) + withAttributes: attribs]; +// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)]; + [path + appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8, pos[i][2]) + radius: 10 + startAngle: 0 + endAngle: 360]; } [path stroke]; } diff --git a/tools/Forge/Bundles/MapEdit/Dict.h b/tools/Forge/Bundles/MapEdit/Dict.h index e48bf86fc..52713c8f6 100644 --- a/tools/Forge/Bundles/MapEdit/Dict.h +++ b/tools/Forge/Bundles/MapEdit/Dict.h @@ -5,39 +5,39 @@ #include "Storage.h" -typedef struct { - char *key; - char *value; +typedef struct { + char *key; + char *value; } dict_t; -@interface Dict:Storage +@interface Dict: Storage { } --initFromFile:(FILE *) fp; +- (id) initFromFile: (FILE *)fp; --(id) parseMultipleFrom:(const char *) value; --(int) getValueUnits:(const char *) key; --delString:(const char *)string fromValue:(const char *) key; +- (id) parseMultipleFrom: (const char *)value; +- (int) getValueUnits: (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; -- (const char *) getStringFor:(const char *) name; --removeKeyword:(const char *) key; --(unsigned int) getValueFor:(const char *) name; --changeStringFor:(const char *)key to:(const char *) value; +- (char *) convertListToString: (id)list; +- (const char *) getStringFor: (const char *)name; +- (id) removeKeyword: (const char *)key; +- (unsigned int) getValueFor: (const char *)name; +- (id) changeStringFor: (const char *)key to: (const char *)value; --(dict_t *) findKeyword:(const char *) key; +- (dict_t *) findKeyword: (const char *)key; --writeBlockTo:(FILE *) fp; --writeFile:(const char *) path; +- (id) writeBlockTo: (FILE *)fp; +- (id) writeFile: (const char *)path; // INTERNAL --init; --(id) parseBraceBlock:(FILE *) fp; --setupMultiple:(const char *) value; --(char *) getNextParameter; +- (id) init; +- (id) parseBraceBlock: (FILE *)fp; +- (id) setupMultiple: (const char *)value; +- (char *) getNextParameter; @end diff --git a/tools/Forge/Bundles/MapEdit/Dict.m b/tools/Forge/Bundles/MapEdit/Dict.m index 1e48439f2..259d5bb8d 100644 --- a/tools/Forge/Bundles/MapEdit/Dict.m +++ b/tools/Forge/Bundles/MapEdit/Dict.m @@ -5,20 +5,20 @@ @implementation Dict --init +- (id) init { - [super initCount: 0 elementSize:sizeof (dict_t) - description:NULL]; + [super initCount: 0 elementSize: sizeof (dict_t) + description: NULL]; return self; } --print +- (id) print { - NSUInteger i; - dict_t *d; + NSUInteger i; + dict_t *d; for (i = 0; i < numElements; i++) { - d =[self elementAt:i]; + d = [self elementAt: i]; printf ("%s : %s\n", d->key, d->value); } return self; @@ -31,16 +31,16 @@ copyFromZone JDC =========== */ --copy +- (id) copy { id new; NSUInteger i; - dict_t *d; - char *old; + dict_t *d; + char *old; - new =[super copy]; + new = [super copy]; for (i = 0; i < numElements; i++) { - d =[self elementAt:i]; + d = [self elementAt: i]; old = d->key; d->key = malloc (strlen (old) + 1); strcpy (d->key, old); @@ -53,31 +53,31 @@ JDC return new; } --initFromFile:(FILE *) fp +- (id) initFromFile: (FILE *)fp { [self init]; - return[self parseBraceBlock:fp]; + return [self parseBraceBlock: fp]; } -//=============================================== +// =============================================== // // Dictionary pair functions // -//=============================================== +// =============================================== // // Write a { } block out to a FILE* // --writeBlockTo:(FILE *) fp +- (id) writeBlockTo: (FILE *)fp { - int max; - int i; - dict_t *d; + int max; + int i; + dict_t *d; fprintf (fp, "{\n"); - max =[super count]; + max = [super count]; 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, "}\n"); @@ -88,15 +88,15 @@ JDC // // Write a single { } block out // --writeFile:(const char *) path +- (id) writeFile: (const char *)path { - FILE *fp; + FILE *fp; fp = fopen (path, "w+t"); if (fp != NULL) { printf ("Writing dictionary file %s.\n", path); fprintf (fp, "// QE_Project file %s\n", path); - [self writeBlockTo:fp]; + [self writeBlockTo: fp]; fclose (fp); } else { printf ("Error writing %s!\n", path); @@ -106,25 +106,25 @@ JDC return self; } -//=============================================== +// =============================================== // // Utility methods // -//=============================================== +// =============================================== // // Find a keyword in storage // Returns * to dict_t, otherwise NULL // --(dict_t *) findKeyword:(const char *) key +- (dict_t *) findKeyword: (const char *)key { - int max; - int i; - dict_t *d; + int max; + int i; + dict_t *d; - max =[super count]; + max = [super count]; for (i = 0; i < max; i++) { - d =[super elementAt:i]; + d = [super elementAt: i]; if (!strcmp (d->key, key)) return d; } @@ -135,12 +135,12 @@ JDC // // 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 newd; + dict_t *d; + dict_t newd; - d =[self findKeyword:key]; + d = [self findKeyword: key]; if (d != NULL) { free (d->value); d->value = malloc (strlen (value) + 1); @@ -150,7 +150,7 @@ JDC strcpy (newd.key, key); newd.value = malloc (strlen (value) + 1); strcpy (newd.value, value); - [self addElement:&newd]; + [self addElement: &newd]; } return self; } @@ -158,41 +158,39 @@ JDC // // 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) return d->value; - return (char *) ""; } // // 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) return atol (d->value); - return 0; } // // Return # of units in keyword's value // --(int) getValueUnits:(const char *) key +- (int) getValueUnits: (const char *)key { - id temp; - int count; + id temp; + int count; - temp =[self parseMultipleFrom:key]; - count =[temp count]; + temp = [self parseMultipleFrom: key]; + count = [temp count]; [temp release]; return count; @@ -201,17 +199,17 @@ JDC // // Convert List to string // --(char *) convertListToString:(id) list +- (char *) convertListToString: (id)list { int i; int max; - dstring_t *tempstr; - char *s; + dstring_t *tempstr; + char *s; - max =[list count]; + max = [list count]; tempstr = dstring_newstr (); for (i = 0; i < max; i++) { - s =[list elementAt:i]; + s = [list elementAt: i]; dstring_appendstr (tempstr, s); dstring_appendstr (tempstr, " "); } @@ -222,39 +220,39 @@ JDC // // 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) return self; - [self removeElementAt:d - (dict_t *) dataPtr]; + [self removeElementAt: d - (dict_t *) dataPtr]; return self; } // // 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; - int count; - int i; - char *s; - dict_t *d; + id temp; + int count; + int i; + char *s; + dict_t *d; - d =[self findKeyword:key]; + d = [self findKeyword: key]; if (d == NULL) return NULL; - temp =[self parseMultipleFrom:key]; - count =[temp count]; + temp = [self parseMultipleFrom: key]; + count = [temp count]; for (i = 0; i < count; i++) { - s =[temp elementAt:i]; + s = [temp elementAt: i]; if (!strcmp (s, string)) { - [temp removeElementAt:i]; + [temp removeElementAt: i]; free (d->value); - d->value =[self convertListToString:temp]; + d->value = [self convertListToString: temp]; [temp release]; break; @@ -266,12 +264,12 @@ JDC // // 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; - dict_t *d; + char *newstr; + dict_t *d; - d =[self findKeyword:key]; + d = [self findKeyword: key]; if (d == NULL) return NULL; newstr = nva ("%s\t%s", d->value, string); @@ -281,31 +279,31 @@ JDC return self; } -//=============================================== +// =============================================== // // Use these for multiple parameters in a keyword value // -//=============================================== -const char *searchStr; +// =============================================== +const char *searchStr; char item[4096]; --setupMultiple:(const char *) value +- (id) setupMultiple: (const char *)value { searchStr = value; return self; } --(char *) getNextParameter +- (char *) getNextParameter { - char *s; + char *s; if (!searchStr) return NULL; strcpy (item, searchStr); s = FindWhitespcInBuffer (item); - if (!*s) + if (!*s) { searchStr = NULL; - else { + } else { *s = 0; searchStr = FindNonwhitespcInBuffer (s + 1); } @@ -315,65 +313,66 @@ char item[4096]; // // 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; char string[ITEMSIZE]; - const char *s; + const char *s; - s =[self getStringFor:key]; + s = [self getStringFor: key]; if (s == NULL) return NULL; + stuff = [[Storage alloc] + initCount: 0 elementSize: ITEMSIZE description: NULL]; - stuff =[[Storage alloc] - initCount: 0 elementSize: ITEMSIZE description:NULL]; - - [self setupMultiple:s]; - while ((s =[self getNextParameter])) { + [self setupMultiple: s]; + while ((s = [self getNextParameter])) { bzero (string, ITEMSIZE); strcpy (string, s); - [stuff addElement:string]; + [stuff addElement: string]; } return stuff; } -//=============================================== +// =============================================== // // Dictionary pair parsing // -//=============================================== +// =============================================== // // parse all keyword/value pairs within { } 's // --(id) parseBraceBlock:(FILE *) fp +- (id) parseBraceBlock: (FILE *)fp { - int c; - dict_t pair; - char string[1024]; + int c; + dict_t pair; + char string[1024]; c = FindBrace (fp); if (c == -1) return NULL; - while ((c = FindBrace (fp)) != '}') { if (c == -1) return NULL; -// c = FindNonwhitespc(fp); -// if (c == -1) -// return NULL; -// CopyUntilWhitespc(fp,string); + +#if 0 + c = FindNonwhitespc (fp); + if (c == -1) + return NULL; + CopyUntilWhitespc (fp, string); +#endif // JDC: fixed to allow quoted keys c = FindNonwhitespc (fp); if (c == -1) return NULL; c = fgetc (fp); - if (c == '\"') + if (c == '\"') { CopyUntilQuote (fp, string); - else { + } else { ungetc (c, fp); CopyUntilWhitespc (fp, string); } @@ -386,7 +385,7 @@ char item[4096]; pair.value = malloc (strlen (string) + 1); strcpy (pair.value, string); - [super addElement:&pair]; + [super addElement: &pair]; c = FindBrace (fp); } @@ -394,28 +393,32 @@ char item[4096]; } @end -//=============================================== + +// =============================================== // // C routines for string parsing // -//=============================================== - int +// =============================================== +int GetNextChar (FILE * fp) { - int c; - int c2; + int c; + int c2; c = getc (fp); if (c == EOF) return -1; - if (c == '/') // parse comments - { + + if (c == '/') { // parse comments c2 = getc (fp); if (c2 == '/') { - while ((c2 = getc (fp)) != '\n'); + while ((c2 = getc (fp)) != '\n') + ; + c = getc (fp); - } else + } else { ungetc (c2, fp); + } } return c; } @@ -423,13 +426,14 @@ GetNextChar (FILE * fp) void CopyUntilWhitespc (FILE * fp, char *buffer) { - int count = 800; - int c; + int count = 800; + int c; while (count--) { c = GetNextChar (fp); if (c == EOF) return; + if (c <= ' ') { *buffer = 0; return; @@ -441,17 +445,19 @@ CopyUntilWhitespc (FILE * fp, char *buffer) void CopyUntilQuote (FILE * fp, char *buffer) { - int count = 800; - int c; + int count = 800; + int c; while (count--) { c = GetNextChar (fp); if (c == EOF) return; + if (c == '\"') { *buffer = 0; return; } + *buffer++ = c; } } @@ -459,13 +465,14 @@ CopyUntilQuote (FILE * fp, char *buffer) int FindBrace (FILE * fp) { - int count = 800; - int c; + int count = 800; + int c; while (count--) { c = GetNextChar (fp); if (c == EOF) return -1; + if (c == '{' || c == '}') return c; } @@ -475,13 +482,15 @@ FindBrace (FILE * fp) int FindQuote (FILE * fp) { - int count = 800; - int c; + int count = 800; + int c; while (count--) { c = GetNextChar (fp); + if (c == EOF) return -1; + if (c == '\"') return c; } @@ -491,8 +500,8 @@ FindQuote (FILE * fp) int FindWhitespc (FILE * fp) { - int count = 800; - int c; + int count = 800; + int c; while (count--) { c = GetNextChar (fp); @@ -509,8 +518,8 @@ FindWhitespc (FILE * fp) int FindNonwhitespc (FILE * fp) { - int count = 800; - int c; + int count = 800; + int c; while (count--) { c = GetNextChar (fp); @@ -527,27 +536,29 @@ FindNonwhitespc (FILE * fp) char * FindWhitespcInBuffer (char *buffer) { - int count = 1000; - char *b = buffer; + int count = 1000; + char *b = buffer; - while (count--) + while (count--) { if (*b <= ' ') return b; else b++; + } return NULL; } char * FindNonwhitespcInBuffer (char *buffer) { - int count = 1000; - char *b = buffer; + int count = 1000; + char *b = buffer; - while (count--) + while (count--) { if (*b > ' ') return b; else b++; + } return NULL; } diff --git a/tools/Forge/Bundles/MapEdit/DictList.h b/tools/Forge/Bundles/MapEdit/DictList.h index 07ce9acf0..8ff7e3ecf 100644 --- a/tools/Forge/Bundles/MapEdit/DictList.h +++ b/tools/Forge/Bundles/MapEdit/DictList.h @@ -3,14 +3,14 @@ #include -@interface DictList:NSMutableArray +@interface DictList: NSMutableArray { - NSMutableArray *array; + NSMutableArray *array; } --initListFromFile:(FILE *) fp; --writeListFile:(const char *) filename; --(id) findDictKeyword:(const char *) key; +- (id) initListFromFile: (FILE *)fp; +- (id) writeListFile: (const char *)filename; +- (id) findDictKeyword: (const char *)key; @end #endif // DictList_h diff --git a/tools/Forge/Bundles/MapEdit/DictList.m b/tools/Forge/Bundles/MapEdit/DictList.m index 00bc2b7a4..187984ec7 100644 --- a/tools/Forge/Bundles/MapEdit/DictList.m +++ b/tools/Forge/Bundles/MapEdit/DictList.m @@ -1,4 +1,3 @@ - #include "DictList.h" #include "Dict.h" @@ -9,16 +8,16 @@ // // Read in variable # of objects from FILE * // -- initListFromFile:(FILE *) fp +- (id) initListFromFile: (FILE *)fp { - id d; + id d; self = [super init]; array = [[NSMutableArray alloc] init]; do { - d =[(Dict *)[Dict alloc] initFromFile:fp]; + d = [(Dict *)[Dict alloc] initFromFile: fp]; if (d != NULL) - [self addObject:d]; + [self addObject: d]; } while (d != NULL); [d release]; @@ -28,21 +27,20 @@ // // Write out list file // --writeListFile:(const char *) filename +- (id) writeListFile: (const char *)filename { - FILE *fp; + FILE *fp; NSUInteger i; id obj; fp = fopen (filename, "w+t"); if (fp == NULL) return NULL; - fprintf (fp, "// Object List written by QuakeEd\n"); - for (i = 0; i <[self count]; i++) { - obj =[self objectAtIndex:i]; - [obj writeBlockTo:fp]; + for (i = 0; i < [self count]; i++) { + obj = [self objectAtIndex: i]; + [obj writeBlockTo: fp]; } fclose (fp); @@ -52,15 +50,15 @@ // // Find the keyword in all the Dict objects // --(id) findDictKeyword:(const char *) key +- (id) findDictKeyword: (const char *)key { NSUInteger i; - dict_t *d; + dict_t *d; id dict; - for (i = 0; i <[self count]; i++) { - dict =[self objectAtIndex:i]; - d =[(Dict *) dict findKeyword:key]; + for (i = 0; i < [self count]; i++) { + dict = [self objectAtIndex: i]; + d = [(Dict *) dict findKeyword: key]; if (d != NULL) return dict; } diff --git a/tools/Forge/Bundles/MapEdit/Entity.h b/tools/Forge/Bundles/MapEdit/Entity.h index 6538ee825..3a6919442 100644 --- a/tools/Forge/Bundles/MapEdit/Entity.h +++ b/tools/Forge/Bundles/MapEdit/Entity.h @@ -5,42 +5,42 @@ #include "QF/mathlib.h" -typedef struct epair_s { - struct epair_s *next; - char *key; - char *value; +typedef struct epair_s { + struct epair_s *next; + char *key; + char *value; } epair_t; // an Entity is a list of brush objects, with additional key / value info -@interface Entity:NSMutableArray +@interface Entity: NSMutableArray { - NSMutableArray *array; - epair_t *epairs; - BOOL modifiable; + NSMutableArray *array; + epair_t *epairs; + BOOL modifiable; } -- (Entity *) initClass:(const char *) classname; -- (Entity *) initFromScript: (struct script_s *) script; +- (Entity *) initClass: (const char *)classname; +- (Entity *) initFromScript: (struct script_s *)script; - (oneway void) dealloc; --(BOOL) modifiable; -- (void) setModifiable:(BOOL) m; +- (BOOL) modifiable; +- (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; -- (void) getVector:(vec3_t)v forKey:(const char *) k; +- (const char *) valueForQKey: (const char *)k; +- (void) getVector: (vec3_t)v forKey: (const char *)k; -- (void) setKey:(const char *)k - toValue:(const char *)v; +- (void) setKey: (const char *)k + toValue: (const char *)v; --(int) numPairs; --(epair_t *) epairs; -- (void) removeKeyPair:(const char *) key; +- (int) numPairs; +- (epair_t *) epairs; +- (void) removeKeyPair: (const char *)key; @end #endif // Entity_h diff --git a/tools/Forge/Bundles/MapEdit/Entity.m b/tools/Forge/Bundles/MapEdit/Entity.m index b8f20b496..fc320000e 100644 --- a/tools/Forge/Bundles/MapEdit/Entity.m +++ b/tools/Forge/Bundles/MapEdit/Entity.m @@ -15,27 +15,27 @@ @implementation Entity -vec3_t bad_mins = { -8, -8, -8 }; -vec3_t bad_maxs = { 8, 8, 8 }; +vec3_t bad_mins = {-8, -8, -8}; +vec3_t bad_maxs = {8, 8, 8}; --createFixedBrush:(vec3_t) org +- (id) createFixedBrush: (vec3_t)org { - vec3_t emins, emaxs; - float *v, *v2, *color; - id new; - texturedef_t td; + vec3_t emins, emaxs; + float *v, *v2, *color; + id new; + texturedef_t td; // get class - new =[entity_classes_i classForName: [self valueForQKey:"classname"]]; + new = [entity_classes_i classForName: [self valueForQKey: "classname"]]; if (new) { - v =[new mins]; - v2 =[new maxs]; + v = [new mins]; + v2 = [new maxs]; } else { v = bad_mins; v2 = bad_maxs; } - color =[new drawColor]; + color = [new drawColor]; modifiable = NO; memset (&td, 0, sizeof (td)); @@ -43,10 +43,10 @@ vec3_t bad_maxs = { 8, 8, 8 }; VectorAdd (org, v, emins); VectorAdd (org, v2, emaxs); - new =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td]; - [new setEntityColor:color]; + new = [[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td]; + [new setEntityColor: color]; - [self addObject:new]; + [self addObject: new]; return self; } @@ -57,7 +57,7 @@ vec3_t bad_maxs = { 8, 8, 8 }; esize_t esize; vec3_t min, max; int org[3]; - float *v; + float *v; self = [super init]; array = [[NSMutableArray alloc] init]; @@ -67,7 +67,7 @@ vec3_t bad_maxs = { 8, 8, 8 }; [self setKey: "classname" toValue: classname]; // get class - new = [entity_classes_i classForName: [self valueForQKey:"classname"]]; + new = [entity_classes_i classForName: [self valueForQKey: "classname"]]; if (!new) esize = esize_model; else @@ -76,22 +76,23 @@ vec3_t bad_maxs = { 8, 8, 8 }; // create a brush if needed if (esize == esize_fixed) { v = [new mins]; - [[map_i selectedBrush] getMins: min maxs:max]; + [[map_i selectedBrush] getMins: min maxs: max]; 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]; - } else + } else { modifiable = YES; - + } return self; } - (oneway void) dealloc { - epair_t *e, *n; + epair_t *e, *n; for (e = epairs; e; e = n) { n = e->next; @@ -103,7 +104,7 @@ vec3_t bad_maxs = { 8, 8, 8 }; [super dealloc]; } --(BOOL) modifiable +- (BOOL) modifiable { return modifiable; } @@ -114,45 +115,45 @@ vec3_t bad_maxs = { 8, 8, 8 }; return; } --(void) removeObject: (id)o +- (void) removeObject: (id)o { - [super removeObject:o]; + [super removeObject: o]; if ([self count]) 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]; } - --(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)) return e->value; + } return ""; } - (void) getVector: (vec3_t)v - forKey: (const char *)k + forKey: (const char *)k { - const char *c; - - c =[self valueForQKey:k]; + const char *c; + c = [self valueForQKey: k]; v[0] = v[1] = v[2] = 0; 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) printf ("%20s : %20s\n", e->key, e->value); @@ -160,15 +161,17 @@ vec3_t bad_maxs = { 8, 8, 8 }; return self; } -- (void) setKey:(const char *)k - toValue:(const char *) v +- (void) setKey: (const char *)k + toValue: (const char *)v { - epair_t *e; + epair_t *e; while (*k && *k <= ' ') k++; + + // don't set NULL values if (!*k) - return; // don't set NULL values + return; for (e = epairs; e; e = e->next) { if (!strcmp (k, e->key)) { @@ -185,25 +188,26 @@ vec3_t bad_maxs = { 8, 8, 8 }; epairs = e; } --(int) numPairs +- (int) numPairs { int i; - epair_t *e; + epair_t *e; i = 0; for (e = epairs; e; e = e->next) i++; + return i; } --(epair_t *) epairs +- (epair_t *) epairs { return epairs; } -- (void) removeKeyPair:(char *) key +- (void) removeKeyPair: (char *)key { - epair_t *e, *e2; + epair_t *e, *e2; if (!epairs) return; @@ -215,7 +219,7 @@ vec3_t bad_maxs = { 8, 8, 8 }; return; } - for (; e; e = e->next) { + for ( ; e; e = e->next) { if (e->next && !strcmp (e->next->key, key)) { e2 = e->next; e->next = e2->next; @@ -228,7 +232,6 @@ vec3_t bad_maxs = { 8, 8, 8 }; return; } - /* ============= targetname @@ -236,23 +239,23 @@ targetname 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; id ent; int tval, maxt; - t =[self valueForQKey:"targetname"]; + t = [self valueForQKey: "targetname"]; if (t && t[0]) return t; -// make a unique name of the form t - count =[map_i count]; + // make a unique name of the form t + count = [map_i count]; maxt = 0; for (i = 1; i < count; i++) { - ent =[map_i objectAtIndex:i]; - t =[ent valueForQKey:"targetname"]; + ent = [map_i objectAtIndex: i]; + t = [ent valueForQKey: "targetname"]; if (!t || t[0] != 't') continue; tval = atoi (t + 1); @@ -260,9 +263,9 @@ If the entity does not have a "targetname" key, a unique one is generated 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; - id eclass, brush; - const char *spawn; - vec3_t emins, emaxs; - vec3_t org; - texturedef_t td; - esize_t esize; - int i, c; - float *color; + char *key; + id eclass, brush; + const char *spawn; + vec3_t emins, emaxs; + vec3_t org; + texturedef_t td; + esize_t esize; + int i, c; + float *color; self = [super init]; array = [[NSMutableArray alloc] init]; @@ -305,13 +308,13 @@ int nument; break; if (!strcmp (Script_Token (script), "{")) { // read a brush - brush =[[SetBrush alloc] initFromScript: script owner:self]; - [self addObject:brush]; + brush = [[SetBrush alloc] initFromScript: script owner: self]; + [self addObject: brush]; } else { // read a key / value pair key = strdup (Script_Token (script)); Script_GetToken (script, false); - [self setKey: key toValue:Script_Token (script)]; + [self setKey: key toValue: Script_Token (script)]; free (key); } } while (1); @@ -319,12 +322,12 @@ int nument; nument++; // get class - spawn =[self valueForQKey:"classname"]; - eclass =[entity_classes_i classForName:spawn]; + spawn = [self valueForQKey: "classname"]; + 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) { printf ("WARNING:Entity with brushes and wrong model type\n"); @@ -332,94 +335,96 @@ int nument; } if (![self count] && esize == esize_model) { - printf ("WARNING:Entity with no brushes and esize_model: %s\n", [self valueForQKey:"classname"]); - [texturepalette_i getTextureDef:&td]; + printf ("WARNING:Entity with no brushes and esize_model: %s\n", + [self valueForQKey: "classname"]); + [texturepalette_i getTextureDef: &td]; for (i = 0; i < 3; i++) { emins[i] = org[i] - 8; emaxs[i] = org[i] + 8; } - brush =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td]; - [self addObject:brush]; + 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) - [self createFixedBrush:org]; + [self createFixedBrush: org]; else modifiable = YES; -// set all the brush colors - color =[eclass drawColor]; + // set all the brush colors + color = [eclass drawColor]; - c =[self count]; + c = [self count]; for (i = 0; i < c; i++) { - brush =[self objectAtIndex:i]; - [brush setEntityColor:color]; + brush = [self objectAtIndex: i]; + [brush setEntityColor: color]; } return self; } - -- (void) writeToFILE:(FILE *)f - region:(BOOL) reg; +- (void) writeToFILE: (FILE *)f + region: (BOOL)reg; { - epair_t *e; - int ang; - unsigned int i; - id new; - vec3_t mins, maxs; - int org[3]; - const vec_t *v; - char *oldang = 0; + epair_t *e; + int ang; + unsigned int i; + id new; + vec3_t mins, maxs; + int org[3]; + const vec_t *v; + char *oldang = 0; 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 - oldang = strdup ([self valueForQKey:"angle"]); + oldang = strdup ([self valueForQKey: "angle"]); ang = (int) ([cameraview_i yawAngle] * 180 / M_PI); [self setKey: "angle" toValue: va ("%i", ang)]; - } else if (self != [map_i objectAtIndex:0] - && [[self objectAtIndex:0] regioned]) { - return; // skip the entire entity definition + } else if (self != [map_i objectAtIndex: 0] + && [[self objectAtIndex: 0] regioned]) { + return; // skip the entire entity definition } } fprintf (f, "{\n"); -// set an origin epair + // set an origin epair if (!modifiable) { - [[self objectAtIndex: 0] getMins: mins maxs:maxs]; + [[self objectAtIndex: 0] getMins: mins maxs: maxs]; if (oldang) { - [cameraview_i getOrigin:mins]; + [cameraview_i getOrigin: mins]; mins[0] -= 16; mins[1] -= 16; mins[2] -= 48; } - new =[entity_classes_i classForName: - [self valueForQKey:"classname"]]; + new = [entity_classes_i classForName: + [self valueForQKey: "classname"]]; if (new) - v =[new mins]; + v = [new mins]; else v = vec3_origin; VectorSubtract (mins, v, org); [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) 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) { - for (i = 0; i <[self count]; i++) - [[self objectAtIndex: i] writeToFILE: f region:reg]; + for (i = 0; i < [self count]; i++) + [[self objectAtIndex: i] writeToFILE: f region: reg]; } fprintf (f, "}\n"); if (oldang) { - [self setKey: "angle" toValue:oldang]; + [self setKey: "angle" toValue: oldang]; free (oldang); } diff --git a/tools/Forge/Bundles/MapEdit/EntityClass.h b/tools/Forge/Bundles/MapEdit/EntityClass.h index def8016e5..65d016577 100644 --- a/tools/Forge/Bundles/MapEdit/EntityClass.h +++ b/tools/Forge/Bundles/MapEdit/EntityClass.h @@ -5,42 +5,42 @@ #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; vec3_t mins, maxs; vec3_t color; - char *comments; - char *flagnames[MAX_FLAGS]; + char *comments; + char *flagnames[MAX_FLAGS]; } --initFromText:(const char *)text source:(const char *) filename; +- (id) initFromText: (const char *)text source: (const char *)filename; --(const char *) classname; --(esize_t) esize; --(float *) mins; // only for esize_fixed --(float *) maxs; // only for esize_fixed --(float *) drawColor; --(const char *) comments; --(const char *) flagName:(unsigned) flagnum; +- (const char *) classname; +- (esize_t) esize; +- (float *) mins; // only for esize_fixed +- (float *) maxs; // only for esize_fixed +- (float *) drawColor; +- (const char *) comments; +- (const char *) flagName: (unsigned)flagnum; @end extern id entity_classes_i; -@interface EntityClassList:NSMutableArray +@interface EntityClassList: NSMutableArray { - NSMutableArray *array; - id nullclass; - char *source_path; + NSMutableArray *array; + id nullclass; + char *source_path; } --initForSourceDirectory:(const char *) path; --(id) classForName:(const char *) name; --(void) scanDirectory; +- (id) initForSourceDirectory: (const char *)path; +- (id) classForName: (const char *)name; +- (void) scanDirectory; @end #endif // EntityClass_h diff --git a/tools/Forge/Bundles/MapEdit/EntityClass.m b/tools/Forge/Bundles/MapEdit/EntityClass.m index 912b4f4c5..d70474ab8 100644 --- a/tools/Forge/Bundles/MapEdit/EntityClass.m +++ b/tools/Forge/Bundles/MapEdit/EntityClass.m @@ -12,17 +12,15 @@ static int parse_vector (script_t * script, vec3_t vec) { - int r; + int r; if (!Script_GetToken (script, 0)) return 0; if (strcmp (Script_Token (script), "(")) return 0; - r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]); if (r != 3) return 0; - while (strcmp (Script_Token (script), ")")) { if (!Script_GetToken (script, 0)) return 0; @@ -38,14 +36,15 @@ parse_vector (script_t * script, vec3_t vec) // // 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; int i; - script_t *script; + script_t *script; [super init]; @@ -64,7 +63,7 @@ parse_vector (script_t * script, vec3_t vec) // grab the color if (!parse_vector (script, color)) return 0; - // get the size + // get the size if (!Script_GetToken (script, 0)) return 0; if (!strcmp (Script_Token (script), "(")) { @@ -80,7 +79,6 @@ parse_vector (script_t * script, vec3_t vec) } else { return 0; } - // get the flags // any remaining words on the line are parm flags for (i = 0; i < MAX_FLAGS; i++) { @@ -105,38 +103,37 @@ parse_vector (script_t * script, vec3_t vec) return self; } --(esize_t) esize +- (esize_t) esize { return esize; } --(const char *) classname +- (const char *) classname { return name; } --(float *) mins +- (float *) mins { return mins; } --(float *) maxs +- (float *) maxs { return maxs; } --(float *) drawColor +- (float *) drawColor { return color; } --(const char *) comments +- (const char *) comments { return comments; } - --(const char *) flagName:(unsigned) flagnum +- (const char *) flagName: (unsigned)flagnum { if (flagnum >= MAX_FLAGS) Sys_Error ("EntityClass flagName: bad number"); @@ -144,7 +141,7 @@ parse_vector (script_t * script, vec3_t vec) } @end -//=========================================================================== +// =========================================================================== #define THING EntityClassList #include "THING+NSArray.m" @@ -155,35 +152,34 @@ parse_vector (script_t * script, vec3_t vec) insertEC: ================= */ -- (void) insertEC:ec +- (void) insertEC: ec { - const char *name; - unsigned int i; + const char *name; + unsigned int i; - name =[ec classname]; - for (i = 0; i <[self count]; i++) { - if (strcasecmp (name,[[self objectAtIndex:i] classname]) < 0) { - [self insertObject: ec atIndex:i]; + name = [ec classname]; + for (i = 0; i < [self count]; i++) { + if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0) { + [self insertObject: ec atIndex: i]; return; } } - [self addObject:ec]; + [self addObject: ec]; } - /* ================= scanFile ================= */ --(void) scanFile:(const char *) filename +- (void) scanFile: (const char *)filename { int size, line; - char *data; + char *data; id cl; int i; - const char *path; - QFile *file; + const char *path; + QFile *file; path = va ("%s/%s", source_path, filename); @@ -199,10 +195,11 @@ scanFile line = 1; for (i = 0; i < size; i++) { if (!strncmp (data + i, "/*QUAKED", 8)) { - cl =[[EntityClass alloc] initFromText:(data + i) - source:va ("%s:%d", filename, line)]; + cl = [[EntityClass alloc] + initFromText: (data + i) + source: va ("%s:%d", filename, line)]; if (cl) - [self insertEC:cl]; + [self insertEC: cl]; } else if (data[i] == '\n') { line++; } @@ -211,68 +208,63 @@ scanFile free (data); } - /* ================= scanDirectory ================= */ --(void) scanDirectory +- (void) scanDirectory { - int count, i; - struct dirent **namelist, *ent; + int count, i; + struct dirent **namelist, *ent; [self removeAllObjects]; count = scandir (source_path, &namelist, NULL, NULL); for (i = 0; i < count; i++) { - int len; + int len; ent = namelist[i]; len = strlen (ent->d_name); if (len <= 3) continue; 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; - - --initForSourceDirectory:(const char *) path +- (id) initForSourceDirectory: (const char *)path { self = [super init]; array = [[NSMutableArray alloc] init]; - source_path = strdup (path); //FIXME leak? + source_path = strdup (path); // FIXME leak? [self scanDirectory]; entity_classes_i = self; - nullclass =[[EntityClass alloc] - initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/" source:va ("%s:%d", __FILE__, - __LINE__ - - 1)]; + nullclass = [[EntityClass alloc] + initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/" + source: va ("%s:%d", __FILE__, __LINE__ - 1)]; return self; } --(id) classForName:(const char *) name +- (id) classForName: (const char *)name { - unsigned int i; - id o; + unsigned int i; + id o; - for (i = 0; i <[self count]; i++) { - o =[self objectAtIndex:i]; - if (!strcmp (name,[o classname])) + for (i = 0; i < [self count]; i++) { + o = [self objectAtIndex: i]; + if (!strcmp (name, [o classname])) return o; } return nullclass; } - @end diff --git a/tools/Forge/Bundles/MapEdit/InspectorControl.h b/tools/Forge/Bundles/MapEdit/InspectorControl.h index 56548376c..f9733aea6 100644 --- a/tools/Forge/Bundles/MapEdit/InspectorControl.h +++ b/tools/Forge/Bundles/MapEdit/InspectorControl.h @@ -24,25 +24,25 @@ extern InspectorControl *inspcontrol_i; { IBOutlet NSView *inspectorView_i; // inspector view IBOutlet NSView *inspectorSubview_i; // inspector view's current subview - // (gets replaced) + // (gets replaced) - id contentList; // List of contentviews (corresponds to - // insp_e enum order) + id contentList; // List of contentviews (corresponds to + // insp_e enum order) - id windowList; // List of Windows (corresponds to - // insp_e enum order) + id windowList; // List of Windows (corresponds to + // insp_e enum order) - id obj_textures_i; // TexturePalette object (for - // delegating) - id obj_genkeypair_i; // GenKeyPair object + id obj_textures_i; // TexturePalette object (for + // delegating) + id obj_genkeypair_i; // GenKeyPair object - NSPopUpButton *popUpButton_i; // PopUpList title button - NSMatrix *popUpMatrix_i; // PopUpList matrix - NSMutableArray *itemList; // List of popUp buttons + NSPopUpButton *popUpButton_i; // PopUpList title button + NSMatrix *popUpMatrix_i; // PopUpList matrix + NSMutableArray *itemList; // List of popUp buttons IBOutlet NSTextView *helpView; - insp_e currentInspectorType; // keep track of current inspector + insp_e currentInspectorType; // keep track of current inspector // // Add id's here for new inspectors @@ -65,7 +65,7 @@ extern InspectorControl *inspcontrol_i; IBOutlet id itemPrefs_i; // preferences IBOutlet id itemSettings_i; // project settings IBOutlet id itemOutput_i; // bsp output - IBOutlet id itemHelp_i; // docs + IBOutlet id itemHelp_i; // docs } - (IBAction) changeInspector: (id)sender; diff --git a/tools/Forge/Bundles/MapEdit/InspectorControl.m b/tools/Forge/Bundles/MapEdit/InspectorControl.m index b1a19dc54..7df99bfa1 100644 --- a/tools/Forge/Bundles/MapEdit/InspectorControl.m +++ b/tools/Forge/Bundles/MapEdit/InspectorControl.m @@ -7,7 +7,7 @@ #include "TexturePalette.h" #include "Preferences.h" -InspectorControl *inspcontrol_i; +InspectorControl *inspcontrol_i; @interface CustomView: NSView @end @@ -100,10 +100,8 @@ InspectorControl *inspcontrol_i; NSRect r; NSRect f; - if (which == currentInspectorType) { + if (which == currentInspectorType) return; - } - currentInspectorType = which; newView = [contentList objectAtIndex: which]; diff --git a/tools/Forge/Bundles/MapEdit/KeypairView.h b/tools/Forge/Bundles/MapEdit/KeypairView.h index 7560aa2e7..8afdd1d95 100644 --- a/tools/Forge/Bundles/MapEdit/KeypairView.h +++ b/tools/Forge/Bundles/MapEdit/KeypairView.h @@ -3,19 +3,19 @@ #include -extern id keypairview_i; +extern id keypairview_i; -@interface KeypairView:NSView +@interface KeypairView: NSView { } --calcViewSize; +- (id) calcViewSize; -#define SPACING 4 -#define FONTSIZE 12 -#define EXTRASPC 2 +#define SPACING 4 +#define FONTSIZE 12 +#define EXTRASPC 2 -#define LINEHEIGHT 16 +#define LINEHEIGHT 16 @end diff --git a/tools/Forge/Bundles/MapEdit/KeypairView.m b/tools/Forge/Bundles/MapEdit/KeypairView.m index 488478a0a..a8cb429a0 100644 --- a/tools/Forge/Bundles/MapEdit/KeypairView.m +++ b/tools/Forge/Bundles/MapEdit/KeypairView.m @@ -1,10 +1,9 @@ - #include "KeypairView.h" #include "Map.h" #include "Entity.h" #include "Things.h" -id keypairview_i; +id keypairview_i; @implementation KeypairView /* @@ -12,20 +11,19 @@ id keypairview_i; initWithFrame: ================== */ -- initWithFrame:(NSRect) frameRect +- (id) initWithFrame: (NSRect)frameRect { - [super initWithFrame:frameRect]; + [super initWithFrame: frameRect]; keypairview_i = self; return self; } --(BOOL) isFlipped +- (BOOL) isFlipped { return YES; } - --calcViewSize +- (id) calcViewSize { NSRect b; NSPoint pt; @@ -37,17 +35,17 @@ initWithFrame: b = [[self superview] bounds]; b.size.height = LINEHEIGHT * count + SPACING; - [self setFrameSize:b.size]; + [self setFrameSize: b.size]; pt.x = pt.y = 0; - [self scrollPoint:pt]; + [self scrollPoint: pt]; return self; } --drawRect: (NSRect) rects +- (id) drawRect: (NSRect)rects { - epair_t *pair; + epair_t *pair; int y; - NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; + NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; [[NSColor lightGrayColor] set]; NSRectFill (NSMakeRect (0, 0, _bounds.size.width, _bounds.size.height)); @@ -55,11 +53,12 @@ initWithFrame: [[NSFont systemFontOfSize: FONTSIZE] set]; [[NSColor blackColor] set]; - pair =[[map_i currentEntity] epairs]; + pair = [[map_i currentEntity] epairs]; y = _bounds.size.height - LINEHEIGHT; - for (; pair; pair = pair->next) { - NSString *key = [NSString stringWithCString: pair->key]; - NSString *value = [NSString stringWithCString: pair->value]; + for ( ; pair; pair = pair->next) { + NSString *key = [NSString stringWithCString: pair->key]; + NSString *value = [NSString stringWithCString: pair->value]; + [key drawAtPoint: NSMakePoint (SPACING, y) withAttributes: attribs]; [value drawAtPoint: NSMakePoint (100, y) withAttributes: attribs]; y -= LINEHEIGHT; @@ -68,18 +67,18 @@ initWithFrame: return self; } --(void) mouseDown:(NSEvent *) theEvent +- (void) mouseDown: (NSEvent *)theEvent { NSPoint loc; int i; - epair_t *p; + epair_t *p; - loc =[theEvent locationInWindow]; - loc =[self convertPoint: loc fromView:NULL]; + loc = [theEvent locationInWindow]; + loc = [self convertPoint: loc fromView: NULL]; i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT; - p =[[map_i currentEntity] epairs]; + p = [[map_i currentEntity] epairs]; while (i) { p = p->next; if (!p) @@ -87,7 +86,7 @@ initWithFrame: i--; } if (p) - [things_i setSelectedKey:p]; + [things_i setSelectedKey: p]; return; } diff --git a/tools/Forge/Bundles/MapEdit/Map.h b/tools/Forge/Bundles/MapEdit/Map.h index 5401a4bb4..8d8347dc3 100644 --- a/tools/Forge/Bundles/MapEdit/Map.h +++ b/tools/Forge/Bundles/MapEdit/Map.h @@ -7,70 +7,70 @@ // Map is a list of Entity objects -extern id map_i; +extern id map_i; -@interface Map:NSMutableArray +@interface Map: NSMutableArray { - NSMutableArray *array; - id currentEntity; - id oldselection; // temp when loading a new map - float minz, maxz; + NSMutableArray *array; + id currentEntity; + id oldselection; // temp when loading a new map + float minz, maxz; } --newMap; +- (id) newMap; --writeStats; +- (id) writeStats; --readMapFile:(const char *) fname; --writeMapFile:(const char *)fname useRegion:(BOOL) reg; +- (id) readMapFile: (const char *)fname; +- (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; --grabRay: (vec3_t) p1:(vec3_t) p2; --setTextureRay: (vec3_t) p1: (vec3_t) p2:(BOOL) allsides; --getTextureRay: (vec3_t) p1:(vec3_t) p2; +- (id) selectRay: (vec3_t)p1: (vec3_t)p2: (BOOL)ef; +- (id) grabRay: (vec3_t)p1: (vec3_t)p2; +- (id) setTextureRay: (vec3_t)p1: (vec3_t)p2: (BOOL)allsides; +- (id) getTextureRay: (vec3_t)p1: (vec3_t)p2; --currentEntity; --setCurrentEntity:ent; +- (id) currentEntity; +- (id) setCurrentEntity: ent; --(float) currentMinZ; --setCurrentMinZ:(float) m; --(float) currentMaxZ; --setCurrentMaxZ:(float) m; +- (float) currentMinZ; +- (id) setCurrentMinZ: (float)m; +- (float) currentMaxZ; +- (id) setCurrentMaxZ: (float)m; --(int) numSelected; --selectedBrush; // returns the first selected brush +- (int) numSelected; +- (id) selectedBrush; // returns the first selected brush // // operations on current selection // --makeSelectedPerform:(SEL) sel; --makeUnselectedPerform:(SEL) sel; --makeAllPerform:(SEL) sel; --makeGlobalPerform:(SEL) sel; // in and out of region +- (id) makeSelectedPerform: (SEL)sel; +- (id) makeUnselectedPerform: (SEL)sel; +- (id) makeAllPerform: (SEL)sel; +- (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; --selectPartiallyInside:sender; +- (id) selectCompletelyInside: sender; +- (id) selectPartiallyInside: sender; --tallBrush:sender; --shortBrush:sender; +- (id) tallBrush: sender; +- (id) shortBrush: sender; --rotate_x:sender; --rotate_y:sender; --rotate_z:sender; +- (id) rotate_x: sender; +- (id) rotate_y: sender; +- (id) rotate_z: sender; --flip_x:sender; --flip_y:sender; --flip_z:sender; +- (id) flip_x: sender; +- (id) flip_y: sender; +- (id) flip_z: sender; --selectCompleteEntity:sender; +- (id) selectCompleteEntity: sender; @end diff --git a/tools/Forge/Bundles/MapEdit/Map.m b/tools/Forge/Bundles/MapEdit/Map.m index 25c1c09e3..0d06cfd9e 100644 --- a/tools/Forge/Bundles/MapEdit/Map.m +++ b/tools/Forge/Bundles/MapEdit/Map.m @@ -1,4 +1,3 @@ - #include #include @@ -20,7 +19,7 @@ #define THING Map #include "THING+NSArray.m" -id map_i; +id map_i; @implementation Map /* @@ -30,7 +29,7 @@ FILE METHODS =============================================================================== */ -- init +- (id) init { self = [super init]; array = [[NSMutableArray alloc] init]; @@ -38,50 +37,49 @@ FILE METHODS minz = 0; maxz = 80; - oldselection =[[NSMutableArray alloc] init]; + oldselection = [[NSMutableArray alloc] init]; return self; } --saveSelected +- (id) saveSelected { - int i, c; - id o, w; + int i, c; + id o, w; [oldselection removeAllObjects]; - w =[self objectAtIndex:0]; - c =[w count]; + w = [self objectAtIndex: 0]; + c = [w count]; sb_newowner = oldselection; for (i = 0; i < c; i++) { - o =[w objectAtIndex:0]; + o = [w objectAtIndex: 0]; if ([o selected]) [o moveToEntity]; - else { - [w removeObjectAtIndex:0]; - } + else + [w removeObjectAtIndex: 0]; } - c =[self count]; + c = [self count]; for (i = 0; i < c; i++) { - o =[self objectAtIndex:0]; - [self removeObjectAtIndex:0]; + o = [self objectAtIndex: 0]; + [self removeObjectAtIndex: 0]; [o removeAllObjects]; } return self; } --addSelected +- (id) addSelected { - int i, c; - id n, w; + int i, c; + id n, w; - c =[oldselection count]; - w =[self objectAtIndex:0]; // world object + c = [oldselection count]; + w = [self objectAtIndex: 0]; // world object sb_newowner = w; for (i = 0; i < c; i++) { - n =[oldselection objectAtIndex:i]; + n = [oldselection objectAtIndex: i]; [n moveToEntity]; i--; c--; @@ -91,148 +89,152 @@ FILE METHODS return self; } - --newMap +- (id) newMap { - id ent; + id ent; [self saveSelected]; - ent =[[Entity alloc] initClass:"worldspawn"]; - [self addObject:ent]; + ent = [[Entity alloc] initClass: "worldspawn"]; + [self addObject: ent]; currentEntity = NULL; - [self setCurrentEntity:ent]; + [self setCurrentEntity: ent]; [self addSelected]; return self; } --currentEntity +- (id) currentEntity { return currentEntity; } --setCurrentEntity:ent +- (id) setCurrentEntity: ent { - id old; + id old; old = currentEntity; currentEntity = ent; if (old != ent) { - [things_i newCurrentEntity]; // update inspector + [things_i newCurrentEntity]; // update inspector [inspcontrol_i setCurrentInspector: i_things]; } return self; } --(float) currentMinZ +- (float) currentMinZ { - float grid; + float grid; - grid =[xyview_i gridsize]; + grid = [xyview_i gridsize]; minz = grid * rint (minz / grid); + return minz; } --setCurrentMinZ:(float) m +- (id) setCurrentMinZ: (float)m { if (m > -2048) minz = m; + return self; } --(float) currentMaxZ +- (float) currentMaxZ { - float grid; + float grid; - [self currentMinZ]; // grid align + [self currentMinZ]; - grid =[xyview_i gridsize]; + // grid align + grid = [xyview_i gridsize]; maxz = grid * rint (maxz / grid); if (maxz <= minz) maxz = minz + grid; + return maxz; } --setCurrentMaxZ:(float) m +- (id) setCurrentMaxZ: (float)m { if (m < 2048) maxz = m; + return self; } --(void) removeObject:o +- (void) removeObject: o { - [super removeObject:o]; + [super removeObject: o]; - if (o == currentEntity) { // select the world - [self setCurrentEntity: [self objectAtIndex:0]]; - } + if (o == currentEntity) // select the world + [self setCurrentEntity: [self objectAtIndex: 0]]; return; } #define FN_DEVLOG "/qcache/devlog" --writeStats +- (id) writeStats { - FILE *f; - extern int c_updateall; - struct timeval tp; - struct timezone tzp; + FILE *f; + extern int c_updateall; + struct timeval tp; + struct timezone tzp; + + gettimeofday (&tp, &tzp); - gettimeofday(&tp, &tzp); - f = fopen (FN_DEVLOG, "a"); - fprintf (f,"%i %i\n", (int)tp.tv_sec, c_updateall); + fprintf (f, "%i %i\n", (int) tp.tv_sec, c_updateall); c_updateall = 0; fclose (f); return self; } --(int) numSelected +- (int) numSelected { - int i, c; - int num; + int i, c; + int num; num = 0; - c =[currentEntity count]; - for (i = 0; i < c; i++) - if ([[currentEntity objectAtIndex:i] selected]) + c = [currentEntity count]; + for (i = 0; i < c; i++) { + if ([[currentEntity objectAtIndex: i] selected]) num++; + } return num; } --selectedBrush +- (id) selectedBrush { - int i, c; - int num; + int i, c; + int num; num = 0; - c =[currentEntity count]; - for (i = 0; i < c; i++) - if ([[currentEntity objectAtIndex:i] selected]) - return[currentEntity objectAtIndex:i]; + c = [currentEntity count]; + for (i = 0; i < c; i++) { + if ([[currentEntity objectAtIndex: i] selected]) + return [currentEntity objectAtIndex: i]; + } return nil; } - /* ================= readMapFile ================= */ --readMapFile:(const char *) fname +- (id) readMapFile: (const char *)fname { - char *dat; - const char *wad, *cl; + char *dat; + const char *wad, *cl; id new; id ent; int i, c; vec3_t org; float angle; - QFile *file; - script_t *script; + QFile *file; + script_t *script; size_t size; [self saveSelected]; @@ -252,39 +254,39 @@ readMapFile Script_Start (script, fname, dat); do { - new =[[Entity alloc] initFromScript:script]; + new = [[Entity alloc] initFromScript: script]; if (!new) break; - [self addObject:new]; + [self addObject: new]; } while (1); free (dat); [self addSelected]; -// load the apropriate texture wad - wad =[currentEntity valueForQKey:"wad"]; + // load the apropriate texture wad + wad = [currentEntity valueForQKey: "wad"]; if (wad && wad[0]) { - if (wad[0] == '/') // remove old style fullpaths - [currentEntity removeKeyPair:"wad"]; - else { - if (strcmp ([texturepalette_i currentWad], wad)) - [project_i setTextureWad:wad]; - } + // remove old style fullpaths + if (wad[0] == '/') + [currentEntity removeKeyPair: "wad"]; + else if (strcmp ([texturepalette_i currentWad], wad)) + [project_i setTextureWad: wad]; } - [self setCurrentEntity: [self objectAtIndex:0]]; -// center the camera and XY view on the playerstart - c =[self count]; + [self setCurrentEntity: [self objectAtIndex: 0]]; + + // center the camera and XY view on the playerstart + c = [self count]; for (i = 1; i < c; i++) { - ent =[self objectAtIndex:i]; - cl =[ent valueForQKey:"classname"]; + ent = [self objectAtIndex: i]; + cl = [ent valueForQKey: "classname"]; if (cl && !strcasecmp (cl, "info_player_start")) { - angle = atof ([ent valueForQKey:"angle"]); + angle = atof ([ent valueForQKey: "angle"]); angle = angle / 180 * M_PI; - [ent getVector: org forKey:"origin"]; - [cameraview_i setOrigin: org angle:angle]; - [xyview_i centerOn:org]; + [ent getVector: org forKey: "origin"]; + [cameraview_i setOrigin: org angle: angle]; + [xyview_i centerOn: org]; break; } } @@ -297,20 +299,19 @@ readMapFile writeMapFile ================= */ --writeMapFile:(const char *) -fname useRegion:(BOOL) reg +- (id) writeMapFile: (const char *)fname + useRegion: (BOOL)reg { - FILE *f; - unsigned int i; + FILE *f; + unsigned int i; Sys_Printf ("writeMapFile: %s\n", fname); f = fopen (fname, "w"); if (!f) Sys_Error ("couldn't write %s", fname); - - for (i = 0; i <[self count]; i++) - [[self objectAtIndex: i] writeToFILE: f region:reg]; + for (i = 0; i < [self count]; i++) + [[self objectAtIndex: i] writeToFILE: f region: reg]; fclose (f); @@ -325,29 +326,27 @@ DRAWING ============================================================================== */ --(void)ZDrawSelf +- (void) ZDrawSelf { - int i, count; + int i, count; - count =[self count]; + count = [self count]; for (i = 0; i < count; i++) - [[self objectAtIndex:i] ZDrawSelf]; + [[self objectAtIndex: i] ZDrawSelf]; } --(void)RenderSelf:(void (*)(face_t *)) callback +- (void) RenderSelf: (void (*)(face_t *))callback { - int i, count; + int i, count; - count =[self count]; + count = [self count]; for (i = 0; i < count; i++) - [[self objectAtIndex: i] RenderSelf:callback]; + [[self objectAtIndex: i] RenderSelf: callback]; } - -//============================================================================ - +// ============================================================================ /* =================== @@ -357,35 +356,35 @@ A command-shift-click on an entity while an entity is selected will make a target connection from the original entity. =================== */ --entityConnect: (vec3_t) p1:(vec3_t) p2 +- (id) entityConnect: (vec3_t)p1 + : (vec3_t)p2 { - id oldent, ent; + id oldent, ent; - oldent =[self currentEntity]; - if (oldent ==[self objectAtIndex:0]) { + oldent = [self currentEntity]; + if (oldent == [self objectAtIndex: 0]) { Sys_Printf ("Must have a non-world entity selected to connect\n"); return self; } - [self selectRay: p1: p2:YES]; - ent =[self currentEntity]; + [self selectRay: p1: p2: YES]; + ent = [self currentEntity]; if (ent == oldent) { Sys_Printf ("Must click on a different entity to connect\n"); return self; } - if (ent ==[self objectAtIndex:0]) { + if (ent == [self objectAtIndex: 0]) { Sys_Printf ("Must click on a non-world entity to connect\n"); return self; } - [oldent setKey: "target" toValue:[ent targetname]]; + [oldent setKey: "target" toValue: [ent targetname]]; [quakeed_i updateAll]; return self; } - /* ================= selectRay @@ -394,27 +393,29 @@ If ef is true, any entity brush along the ray will be selected in preference to intervening world brushes ================= */ --selectRay: (vec3_t) p1: (vec3_t) p2:(BOOL) ef +- (id) selectRay: (vec3_t)p1 + : (vec3_t)p2 + : (BOOL)ef { - int i, j, c, c2; - id ent, bestent; - id brush, bestbrush; - int face, bestface; - float time, besttime; - texturedef_t *td; + int i, j, c, c2; + id ent, bestent; + id brush, bestbrush; + int face, bestface; + float time, besttime; + texturedef_t *td; bestent = nil; bestface = -1; bestbrush = nil; besttime = 99999; - c =[self count]; + c = [self count]; for (i = c - 1; i >= 0; i--) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = 0; j < c2; j++) { - brush =[ent objectAtIndex:j]; - [brush hitByRay: p1: p2: &time:&face]; + brush = [ent objectAtIndex: j]; + [brush hitByRay: p1 : p2 : &time : &face]; if (time < 0 || time > besttime) continue; bestent = ent; @@ -422,9 +423,9 @@ to intervening world brushes bestbrush = brush; bestface = face; } - if (i == 1 && ef && bestbrush) - break; // found an entity, so don't check the - // world + if (i == 1 && ef && bestbrush) // found an entity, don't check the + // world + break; } if (besttime == 99999) { @@ -433,32 +434,32 @@ to intervening world brushes } if ([bestbrush regioned]) { - Sys_Printf ("WANRING: clicked on regioned brush\n"); + Sys_Printf ("WARNING: clicked on regioned brush\n"); return self; } if (bestent != currentEntity) { - [self makeSelectedPerform:@selector (deselect)]; - [self setCurrentEntity:bestent]; + [self makeSelectedPerform: @selector (deselect)]; + [self setCurrentEntity: bestent]; } [quakeed_i disableFlushWindow]; if (![bestbrush selected]) { - if ([map_i numSelected] == 0) { // don't grab texture if others are - // selected - td =[bestbrush texturedefForFace:bestface]; - [texturepalette_i setTextureDef:td]; + // don't grab texture if others are selected + if ([map_i numSelected] == 0) { + td = [bestbrush texturedefForFace: bestface]; + [texturepalette_i setTextureDef: td]; } - [bestbrush setSelected:YES]; + [bestbrush setSelected: YES]; Sys_Printf ("selected entity %i brush %i face %i\n", - (int)[self indexOfObject: bestent], - (int)[bestent indexOfObject:bestbrush], bestface); + (int) [self indexOfObject: bestent], + (int) [bestent indexOfObject: bestbrush], bestface); } else { - [bestbrush setSelected:NO]; + [bestbrush setSelected: NO]; Sys_Printf ("deselected entity %i brush %i face %i\n", - (int)[self indexOfObject: bestent], - (int)[bestent indexOfObject:bestbrush], bestface); + (int) [self indexOfObject: bestent], + (int) [bestent indexOfObject: bestbrush], bestface); } [quakeed_i enableFlushWindow]; @@ -475,26 +476,27 @@ checks only the selected brushes Returns the brush hit, or nil if missed. ================= */ --grabRay: (vec3_t) p1:(vec3_t) p2 +- (id) grabRay: (vec3_t)p1 + : (vec3_t)p2 { - int i, j, c, c2; - id ent; - id brush, bestbrush; - int face; - float time, besttime; + int i, j, c, c2; + id ent; + id brush, bestbrush; + int face; + float time, besttime; bestbrush = nil; besttime = 99999; - c =[self count]; + c = [self count]; for (i = 0; i < c; i++) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = 0; j < c2; j++) { - brush =[ent objectAtIndex:j]; + brush = [ent objectAtIndex: j]; if (![brush selected]) continue; - [brush hitByRay: p1: p2: &time:&face]; + [brush hitByRay: p1 : p2 : &time : &face]; if (time < 0 || time > besttime) continue; besttime = time; @@ -504,7 +506,6 @@ Returns the brush hit, or nil if missed. if (besttime == 99999) return nil; - return bestbrush; } @@ -513,28 +514,28 @@ Returns the brush hit, or nil if missed. getTextureRay ================= */ --getTextureRay: (vec3_t) p1:(vec3_t) p2 +- (id) getTextureRay: (vec3_t)p1 + : (vec3_t)p2 { - int i, j, c, c2; - id ent, bestent; - id brush, bestbrush; - int face, bestface; - float time, besttime; - texturedef_t *td; - vec3_t mins, maxs; - + int i, j, c, c2; + id ent, bestent; + id brush, bestbrush; + int face, bestface; + float time, besttime; + texturedef_t *td; + vec3_t mins, maxs; bestbrush = nil; bestent = nil; besttime = 99999; bestface = -1; - c =[self count]; + c = [self count]; for (i = 0; i < c; i++) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = 0; j < c2; j++) { - brush =[ent objectAtIndex:j]; - [brush hitByRay: p1: p2: &time:&face]; + brush = [ent objectAtIndex: j]; + [brush hitByRay: p1 : p2 : &time : &face]; if (time < 0 || time > besttime) continue; bestent = ent; @@ -546,18 +547,17 @@ getTextureRay if (besttime == 99999) return nil; - if (![bestent modifiable]) { Sys_Printf ("can't modify spawned entities\n"); return self; } - td =[bestbrush texturedefForFace:bestface]; - [texturepalette_i setTextureDef:td]; + td = [bestbrush texturedefForFace: bestface]; + [texturepalette_i setTextureDef: td]; Sys_Printf ("grabbed texturedef and sizes\n"); - [bestbrush getMins: mins maxs:maxs]; + [bestbrush getMins: mins maxs: maxs]; minz = mins[2]; maxz = maxs[2]; @@ -570,27 +570,29 @@ getTextureRay setTextureRay ================= */ --setTextureRay: (vec3_t) p1: (vec3_t) p2:(BOOL) allsides; +- (id) setTextureRay: (vec3_t)p1 + : (vec3_t)p2 + : (BOOL)allsides; { - int i, j, c, c2; - id ent, bestent; - id brush, bestbrush; - int face, bestface; - float time, besttime; - texturedef_t td; + int i, j, c, c2; + id ent, bestent; + id brush, bestbrush; + int face, bestface; + float time, besttime; + texturedef_t td; bestent = nil; bestface = -1; bestbrush = nil; besttime = 99999; - c =[self count]; + c = [self count]; for (i = 0; i < c; i++) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = 0; j < c2; j++) { - brush =[ent objectAtIndex:j]; - [brush hitByRay: p1: p2: &time:&face]; + brush = [ent objectAtIndex: j]; + [brush hitByRay: p1 : p2 : &time : &face]; if (time < 0 || time > besttime) continue; bestent = ent; @@ -615,15 +617,20 @@ setTextureRay return self; } - [texturepalette_i getTextureDef:&td]; + [texturepalette_i getTextureDef: &td]; [quakeed_i disableFlushWindow]; if (allsides) { - [bestbrush setTexturedef:&td]; - Sys_Printf ("textured entity %i brush %i\n", (int)[self indexOfObject: bestent], (int)[bestent indexOfObject:bestbrush]); + [bestbrush setTexturedef: &td]; + Sys_Printf ("textured entity %i brush %i\n", + (int) [self indexOfObject: bestent], + (int) [bestent indexOfObject: bestbrush]); } else { - [bestbrush setTexturedef: &td forFace:bestface]; - Sys_Printf ("deselected entity %i brush %i face %i\n", (int)[self indexOfObject: bestent], (int)[bestent indexOfObject:bestbrush], bestface); + [bestbrush setTexturedef: &td forFace: bestface]; + Sys_Printf ("deselected entity %i brush %i face %i\n", + (int) [self indexOfObject: bestent], + (int) [bestent indexOfObject: bestbrush], + bestface); } [quakeed_i enableFlushWindow]; @@ -632,7 +639,6 @@ setTextureRay return self; } - /* ============================================================================== @@ -641,25 +647,25 @@ OPERATIONS ON SELECTIONS ============================================================================== */ --makeSelectedPerform:(SEL) sel +- (id) makeSelectedPerform: (SEL)sel { - int i, j, c, c2; - id ent, brush; - int total; + int i, j, c, c2; + id ent, brush; + int total; total = 0; - c =[self count]; + c = [self count]; for (i = c - 1; i >= 0; i--) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = c2 - 1; j >= 0; j--) { - brush =[ent objectAtIndex:j]; + brush = [ent objectAtIndex: j]; if (![brush selected]) continue; if ([brush regioned]) continue; total++; - [brush performSelector:sel]; + [brush performSelector: sel]; } } @@ -669,67 +675,66 @@ OPERATIONS ON SELECTIONS return self; } --makeUnselectedPerform:(SEL) sel +- (id) makeUnselectedPerform: (SEL)sel { - int i, j, c, c2; - id ent, brush; + int i, j, c, c2; + id ent, brush; - c =[self count]; + c = [self count]; for (i = c - 1; i >= 0; i--) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = c2 - 1; j >= 0; j--) { - brush =[ent objectAtIndex:j]; + brush = [ent objectAtIndex: j]; if ([brush selected]) continue; if ([brush regioned]) continue; - [brush performSelector:sel]; + [brush performSelector: sel]; } } return self; } --makeAllPerform:(SEL) sel +- (id) makeAllPerform: (SEL)sel { - int i, j, c, c2; - id ent, brush; + int i, j, c, c2; + id ent, brush; - c =[self count]; + c = [self count]; for (i = c - 1; i >= 0; i--) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = c2 - 1; j >= 0; j--) { - brush =[ent objectAtIndex:j]; + brush = [ent objectAtIndex: j]; if ([brush regioned]) continue; - [brush performSelector:sel]; + [brush performSelector: sel]; } } return self; } --makeGlobalPerform:(SEL) sel // in and out of region +- (id) makeGlobalPerform: (SEL)sel // in and out of region { - int i, j, c, c2; - id ent, brush; + int i, j, c, c2; + id ent, brush; - c =[self count]; + c = [self count]; for (i = c - 1; i >= 0; i--) { - ent =[self objectAtIndex:i]; - c2 =[ent count]; + ent = [self objectAtIndex: i]; + c2 = [ent count]; for (j = c2 - 1; j >= 0; j--) { - brush =[ent objectAtIndex:j]; - [brush performSelector:sel]; + brush = [ent objectAtIndex: j]; + [brush performSelector: sel]; } } return self; } - void sel_identity (void) { @@ -744,7 +749,7 @@ sel_identity (void) sel_z[2] = 1; } --transformSelection +- (id) transformSelection { if (![currentEntity modifiable]) { Sys_Printf ("can't modify spawned entities\n"); @@ -753,23 +758,22 @@ sel_identity (void) // find an origin to apply the transformation to sb_mins[0] = sb_mins[1] = sb_mins[2] = 99999; sb_maxs[0] = sb_maxs[1] = sb_maxs[2] = -99999; - [self makeSelectedPerform:@selector (addToBBox)]; - sel_org[0] =[xyview_i snapToGrid:(sb_mins[0] + sb_maxs[0]) / 2]; - sel_org[1] =[xyview_i snapToGrid:(sb_mins[1] + sb_maxs[1]) / 2]; - sel_org[2] =[xyview_i snapToGrid:(sb_mins[2] + sb_maxs[2]) / 2]; + [self makeSelectedPerform: @selector (addToBBox)]; + sel_org[0] = [xyview_i snapToGrid: (sb_mins[0] + sb_maxs[0]) / 2]; + sel_org[1] = [xyview_i snapToGrid: (sb_mins[1] + sb_maxs[1]) / 2]; + sel_org[2] = [xyview_i snapToGrid: (sb_mins[2] + sb_maxs[2]) / 2]; // do it! - [self makeSelectedPerform:@selector (transform)]; + [self makeSelectedPerform: @selector (transform)]; [quakeed_i updateAll]; return self; } - void swapvectors (vec3_t a, vec3_t b) { - vec3_t temp; + vec3_t temp; VectorCopy (a, temp); VectorCopy (b, a); @@ -784,7 +788,7 @@ UI operations =============================================================================== */ --rotate_x:sender +- (id) rotate_x: sender { sel_identity (); swapvectors (sel_y, sel_z); @@ -792,7 +796,7 @@ UI operations return self; } --rotate_y:sender +- (id) rotate_y: sender { sel_identity (); swapvectors (sel_x, sel_z); @@ -800,7 +804,7 @@ UI operations return self; } --rotate_z:sender +- (id) rotate_z: sender { sel_identity (); swapvectors (sel_x, sel_y); @@ -808,80 +812,76 @@ UI operations return self; } - --flip_x:sender +- (id) flip_x: sender { sel_identity (); sel_x[0] = -1; [self transformSelection]; - [map_i makeSelectedPerform:@selector (flipNormals)]; + [map_i makeSelectedPerform: @selector (flipNormals)]; return self; } --flip_y:sender +- (id) flip_y: sender { sel_identity (); sel_y[1] = -1; [self transformSelection]; - [map_i makeSelectedPerform:@selector (flipNormals)]; + [map_i makeSelectedPerform: @selector (flipNormals)]; return self; } - --flip_z:sender +- (id) flip_z: sender { sel_identity (); sel_z[2] = -1; [self transformSelection]; - [map_i makeSelectedPerform:@selector (flipNormals)]; + [map_i makeSelectedPerform: @selector (flipNormals)]; return self; } - --cloneSelection:sender +- (id) cloneSelection: sender { - int i, j, c, originalElements; - id o, b; - id new; + int i, j, c, originalElements; + id o, b; + id new; - sb_translate[0] = sb_translate[1] =[xyview_i gridsize]; + sb_translate[0] = sb_translate[1] = [xyview_i gridsize]; sb_translate[2] = 0; -// copy individual brushes in the world entity - o =[self objectAtIndex:0]; - c =[o count]; + // copy individual brushes in the world entity + o = [self objectAtIndex: 0]; + c = [o count]; for (i = 0; i < c; i++) { - b =[o objectAtIndex:i]; + b = [o objectAtIndex: i]; if (![b selected]) continue; - // copy the brush, then translate the original - new =[b copy]; - [new setSelected:YES]; + new = [b copy]; + [new setSelected: YES]; [new translate]; - [b setSelected:NO]; - [o addObject:new]; + [b setSelected: NO]; + [o addObject: new]; } -// copy entire entities otherwise - originalElements =[self count]; // don't copy the new ones + // copy entire entities otherwise + originalElements = [self count]; // don't copy the new ones for (i = 1; i < originalElements; i++) { - o =[self objectAtIndex:i]; - if (![[o objectAtIndex:0] selected]) + o = [self objectAtIndex: i]; + if (![[o objectAtIndex: 0] selected]) continue; - new =[o copy]; - [self addObject:new]; + new = [o copy]; + [self addObject: new]; - c =[o count]; + c = [o count]; for (j = 0; j < c; j++) - [[o objectAtIndex: j] setSelected:NO]; + [[o objectAtIndex: j] setSelected: NO]; - c =[new count]; + c = [new count]; for (j = 0; j < c; j++) { - b =[new objectAtIndex:j]; + b = [new objectAtIndex: j]; [b translate]; - [b setSelected:YES]; + [b setSelected: YES]; } } @@ -890,21 +890,21 @@ UI operations return self; } - --selectCompleteEntity:sender +- (id) selectCompleteEntity: sender { - id o; - int i, c; + id o; + int i, c; - o =[self selectedBrush]; + o = [self selectedBrush]; if (!o) { Sys_Printf ("nothing selected\n"); return self; } - o =[o parent]; - c =[o count]; + o = [o parent]; + c = [o count]; for (i = 0; i < c; i++) - [[o objectAtIndex: i] setSelected:YES]; + [[o objectAtIndex: i] setSelected: YES]; + Sys_Printf ("%i brushes selected\n", c); [quakeed_i updateAll]; @@ -912,9 +912,9 @@ UI operations return self; } --makeEntity:sender +- (id) makeEntity: sender { - if (currentEntity !=[self objectAtIndex:0]) { + if (currentEntity != [self objectAtIndex: 0]) { Sys_Printf ("ERROR: can't makeEntity inside an entity\n"); NSBeep (); return self; @@ -926,39 +926,37 @@ UI operations return self; } - sb_newowner =[[Entity alloc] initClass:[things_i spawnName]]; + sb_newowner = [[Entity alloc] initClass: [things_i spawnName]]; - if ([sb_newowner modifiable]) - [self makeSelectedPerform:@selector (moveToEntity)]; - else { // throw out seed brush and select - // entity fixed brush - [self makeSelectedPerform:@selector (remove)]; - [[sb_newowner objectAtIndex: 0] setSelected:YES]; + if ([sb_newowner modifiable]) { + [self makeSelectedPerform: @selector (moveToEntity)]; + } else { // throw out seed brush and select entity fixed brush + [self makeSelectedPerform: @selector (remove)]; + [[sb_newowner objectAtIndex: 0] setSelected: YES]; } - [self addObject:sb_newowner]; - [self setCurrentEntity:sb_newowner]; + [self addObject: sb_newowner]; + [self setCurrentEntity: sb_newowner]; [quakeed_i updateAll]; return self; } - --selbox:(SEL) selector +- (id) selbox: (SEL)selector { - id b; + id b; if ([self numSelected] != 1) { Sys_Printf ("must have a single brush selected\n"); return self; } - b =[self selectedBrush]; - [b getMins: select_min maxs:select_max]; + b = [self selectedBrush]; + [b getMins: select_min maxs: select_max]; [b remove]; - [self makeUnselectedPerform:selector]; + [self makeUnselectedPerform: selector]; Sys_Printf ("identified contents\n"); [quakeed_i updateAll]; @@ -966,66 +964,71 @@ UI operations return self; } --selectCompletelyInside:sender +- (id) selectCompletelyInside: sender { - return[self selbox:@selector (selectComplete)]; + return [self selbox: @selector (selectComplete)]; } --selectPartiallyInside:sender +- (id) selectPartiallyInside: sender { - return[self selbox:@selector (selectPartial)]; + return [self selbox: @selector (selectPartial)]; } - --tallBrush:sender +- (id) tallBrush: sender { - id b; - vec3_t mins, maxs; - texturedef_t td; + id b; + vec3_t mins, maxs; + texturedef_t td; if ([self numSelected] != 1) { Sys_Printf ("must have a single brush selected\n"); return self; } - b =[self selectedBrush]; + b = [self selectedBrush]; td = *[b texturedef]; - [b getMins: mins maxs:maxs]; + [b getMins: mins maxs: maxs]; [b remove]; mins[2] = -2048; maxs[2] = 2048; - b =[[SetBrush alloc] initOwner: [map_i objectAtIndex: 0] mins: mins maxs: maxs texture:&td]; - [[map_i objectAtIndex: 0] addObject:b]; - [b setSelected:YES]; + b = [[SetBrush alloc] initOwner: [map_i objectAtIndex: 0] + mins: mins + maxs: maxs + texture: &td]; + [[map_i objectAtIndex: 0] addObject: b]; + [b setSelected: YES]; [quakeed_i updateAll]; return self; } --shortBrush:sender +- (id) shortBrush: sender { - id b; - vec3_t mins, maxs; - texturedef_t td; + id b; + vec3_t mins, maxs; + texturedef_t td; if ([self numSelected] != 1) { Sys_Printf ("must have a single brush selected\n"); return self; } - b =[self selectedBrush]; + b = [self selectedBrush]; td = *[b texturedef]; - [b getMins: mins maxs:maxs]; + [b getMins: mins maxs: maxs]; [b remove]; mins[2] = 0; maxs[2] = 16; - b =[[SetBrush alloc] initOwner: [map_i objectAtIndex: 0] mins: mins maxs: maxs texture:&td]; - [[map_i objectAtIndex: 0] addObject:b]; - [b setSelected:YES]; + b = [[SetBrush alloc] initOwner: [map_i objectAtIndex: 0] + mins: mins + maxs: maxs + texture: &td]; + [[map_i objectAtIndex: 0] addObject: b]; + [b setSelected: YES]; [quakeed_i updateAll]; return self; @@ -1036,50 +1039,49 @@ UI operations subtractSelection ================== */ --subtractSelection:semder +- (id) subtractSelection: semder { - int i, j, c, c2; - id o, o2; - id sellist, sourcelist; + int i, j, c, c2; + id o, o2; + id sellist, sourcelist; Sys_Printf ("performing brush subtraction...\n"); - sourcelist =[[NSMutableArray alloc] init]; - sellist =[[NSMutableArray alloc] init]; - carve_in =[[NSMutableArray alloc] init]; - carve_out =[[NSMutableArray alloc] init]; + sourcelist = [[NSMutableArray alloc] init]; + sellist = [[NSMutableArray alloc] init]; + carve_in = [[NSMutableArray alloc] init]; + carve_out = [[NSMutableArray alloc] init]; - c =[currentEntity count]; + c = [currentEntity count]; for (i = 0; i < c; i++) { - o =[currentEntity objectAtIndex:i]; + o = [currentEntity objectAtIndex: i]; if ([o selected]) - [sellist addObject:o]; + [sellist addObject: o]; else - [sourcelist addObject:o]; + [sourcelist addObject: o]; } - - c =[sellist count]; + c = [sellist count]; for (i = 0; i < c; i++) { - o =[sellist objectAtIndex:i]; + o = [sellist objectAtIndex: i]; [o setCarveVars]; - c2 =[sourcelist count]; + c2 = [sourcelist count]; for (j = 0; j < c2; j++) { - o2 =[sourcelist objectAtIndex:j]; + o2 = [sourcelist objectAtIndex: j]; [o2 carve]; [carve_in removeAllObjects]; } - [sourcelist release]; // the individual have been moved/freed + [sourcelist release]; // the individual have been moved/freed sourcelist = carve_out; - carve_out =[[NSMutableArray alloc] init]; + carve_out = [[NSMutableArray alloc] init]; } -// add the selection back to the remnants + // add the selection back to the remnants [currentEntity removeAllObjects]; - [currentEntity addObjectsFromArray:sourcelist]; - [currentEntity addObjectsFromArray:sellist]; + [currentEntity addObjectsFromArray: sourcelist]; + [currentEntity addObjectsFromArray: sellist]; [sourcelist release]; [sellist release]; @@ -1088,7 +1090,7 @@ subtractSelection if (![currentEntity count]) { o = currentEntity; - [self removeObject:o]; + [self removeObject: o]; } Sys_Printf ("subtracted selection\n"); @@ -1097,5 +1099,4 @@ subtractSelection return self; } - @end diff --git a/tools/Forge/Bundles/MapEdit/PopScrollView.h b/tools/Forge/Bundles/MapEdit/PopScrollView.h index 233a7abfe..9f1148a13 100644 --- a/tools/Forge/Bundles/MapEdit/PopScrollView.h +++ b/tools/Forge/Bundles/MapEdit/PopScrollView.h @@ -3,15 +3,16 @@ #include -@interface PopScrollView:NSScrollView +@interface PopScrollView: NSScrollView { - id button1, button2; + id button1, button2; } --initWithFrame:(NSRect) -frameRect button1:b1 button2:b2; +- (id) initWithFrame: (NSRect)frameRect + button1: b1 + button2: b2; --tile; +- (id) tile; @end #endif // PopScrollView_h diff --git a/tools/Forge/Bundles/MapEdit/PopScrollView.m b/tools/Forge/Bundles/MapEdit/PopScrollView.m index aa4c9b6d7..6f2ad5791 100644 --- a/tools/Forge/Bundles/MapEdit/PopScrollView.m +++ b/tools/Forge/Bundles/MapEdit/PopScrollView.m @@ -1,4 +1,3 @@ - #include "PopScrollView.h" @implementation PopScrollView @@ -9,23 +8,26 @@ initWithFrame: button: Initizes a scroll view with a button at it's lower right corner ==================== */ -- initWithFrame:(NSRect) -frameRect button1:b1 button2:b2 { - [super initWithFrame:frameRect]; +- (id) initWithFrame: (NSRect)frameRect + button1: b1 + button2: b2 +{ + [super initWithFrame: frameRect]; - [self addSubview:b1]; - [self addSubview:b2]; + [self addSubview: b1]; + [self addSubview: b2]; button1 = b1; button2 = b2; - [self setHasHorizontalScroller:YES]; - [self setHasVerticalScroller:YES]; + [self setHasHorizontalScroller: YES]; + [self setHasVerticalScroller: YES]; - [self setBorderType:NSBezelBorder]; + [self setBorderType: NSBezelBorder]; return self; } + /* ================ tile @@ -33,49 +35,48 @@ tile Adjust the size for the pop up scale menu ================= */ --tile +- (id) tile { - NSRect scrollerframe; - NSRect buttonframe, buttonframe2; - NSRect newframe; + NSRect scrollerframe; + NSRect buttonframe, buttonframe2; + NSRect newframe; [super tile]; - buttonframe =[button1 frame]; - buttonframe2 =[button2 frame]; - scrollerframe =[_horizScroller frame]; + buttonframe = [button1 frame]; + buttonframe2 = [button2 frame]; + scrollerframe = [_horizScroller frame]; 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.height = scrollerframe.size.height; scrollerframe.size.width -= newframe.size.width; - [button1 setFrame:newframe]; + [button1 setFrame: newframe]; newframe.size.width = buttonframe2.size.width; newframe.origin.x -= newframe.size.width; - [button2 setFrame:newframe]; + [button2 setFrame: newframe]; scrollerframe.size.width -= newframe.size.width; - [_horizScroller setFrame:scrollerframe]; + [_horizScroller setFrame: scrollerframe]; return self; } /* -- superviewSizeChanged:(const NSSize *)oldSize +- (id) superviewSizeChanged: (const NSSize *)oldSize { - [super superviewSizeChanged: oldSize]; - - [[self docView] newSuperBounds]; - - return self; + [super superviewSizeChanged: oldSize]; + + [[self docView] newSuperBounds]; + + return self; } */ --(BOOL) acceptsFirstResponder +- (BOOL) acceptsFirstResponder { return YES; } - - @end diff --git a/tools/Forge/Bundles/MapEdit/Preferences.h b/tools/Forge/Bundles/MapEdit/Preferences.h index 015741a1b..fecffde4d 100644 --- a/tools/Forge/Bundles/MapEdit/Preferences.h +++ b/tools/Forge/Bundles/MapEdit/Preferences.h @@ -3,84 +3,82 @@ #include -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 // 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 - char projectpath[1024]; - char bspSound[1024]; + char projectpath[1024]; + char bspSound[1024]; - BOOL brushOffset; - BOOL showBSP; + BOOL brushOffset; + BOOL showBSP; - float xlight; - float ylight; - float zlight; // 0.0 - 1.0 + float xlight; + float ylight; + float zlight; // 0.0 - 1.0 - int startwad; // 0 - 2 + int startwad; // 0 - 2 // 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 showBSP_i; // Show BSP Output checkbox + id brushOffset_i; // Brush Offset 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 ylight_i; // Y-side lighting - id zlight_i; // Z-side lighting + id xlight_i; // X-side lighting + id ylight_i; // Y-side lighting + id zlight_i; // Z-side lighting - NSUserDefaults *prefs; + NSUserDefaults *prefs; } --readDefaults; +- (id) readDefaults; // // validate and set methods called by UI or defaults // --setProjectPath:(const char *) path; --setBspSoundPath:(const char *) path; // set the path of the soundfile - // externally --setShowBSP:(int) state; // set the state of ShowBSP --setBrushOffset:(int) state; // set the state of BrushOffset --setStartWad:(int) value; // set start wad (0-2) --setXlight:(float) value; // set Xlight value for CameraView --setYlight:(float) value; // set Ylight value for CameraView --setZlight:(float) value; // set Zlight value for CameraView +- (id) setProjectPath: (const char *)path; +- (id) setBspSoundPath: (const char *)path; // set the path of the soundfile +- (id) setShowBSP: (int)state; // set the state of ShowBSP +- (id) setBrushOffset: (int)state; // set the state of BrushOffset +- (id) setStartWad: (int)value; // set start wad (0-2) +- (id) setXlight: (float)value; // set Xlight value for CameraView +- (id) setYlight: (float)value; // set Ylight value for CameraView +- (id) setZlight: (float)value; // set Zlight value for CameraView // // UI targets // --setBspSound:sender; // use OpenPanel to select sound --setCurrentProject:sender; // make current roject the default --UIChanged:sender; // target for all checks and fields +- (id) setBspSound: sender; // use OpenPanel to select sound +- (id) setCurrentProject: sender; // make current project the default +- (id) UIChanged: sender; // target for all checks and fields // // methods used by other objects to retreive defaults // --playBspSound; +- (id) playBspSound; --(const char *) getProjectPath; --(int) getBrushOffset; // get the state --(int) getShowBSP; // get the state +- (const char *) getProjectPath; +- (int) getBrushOffset; // get the state +- (int) getShowBSP; // get the state --(float) getXlight; // get Xlight value --(float) getYlight; // get Ylight value --(float) getZlight; // get Zlight value - --(int) getStartWad; +- (float) getXlight; // get Xlight value +- (float) getYlight; // get Ylight value +- (float) getZlight; // get Zlight value +- (int) getStartWad; @end #endif // Preferences_h diff --git a/tools/Forge/Bundles/MapEdit/Preferences.m b/tools/Forge/Bundles/MapEdit/Preferences.m index 6821cf223..d86ed7480 100644 --- a/tools/Forge/Bundles/MapEdit/Preferences.m +++ b/tools/Forge/Bundles/MapEdit/Preferences.m @@ -8,20 +8,21 @@ #include "QuakeEd.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 void WriteStringDefault (id prefs, const char *name, const char *value) { - NSString *key = [NSString stringWithCString: name]; - NSString *val = [NSString stringWithCString: value]; - [prefs setObject:val forKey:key]; + NSString *key = [NSString stringWithCString: name]; + NSString *val = [NSString stringWithCString: value]; + + [prefs setObject: val forKey: key]; } void @@ -30,12 +31,12 @@ WriteNumericDefault (id prefs, const char *name, float value) WriteStringDefault (prefs, name, va ("%f", value)); } --init +- (id) init { [super init]; preferences_i = self; - NSMutableDictionary *defaults = [NSMutableDictionary dictionary]; + NSMutableDictionary *defaults = [NSMutableDictionary dictionary]; WriteStringDefault (defaults, "ProjectPath", ""); WriteStringDefault (defaults, "BspSoundPath", ""); @@ -47,7 +48,7 @@ WriteNumericDefault (id prefs, const char *name, float value) WriteNumericDefault (defaults, "Zlight", 0); prefs = [[NSUserDefaults standardUserDefaults] retain]; - [prefs registerDefaults:defaults]; + [prefs registerDefaults: defaults]; return self; } @@ -56,6 +57,7 @@ _atoi (const char *c) { if (!c) return 0; + return atoi (c); } @@ -64,88 +66,89 @@ _atof (const char *c) { if (!c) return 0; + return atof (c); } // // Read in at start of program // --readDefaults +- (id) readDefaults { - const char *string; + const char *string; float value = 0; string = [[prefs stringForKey: @"ProjectPath"] cString]; - [self setProjectPath:string]; + [self setProjectPath: string]; string = [[prefs stringForKey: @"BspSoundPath"] cString]; - [self setBspSoundPath:string]; + [self setBspSoundPath: string]; string = [[prefs stringForKey: @"ShowBSPOutput"] cString]; value = _atoi (string); - [self setShowBSP:value]; + [self setShowBSP: value]; string = [[prefs stringForKey: @"OffsetBrushCopy"] cString]; value = _atoi (string); - [self setBrushOffset:value]; + [self setBrushOffset: value]; string = [[prefs stringForKey: @"StartWad"] cString]; value = _atoi (string); - [self setStartWad:value]; + [self setStartWad: value]; string = [[prefs stringForKey: @"Xlight"] cString]; value = _atof (string); - [self setXlight:value]; + [self setXlight: value]; string = [[prefs stringForKey: @"Ylight"] cString]; value = _atof (string); - [self setYlight:value]; + [self setYlight: value]; string = [[prefs stringForKey: @"Zlight"] cString]; value = _atof (string); - [self setZlight:value]; + [self setZlight: value]; return self; } - --setProjectPath:(const char *) path +- (id) setProjectPath: (const char *)path { if (!path) path = ""; + strcpy (projectpath, path); - [startproject_i setStringValue: [NSString stringWithCString:path]]; + [startproject_i setStringValue: [NSString stringWithCString: path]]; WriteStringDefault (prefs, "ProjectPath", path); return self; } --setCurrentProject:sender +- (id) setCurrentProject: sender { - [startproject_i setStringValue: [NSString stringWithCString:[project_i - currentProjectFile]]]; - [self UIChanged:self]; + [startproject_i setStringValue: [NSString stringWithCString: [project_i + currentProjectFile + ]]]; + [self UIChanged: self]; return self; } --(const char *) getProjectPath +- (const char *) getProjectPath { return projectpath; } - // -//=============================================== +// =============================================== // BSP sound stuff -//=============================================== +// =============================================== // // Set the BSP sound using an OpenPanel // --setBspSound:sender +- (id) setBspSound: sender { id panel; - NSString *types[] = { @"snd" }; + NSString *types[] = {@"snd"}; int rtn; - NSArray *filenames; + NSArray *filenames; char path[1024], file[64]; panel = [NSOpenPanel new]; @@ -153,37 +156,36 @@ _atof (const char *c) // XXX ExtractFilePath (bspSound, path); // XXX ExtractFileBase (bspSound, file); - rtn = [panel runModalForDirectory: [NSString stringWithCString:path] - file: [NSString stringWithCString:file] - types: [NSArray arrayWithObjects: types count:1]]; + rtn = [panel runModalForDirectory: [NSString stringWithCString: path] + file: [NSString stringWithCString: file] + types: [NSArray arrayWithObjects: types count: 1] + ]; if (rtn) { - filenames =[panel filenames]; - strcpy (bspSound,[[panel directory] cString]); + filenames = [panel filenames]; + strcpy (bspSound, [[panel directory] cString]); strcat (bspSound, "/"); - strcat (bspSound,[[filenames objectAtIndex:0] cString]); - [self setBspSoundPath:bspSound]; + strcat (bspSound, [[filenames objectAtIndex: 0] cString]); + [self setBspSoundPath: bspSound]; [self playBspSound]; } return self; } - // // Play the BSP sound // --playBspSound +- (id) playBspSound { [bspSound_i play]; return self; } - // // Set the bspSound path // --setBspSoundPath:(const char *) path +- (id) setBspSoundPath: (const char *)path { if (!path) path = ""; @@ -193,30 +195,32 @@ _atof (const char *c) [bspSound_i release]; bspSound_i = nil; } - if (path[0] && access (path, R_OK)) - bspSound_i =[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:bspSound] byReference: YES]; - if (!bspSound_i) { - return self; + if (path[0] && access (path, R_OK)) { + bspSound_i = + [[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString: + bspSound] byReference: YES]; } + if (!bspSound_i) + return self; - [bspSoundField_i setStringValue: [NSString stringWithCString:bspSound]]; + [bspSoundField_i setStringValue: [NSString stringWithCString: bspSound]]; WriteStringDefault (prefs, "BspSoundPath", bspSound); return self; } -//=============================================== +// =============================================== // Show BSP Output management -//=============================================== +// =============================================== // // Set the state // --setShowBSP:(int) state +- (id) setShowBSP: (int)state { showBSP = state; - [showBSP_i setIntValue:state]; + [showBSP_i setIntValue: state]; WriteNumericDefault (prefs, "ShowBSPOutput", showBSP); return self; @@ -225,23 +229,22 @@ _atof (const char *c) // // Get the state // --(int) getShowBSP +- (int) getShowBSP { return showBSP; } - -//=============================================== +// =============================================== // "Offset Brush ..." management -//=============================================== +// =============================================== // // Set the state // --setBrushOffset:(int) state +- (id) setBrushOffset: (int)state { brushOffset = state; - [brushOffset_i setIntValue:state]; + [brushOffset_i setIntValue: state]; WriteNumericDefault (prefs, "OffsetBrushCopy", state); return self; } @@ -249,68 +252,67 @@ _atof (const char *c) // // Get the state // --(int) getBrushOffset +- (int) getBrushOffset { return brushOffset; } -//=============================================== +// =============================================== // StartWad -//=============================================== +// =============================================== --setStartWad:(int) value // set start wad (0-2) +- (id) setStartWad: (int)value // set start wad (0-2) { startwad = value; if (startwad < 0 || startwad > 2) startwad = 0; - [startwad_i selectCellAtRow: startwad column:0]; + [startwad_i selectCellAtRow: startwad column: 0]; WriteNumericDefault (prefs, "StartWad", value); return self; } --(int) getStartWad +- (int) getStartWad { return startwad; } - -//=============================================== +// =============================================== // X,Y,Z light values -//=============================================== +// =============================================== // // Set the state // --setXlight:(float) value +- (id) setXlight: (float)value { xlight = value; if (xlight < 0.25 || xlight > 1) xlight = 0.6; lightaxis[1] = xlight; - [xlight_i setFloatValue:xlight]; + [xlight_i setFloatValue: xlight]; WriteNumericDefault (prefs, "Xlight", xlight); return self; } --setYlight:(float) value +- (id) setYlight: (float)value { ylight = value; if (ylight < 0.25 || ylight > 1) ylight = 0.75; lightaxis[2] = ylight; - [ylight_i setFloatValue:ylight]; + [ylight_i setFloatValue: ylight]; WriteNumericDefault (prefs, "Ylight", ylight); return self; } --setZlight:(float) value +- (id) setZlight: (float)value { zlight = value; if (zlight < 0.25 || zlight > 1) zlight = 1; lightaxis[0] = zlight; - [zlight_i setFloatValue:zlight]; + [zlight_i setFloatValue: zlight]; WriteNumericDefault (prefs, "Zlight", zlight); return self; } @@ -318,23 +320,21 @@ _atof (const char *c) // // 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 @@ -342,24 +342,23 @@ UIChanged Grab all the current UI state ============ */ --UIChanged:sender +- (id) UIChanged: sender { Sys_Printf ("defaults updated\n"); - [self setProjectPath:[[startproject_i stringValue] cString]]; - [self setBspSoundPath:[[bspSoundField_i stringValue] cString]]; - [self setShowBSP:[showBSP_i intValue]]; - [self setBrushOffset:[brushOffset_i intValue]]; - [self setStartWad:[startwad_i selectedRow]]; - [self setXlight:[xlight_i floatValue]]; - [self setYlight:[ylight_i floatValue]]; - [self setZlight:[zlight_i floatValue]]; + [self setProjectPath: [[startproject_i stringValue] cString]]; + [self setBspSoundPath: [[bspSoundField_i stringValue] cString]]; + [self setShowBSP: [showBSP_i intValue]]; + [self setBrushOffset: [brushOffset_i intValue]]; + [self setStartWad: [startwad_i selectedRow]]; + [self setXlight: [xlight_i floatValue]]; + [self setYlight: [ylight_i floatValue]]; + [self setZlight: [zlight_i floatValue]]; - [map_i makeGlobalPerform:@selector (flushTextures)]; + [map_i makeGlobalPerform: @selector (flushTextures)]; [quakeed_i updateAll]; return self; } - @end diff --git a/tools/Forge/Bundles/MapEdit/Project.h b/tools/Forge/Bundles/MapEdit/Project.h index 925af3573..ab6b56625 100644 --- a/tools/Forge/Bundles/MapEdit/Project.h +++ b/tools/Forge/Bundles/MapEdit/Project.h @@ -4,111 +4,114 @@ #include #include -#define BASEPATHKEY "basepath" -#define MAPNAMESKEY "maps" -#define DESCKEY "desc" -#define WADSKEY "wads" -#define BSPFULLVIS "bspfullvis" -#define BSPFASTVIS "bspfastvis" -#define BSPNOVIS "bspnovis" -#define BSPRELIGHT "bsprelight" -#define BSPLEAKTEST "bspleaktest" -#define BSPENTITIES "bspentities" +#define BASEPATHKEY "basepath" +#define MAPNAMESKEY "maps" +#define DESCKEY "desc" +#define WADSKEY "wads" +#define BSPFULLVIS "bspfullvis" +#define BSPFASTVIS "bspfastvis" +#define BSPNOVIS "bspnovis" +#define BSPRELIGHT "bsprelight" +#define BSPLEAKTEST "bspleaktest" +#define BSPENTITIES "bspentities" -#define SUBDIR_ENT "progs" // subdir names in heirarchy -#define SUBDIR_MAPS "maps" -#define SUBDIR_GFX "gfx" +#define SUBDIR_ENT "progs" // subdir names in heirarchy +#define SUBDIR_MAPS "maps" +#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 mapbrowse_i; // outlet to QuakeEd Maps browser - id currentmap_i; // outlet to current map textfield - id mapList; // list of map names (Storage) - id descList; // list of map descriptions (Storage) - id wadList; // list of wad names (Storage) + id basepathinfo_i; // outlet to base path info textfield + id mapbrowse_i; // outlet to QuakeEd Maps browser + id currentmap_i; // outlet to current map textfield + id mapList; // list of map names (Storage) + id descList; // list of map descriptions (Storage) + id wadList; // list of wad names (Storage) - id pis_panel_i; // outlet to Project Info Settings - // (PIS) panel + id pis_panel_i; // outlet to Project Info Settings (PIS) + // panel - id pis_basepath_i; // outlet to PIS->base path - id pis_wads_i; // outlet to PIS->wad browser - id pis_fullvis_i; // outlet to PIS->full vis command - id pis_fastvis_i; // outlet to PIS->fast vis command - id pis_novis_i; // outlet to PIS->no vis command - id pis_relight_i; // outlet to PIS->relight command - id pis_leaktest_i; // outlet to PIS->leak test command + id pis_basepath_i; // outlet to PIS->base path + id pis_wads_i; // outlet to PIS->wad browser + id pis_fullvis_i; // outlet to PIS->full vis command + id pis_fastvis_i; // outlet to PIS->fast vis command + id pis_novis_i; // outlet to PIS->no vis command + id pis_relight_i; // outlet to PIS->relight command + id pis_leaktest_i; // outlet to PIS->leak test command - id BSPoutput_i; // outlet to Text + id 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_mapdirectory[128]; // derived from basepath - char path_finalmapdir[128]; // derived from basepath + char path_progdir[128]; // derived from basepath + char path_mapdirectory[128]; // derived from basepath + char path_finalmapdir[128]; // derived from basepath - char path_wad8[128]; // path of texture WAD for cmd-8 key - char path_wad9[128]; // path of texture WAD for cmd-9 key - char path_wad0[128]; // path of texture WAD for cmd-0 key + char path_wad8[128]; // path of texture WAD for cmd-8 key + char path_wad9[128]; // path of texture WAD for cmd-9 key + char path_wad0[128]; // path of texture WAD for cmd-0 key - char string_fullvis[1024]; // cmd-line parm - char string_fastvis[1024]; // cmd-line parm - char string_novis[1024]; // cmd-line parm - char string_relight[1024]; // cmd-line parm - char string_leaktest[1024]; // cmd-line parm - char string_entities[1024]; // cmd-line parm + char string_fullvis[1024]; // cmd-line parm + char string_fastvis[1024]; // cmd-line parm + char string_novis[1024]; // cmd-line parm + char string_relight[1024]; // cmd-line parm + char string_leaktest[1024]; // cmd-line parm + char string_entities[1024]; // cmd-line parm - int showDescriptions; // 1 = show map descs in browser + 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; --initVars; +- (id) initProject; +- (id) initVars; --(const char *) currentProjectFile; +- (const char *) currentProjectFile; --setTextureWad:(const char *) wf; +- (id) setTextureWad: (const char *)wf; --addToOutput:(const char *) string; --clearBspOutput:sender; --initProjSettings; --changeChar:(char) f to:(char) t in:(id) obj; +- (id) addToOutput: (const char *)string; +- (id) clearBspOutput: (id)sender; +- (id) initProjSettings; +- (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 - // path --openProjectFile:(const char *) path; // called by openProject and newProject --openProject; --clickedOnMap:sender; // called if clicked on map in browser --clickedOnWad:sender; // called if clicked on wad in browser +- (id) parseProjectFile; // read defaultsdatabase for project path +- (id) openProjectFile: (const char *)path; // called by openProject, newProject +- (id) openProject; +- (id) clickedOnMap: sender; // called if clicked on map in browser +- (id) 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 *) getFinalMapDirectory; --(const char *) getProgDirectory; +- (const char *) getWAD8; +- (const char *) getWAD9; +- (const char *) getWAD0; --(const char *) getWAD8; --(const char *) getWAD9; --(const char *) getWAD0; +- (const char *) getFullVisCmd; +- (const char *) getFastVisCmd; +- (const char *) getNoVisCmd; +- (const char *) getRelightCmd; +- (const char *) getLeaktestCmd; +- (const char *) getEntitiesCmd; --(const char *) getFullVisCmd; --(const char *) getFastVisCmd; --(const char *) getNoVisCmd; --(const char *) getRelightCmd; --(const char *) getLeaktestCmd; --(const char *) getEntitiesCmd; - -@end void -changeString (char cf, char ct, char *string); +@end +void changeString (char cf, char ct, char *string); #endif // Project_h diff --git a/tools/Forge/Bundles/MapEdit/Project.m b/tools/Forge/Bundles/MapEdit/Project.m index bece9f010..58395d791 100644 --- a/tools/Forge/Bundles/MapEdit/Project.m +++ b/tools/Forge/Bundles/MapEdit/Project.m @@ -1,8 +1,8 @@ -//====================================== +// ====================================== // // QuakeEd Project Management // -//====================================== +// ====================================== #include @@ -18,28 +18,27 @@ #include "Things.h" #include "TexturePalette.h" - -id project_i; +id project_i; @implementation Project --init +- (id) init { project_i = self; return self; } -//=========================================================== +// =========================================================== // // Project code // -//=========================================================== --initVars +// =========================================================== +- (id) initVars { - const char *s; - const char *pe; - char *ts; + const char *s; + const char *pe; + char *ts; ts = strdup ([preferences_i getProjectPath]); pe = QFS_SkipPath (ts); @@ -50,68 +49,67 @@ id project_i; strcat (path_progdir, SUBDIR_ENT); strcpy (path_mapdirectory, ts); - strcat (path_mapdirectory, SUBDIR_MAPS); // source dir + strcat (path_mapdirectory, SUBDIR_MAPS); // source dir 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 ((s =[projectInfo getStringFor:BASEPATHKEY])) { +#if 0 // FIXME: for "out-of-tree" projects ? + if ((s = [projectInfo getStringFor: BASEPATHKEY])) { strcpy (path_basepath, s); strcpy (path_progdir, s); strcat (path_progdir, "/" SUBDIR_ENT); strcpy (path_mapdirectory, s); - strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir + strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir strcpy (path_finalmapdir, s); - strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir + strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir - [basepathinfo_i setStringValue:s]; - // in Project Inspector + [basepathinfo_i setStringValue: s]; // in Project Inspector } #endif - if ((s =[projectInfo getStringFor:BSPFULLVIS])) { + if ((s = [projectInfo getStringFor: BSPFULLVIS])) { strcpy (string_fullvis, s); changeString ('@', '\"', string_fullvis); } - if ((s =[projectInfo getStringFor:BSPFASTVIS])) { + if ((s = [projectInfo getStringFor: BSPFASTVIS])) { strcpy (string_fastvis, s); changeString ('@', '\"', string_fastvis); } - if ((s =[projectInfo getStringFor:BSPNOVIS])) { + if ((s = [projectInfo getStringFor: BSPNOVIS])) { strcpy (string_novis, s); changeString ('@', '\"', string_novis); } - if ((s =[projectInfo getStringFor:BSPRELIGHT])) { + if ((s = [projectInfo getStringFor: BSPRELIGHT])) { strcpy (string_relight, s); changeString ('@', '\"', string_relight); } - if ((s =[projectInfo getStringFor:BSPLEAKTEST])) { + if ((s = [projectInfo getStringFor: BSPLEAKTEST])) { strcpy (string_leaktest, s); changeString ('@', '\"', string_leaktest); } - if ((s =[projectInfo getStringFor:BSPENTITIES])) { + if ((s = [projectInfo getStringFor: BSPENTITIES])) { strcpy (string_entities, s); changeString ('@', '\"', string_entities); } - // Build list of wads - wadList =[projectInfo parseMultipleFrom:WADSKEY]; + // Build list of wads + wadList = [projectInfo parseMultipleFrom: WADSKEY]; // Build list of maps & descriptions - mapList =[projectInfo parseMultipleFrom:MAPNAMESKEY]; - descList =[projectInfo parseMultipleFrom:DESCKEY]; - [self changeChar: '_' to: ' ' in:descList]; + mapList = [projectInfo parseMultipleFrom: MAPNAMESKEY]; + descList = [projectInfo parseMultipleFrom: DESCKEY]; + [self changeChar: '_' to: ' ' in: descList]; [self initProjSettings]; @@ -121,14 +119,14 @@ id project_i; // // Init Project Settings fields // --initProjSettings +- (id) initProjSettings { - [pis_basepath_i setStringValue: [NSString stringWithCString:path_basepath]]; - [pis_fullvis_i setStringValue: [NSString stringWithCString:string_fullvis]]; - [pis_fastvis_i setStringValue: [NSString stringWithCString:string_fastvis]]; - [pis_novis_i setStringValue: [NSString stringWithCString:string_novis]]; - [pis_relight_i setStringValue: [NSString stringWithCString:string_relight]]; - [pis_leaktest_i setStringValue: [NSString stringWithCString:string_leaktest]]; + [pis_basepath_i setStringValue: [NSString stringWithCString: path_basepath]]; + [pis_fullvis_i setStringValue: [NSString stringWithCString: string_fullvis]]; + [pis_fastvis_i setStringValue: [NSString stringWithCString: string_fastvis]]; + [pis_novis_i setStringValue: [NSString stringWithCString: string_novis]]; + [pis_relight_i setStringValue: [NSString stringWithCString: string_relight]]; + [pis_leaktest_i setStringValue: [NSString stringWithCString: string_leaktest]]; return self; } @@ -136,46 +134,46 @@ id project_i; // // Add text to the BSP Output window // --addToOutput:(const char *) string +- (id) addToOutput: (const char *)string { - int end; + int end; - end =[BSPoutput_i textLength]; - [BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0) withString: [NSString stringWithCString:string]]; + end = [BSPoutput_i textLength]; + [BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0) + withString: [NSString stringWithCString: string]]; - end =[BSPoutput_i textLength]; - [BSPoutput_i setSelectedRange:NSMakeRange (end, 0)]; + end = [BSPoutput_i textLength]; + [BSPoutput_i setSelectedRange: NSMakeRange (end, 0)]; // XXX [BSPoutput_i scrollSelToVisible]; return self; } --clearBspOutput:sender +- (id) clearBspOutput: sender { - int end; + int end; - end =[BSPoutput_i textLength]; - [BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString:@""]; + end = [BSPoutput_i textLength]; + [BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString: @""]; return self; } --print +- (id) print { // XXX [BSPoutput_i printPSCode:self]; return self; } - --initProject +- (id) initProject { [self parseProjectFile]; if (projectInfo == NULL) return self; [self initVars]; - [mapbrowse_i setReusesColumns:YES]; + [mapbrowse_i setReusesColumns: YES]; [mapbrowse_i loadColumnZero]; - [pis_wads_i setReusesColumns:YES]; + [pis_wads_i setReusesColumns: YES]; [pis_wads_i loadColumnZero]; [things_i initEntities]; @@ -186,15 +184,15 @@ id project_i; // // 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 max; - char *string; + int i; + int max; + char *string; - max =[obj count]; + max = [obj count]; for (i = 0; i < max; i++) { - string =[obj elementAt:i]; + string = [obj elementAt: i]; changeString (f, t, string); } return self; @@ -204,56 +202,56 @@ id project_i; // Fill the QuakeEd Maps or wads browser // (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; - int max; - char *name; - int i; + id cell, list; + int max; + char *name; + int i; - if (sender == mapbrowse_i) + if (sender == mapbrowse_i) { list = mapList; - else if (sender == pis_wads_i) + } else if (sender == pis_wads_i) { list = wadList; - else { + } else { list = nil; Sys_Error ("Project: unknown browser to fill"); } - max =[list count]; + max = [list count]; for (i = 0; i < max; i++) { - name =[list elementAt:i]; + name = [list elementAt: i]; [matrix addRow]; - cell =[matrix cellAtRow: i column:0]; - [cell setStringValue: [NSString stringWithCString:name]]; - [cell setLeaf:YES]; - [cell setLoaded:YES]; + cell = [matrix cellAtRow: i column: 0]; + [cell setStringValue: [NSString stringWithCString: name]]; + [cell setLeaf: YES]; + [cell setLoaded: YES]; } } // // Clicked on a map name or description! // --clickedOnMap:sender +- (id) clickedOnMap: sender { - id matrix; - int row; - const char *fname; - id panel; - NSModalSession session; + id matrix; + int row; + const char *fname; + id panel; + NSModalSession session; - matrix =[sender matrixInColumn:0]; - row =[matrix selectedRow]; + matrix = [sender matrixInColumn: 0]; + row = [matrix selectedRow]; fname = va ("%s/%s.map", path_mapdirectory, - (const char *) [mapList elementAt:row]); //XXX Storage + (const char *) [mapList elementAt: row]); // XXX Storage panel = NSGetAlertPanel (@"Loading...", - @"Loading map. Please wait.", NULL, NULL, NULL); + @"Loading map. Please wait.", NULL, NULL, NULL); session = [NSApp beginModalSessionForWindow: panel]; [NSApp runModalSession: session]; - [quakeed_i doOpen:fname]; + [quakeed_i doOpen: fname]; [NSApp endModalSession: session]; [panel close]; @@ -261,27 +259,26 @@ id project_i; return self; } - --setTextureWad:(const char *) wf +- (id) setTextureWad: (const char *)wf { int i, c; - const char *name; + const char *name; Sys_Printf ("loading %s\n", wf); // set the row in the settings inspector wad browser - c =[wadList count]; + c = [wadList count]; 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)) { - [[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column:0]; + [[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column: 0]; break; } } // update the texture inspector - [texturepalette_i initPaletteFromWadfile:wf]; - [[map_i objectAtIndex: 0] setKey: "wad" toValue:wf]; + [texturepalette_i initPaletteFromWadfile: wf]; + [[map_i objectAtIndex: 0] setKey: "wad" toValue: wf]; // [inspcontrol_i changeInspectorTo:i_textures]; [quakeed_i updateAll]; @@ -292,53 +289,54 @@ id project_i; // // Clicked on a wad name // --clickedOnWad:sender +- (id) clickedOnWad: sender { - id matrix; - int row; - char *name; + id matrix; + int row; + char *name; - matrix =[sender matrixInColumn:0]; - row =[matrix selectedRow]; + matrix = [sender matrixInColumn: 0]; + row = [matrix selectedRow]; - name = (char *)[wadList elementAt:row]; // XXX Storage - [self setTextureWad:name]; + name = (char *) [wadList elementAt: row]; // XXX Storage + [self setTextureWad: name]; return self; } - // // Read in the .QE_Project file // --parseProjectFile +- (id) parseProjectFile { - const char *path; + const char *path; int rtn; - path =[preferences_i getProjectPath]; + path = [preferences_i getProjectPath]; if (!path || !path[0] || access (path, 0)) { rtn = NSRunAlertPanel (@"Project Error!", - @"A default project has not been found.\n", - @"Open Project", NULL, NULL); - if ([self openProject] == nil) - while (1) // can't run without a project - [NSApp terminate:self]; + @"A default project has not been found.\n", + @"Open Project", NULL, NULL); + if ([self openProject] == nil) { + while (1) + [NSApp terminate: self]; // can't run without a project + } return self; } - [self openProjectFile:path]; + [self openProjectFile: path]; return self; } // // Loads and parses a project file // --openProjectFile:(const char *) path +- (id) openProjectFile: (const char *)path { - FILE *fp; - struct stat s; -Sys_Printf ("openProjectFile: %s\n", path); + FILE *fp; + struct stat s; + + Sys_Printf ("openProjectFile: %s\n", path); strcpy (path_projectinfo, path); projectInfo = NULL; @@ -349,13 +347,13 @@ Sys_Printf ("openProjectFile: %s\n", path); stat (path, &s); lastModified = s.st_mtime; - projectInfo =[(Dict *)[Dict alloc] initFromFile:fp]; + projectInfo = [(Dict *)[Dict alloc] initFromFile: fp]; fclose (fp); return self; } --(const char *) currentProjectFile +- (const char *) currentProjectFile { return path_projectinfo; } @@ -363,167 +361,177 @@ Sys_Printf ("openProjectFile: %s\n", path); // // Open a project file // --openProject +- (id) openProject { - const char *path; + const char *path; id openpanel; int rtn; - NSString *projtypes[] = { @"qpr" }; - NSArray *filenames; - const char *dir; + NSString *projtypes[] = {@"qpr"}; + NSArray *filenames; + const char *dir; - openpanel =[NSOpenPanel new]; - // [openpanel allowMultipleFiles:NO]; - // [openpanel chooseDirectories:NO]; - rtn =[openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes count:1]]; + openpanel = [NSOpenPanel new]; +// [openpanel allowMultipleFiles:NO]; +// [openpanel chooseDirectories:NO]; + rtn = [openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes + count: 1]]; if (rtn == NSOKButton) { - filenames =[openpanel filenames]; - dir =[[openpanel directory] cString]; + filenames = [openpanel filenames]; + dir = [[openpanel directory] cString]; dir = ""; - path = va ("%s/%s", dir,[[filenames objectAtIndex:0] cString]); + path = va ("%s/%s", dir, [[filenames objectAtIndex: 0] cString]); strcpy (path_projectinfo, path); - [self openProjectFile:path]; + [self openProjectFile: path]; return self; } return nil; } - // // 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 max; - const char *s; + const char *s; - max =[obj count]; + max = [obj count]; 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)) return 1; } return 0; } --(const char *) getMapDirectory +- (const char *) getMapDirectory { return path_mapdirectory; } --(const char *) getFinalMapDirectory +- (const char *) getFinalMapDirectory { return path_finalmapdir; } --(const char *) getProgDirectory +- (const char *) getProgDirectory { return path_progdir; } - // // Return the WAD name for cmd-8 // --(const char *) getWAD8 +- (const char *) getWAD8 { if (!path_wad8[0]) return NULL; + return path_wad8; } // // Return the WAD name for cmd-9 // --(const char *) getWAD9 +- (const char *) getWAD9 { if (!path_wad9[0]) return NULL; + return path_wad9; } // // Return the WAD name for cmd-0 // --(const char *) getWAD0 +- (const char *) getWAD0 { if (!path_wad0[0]) return NULL; + return path_wad0; } // // Return the FULLVIS cmd string // --(const char *) getFullVisCmd +- (const char *) getFullVisCmd { if (!string_fullvis[0]) return NULL; + return string_fullvis; } // // Return the FASTVIS cmd string // --(const char *) getFastVisCmd +- (const char *) getFastVisCmd { if (!string_fastvis[0]) return NULL; + return string_fastvis; } // // Return the NOVIS cmd string // --(const char *) getNoVisCmd +- (const char *) getNoVisCmd { if (!string_novis[0]) return NULL; + return string_novis; } // // Return the RELIGHT cmd string // --(const char *) getRelightCmd +- (const char *) getRelightCmd { if (!string_relight[0]) return NULL; + return string_relight; } // // Return the LEAKTEST cmd string // --(const char *) getLeaktestCmd +- (const char *) getLeaktestCmd { if (!string_leaktest[0]) return NULL; + return string_leaktest; } --(const char *) getEntitiesCmd +- (const char *) getEntitiesCmd { if (!string_entities[0]) return NULL; + return string_entities; } @end -//==================================================== + +// ==================================================== // C Functions -//==================================================== +// ==================================================== // // Change a character to a different char in a string // - void +void changeString (char cf, char ct, char *string) { unsigned int j; - for (j = 0; j < strlen (string); j++) + for (j = 0; j < strlen (string); j++) { if (string[j] == cf) string[j] = ct; + } } diff --git a/tools/Forge/Bundles/MapEdit/QuakeEd.h b/tools/Forge/Bundles/MapEdit/QuakeEd.h index a4da5de97..ddc901c53 100644 --- a/tools/Forge/Bundles/MapEdit/QuakeEd.h +++ b/tools/Forge/Bundles/MapEdit/QuakeEd.h @@ -3,106 +3,108 @@ #include -extern id quakeed_i; +extern id quakeed_i; -extern BOOL filter_light, filter_path, filter_entities; -extern BOOL filter_clip_brushes, filter_water_brushes, filter_world; +extern BOOL filter_light, filter_path, filter_entities; +extern BOOL filter_clip_brushes, filter_water_brushes, filter_world; -extern id g_cmd_out_i; +extern id g_cmd_out_i; double I_FloatTime (void); void NopSound (void); -@interface QuakeEd:NSWindow +@interface QuakeEd: NSWindow { - BOOL dirty; - char filename[1024]; // full path with .map extension + BOOL dirty; + char filename[1024]; // full path with .map extension - NSBitmapImageRep *cache[3]; - NSRect cache_rect[3]; - BOOL no_restore[3]; + NSBitmapImageRep *cache[3]; + NSRect cache_rect[3]; + BOOL no_restore[3]; +// // UI objects - id brushcount_i; - id entitycount_i; - id regionbutton_i; +// + id brushcount_i; + id entitycount_i; + id regionbutton_i; - id show_coordinates_i; - id show_names_i; + id show_coordinates_i; + id show_names_i; - id filter_light_i; - id filter_path_i; - id filter_entities_i; - id filter_clip_i; - id filter_water_i; - id filter_world_i; + id filter_light_i; + id filter_path_i; + id filter_entities_i; + id filter_clip_i; + id filter_water_i; + id filter_world_i; - id cmd_in_i; // text fields - id cmd_out_i; + id cmd_in_i; // text fields + 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; --(const char *) currentFilename; +- (id) setDefaultFilename; +- (const char *) currentFilename; --updateAll; // when a model has been changed --updateCamera; // when the camera has moved --updateXY; --updateZ; +- (id) updateAll; // when a model has been changed +- (id) updateCamera; // when the camera has moved +- (id) updateXY; +- (id) updateZ; --updateAll:sender; +- (id) updateAll: sender; --(void)cameraNoRestore: (NSRect) rect; --(void)xyNoRestore: (NSRect) rect; --(void)zNoRestore: (NSRect) rect; +- (void) cameraNoRestore: (NSRect)rect; +- (void) xyNoRestore: (NSRect)rect; +- (void) zNoRestore: (NSRect)rect; --newinstance; // force next flushwindow to clear all - // instance drawing --redrawInstance; // erase and redraw all instance now +- (id) newinstance; // force next flushwindow to clear all + // instance drawing +- (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; --centerCamera:sender; --centerZChecker:sender; +- (id) clear: sender; +- (id) centerCamera: sender; +- (id) centerZChecker: sender; --changeXYLookUp:sender; +- (id) changeXYLookUp: sender; --setBrushRegion:sender; --setXYRegion:sender; +- (id) setBrushRegion: sender; +- (id) setXYRegion: sender; --open:sender; --save:sender; --saveAs:sender; +- (id) open: sender; +- (id) save: 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; --BSP_FastVis:sender; --BSP_NoVis:sender; --BSP_relight:sender; --BSP_stop:sender; --BSP_entities:sender; +- (id) BSP_Full: sender; +- (id) BSP_FastVis: sender; +- (id) BSP_NoVis: sender; +- (id) BSP_relight: sender; +- (id) BSP_stop: 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) showNames; +- (BOOL) showCoordinates; +- (BOOL) showNames; @end #endif // QuakeEd_h diff --git a/tools/Forge/Bundles/MapEdit/QuakeEd.m b/tools/Forge/Bundles/MapEdit/QuakeEd.m index e5c0388c4..84a771573 100644 --- a/tools/Forge/Bundles/MapEdit/QuakeEd.m +++ b/tools/Forge/Bundles/MapEdit/QuakeEd.m @@ -18,31 +18,31 @@ #include "InspectorControl.h" #include "Project.h" -id quakeed_i; -id entclasses_i; +id quakeed_i; +id entclasses_i; -extern NSBezierPath *path; -id g_cmd_out_i; +extern NSBezierPath *path; +id g_cmd_out_i; -BOOL autodirty; -BOOL filter_light, filter_path, filter_entities; -BOOL filter_clip_brushes, filter_water_brushes, filter_world; +BOOL autodirty; +BOOL filter_light, filter_path, filter_entities; +BOOL filter_clip_brushes, filter_water_brushes, filter_world; -BOOL running; +BOOL running; -int bsppid; +int bsppid; #if 0 // example command strings -char *fullviscmd = - "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis $2\""; -char *fastviscmd = - "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis -fast $2\""; -char *noviscmd = - "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2\""; -char *relightcmd = "rsh satan \"/LocalApps/light $2\""; -char *leakcmd = "rsh satan \"/LocalApps/qbsp -mark -notjunc $1 $2\""; +char *fullviscmd = + "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis $2\""; +char *fastviscmd = + "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis -fast $2\""; +char *noviscmd = + "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2\""; +char *relightcmd = "rsh satan \"/LocalApps/light $2\""; +char *leakcmd = "rsh satan \"/LocalApps/qbsp -mark -notjunc $1 $2\""; #endif void @@ -51,7 +51,6 @@ NopSound (void) NSBeep (); } - void My_Malloc_Error (int code) { @@ -59,13 +58,13 @@ My_Malloc_Error (int code) write (1, "malloc error!\n", strlen ("malloc error!\n") + 1); } -#define FN_CMDOUT "/tmp/QuakeEdCmd.txt" +#define FN_CMDOUT "/tmp/QuakeEdCmd.txt" void DisplayCmdOutput (void) { - char *buffer; - QFile *file; - int size; + char *buffer; + QFile *file; + int size; file = Qopen (FN_CMDOUT, "rt"); if (!file) @@ -75,14 +74,13 @@ DisplayCmdOutput (void) size = Qread (file, buffer, size); Qclose (file); unlink (FN_CMDOUT); - [project_i addToOutput:buffer]; + [project_i addToOutput: buffer]; free (buffer); if ([preferences_i getShowBSP]) - [inspcontrol_i setCurrentInspector:i_output]; + [inspcontrol_i setCurrentInspector: i_output]; [preferences_i playBspSound]; - } /* @@ -92,36 +90,35 @@ CheckCmdDone See if the BSP is done =============== */ -//DPSTimedEntry cmdte; +// DPSTimedEntry cmdte; void -CheckCmdDone ( /* DPSTimedEntry tag, */ double now, void *userData) +CheckCmdDone (/* DPSTimedEntry tag, */ double now, void *userData) { - union wait statusp; - struct rusage rusage; + union wait statusp; + struct rusage rusage; if (!wait4 (bsppid, &statusp, WNOHANG, &rusage)) return; DisplayCmdOutput (); bsppid = 0; -// DPSRemoveTimedEntry( cmdte ); +// DPSRemoveTimedEntry( cmdte ); } void QuakeEd_print (const char *fmt, va_list args) { - static dstring_t *output; - NSString *string; + static dstring_t *output; + NSString *string; if (!output) output = dstring_new (); - dvsprintf (output, fmt, args); string = [NSString stringWithCString: output->str]; [g_cmd_out_i setStringValue: string]; fputs (output->str, stdout); } -//============================================================================ +// ============================================================================ @implementation QuakeEd /* @@ -131,28 +128,27 @@ AutoSave Every five minutes, save a modified map =============== */ -- (void) AutoSave { +- (void) AutoSave +{ // automatic backup if (autodirty) { autodirty = NO; #define FN_AUTOSAVE "/qcache/AutoSaveMap.map" - [map_i writeMapFile: (char *) FN_AUTOSAVE useRegion:NO]; + [map_i writeMapFile: (char *) FN_AUTOSAVE useRegion: NO]; } [map_i writeStats]; } - #define FN_TEMPSAVE "/qcache/temp.map" --setDefaultFilename +- (id) setDefaultFilename { strcpy (filename, FN_TEMPSAVE); - [self setTitleWithRepresentedFilename: [NSString stringWithCString:filename]]; + [self setTitleWithRepresentedFilename: [NSString stringWithCString: filename]]; return self; } - --(BOOL) dirty +- (BOOL) dirty { return dirty; } @@ -160,98 +156,106 @@ Every five minutes, save a modified map /* =============================================================================== - DISPLAY UPDATING (handles both camera and XYView) + DISPLAY UPDATING (handles both camera and XYView) =============================================================================== */ -BOOL updateinflight; +BOOL updateinflight; -BOOL clearinstance; +BOOL clearinstance; -BOOL updatexy; -BOOL updatez; -BOOL updatecamera; +BOOL updatexy; +BOOL updatez; +BOOL updatecamera; void postappdefined (void) { - NSEvent *ev; + NSEvent *ev; if (updateinflight) return; - -// post an event at the end of the que - ev =[NSEvent otherEventWithType: NSApplicationDefined location: NSZeroPoint modifierFlags: 0 timestamp:[[NSDate date] - timeIntervalSinceReferenceDate] - windowNumber: 0 context:[NSApp context] - subtype: 0 data1: 0 data2:0]; - [NSApp postEvent: ev atStart:NO]; + // post an event at the end of the que + ev = [NSEvent otherEventWithType: NSApplicationDefined + location: NSZeroPoint + modifierFlags: 0 + timestamp: [[NSDate date] timeIntervalSinceReferenceDate] + windowNumber: 0 + context: [NSApp context] + subtype: 0 + data1: 0 + data2: 0]; + [NSApp postEvent: ev atStart: NO]; updateinflight = YES; } +int c_updateall; -int c_updateall; - --updateAll // when a model has been changed +- (id) updateAll // when a model has been changed { updatecamera = updatexy = updatez = YES; c_updateall++; postappdefined (); + return self; } --updateAll:sender +- (id) updateAll: sender { [self updateAll]; + return self; } --updateCamera // when the camera has moved +- (id) updateCamera // when the camera has moved { updatecamera = YES; clearinstance = YES; postappdefined (); + return self; } --updateXY +- (id) updateXY { updatexy = YES; postappdefined (); + return self; } --updateZ +- (id) updateZ { updatez = YES; postappdefined (); + return self; } --(void)cameraNoRestore: (NSRect) rect +- (void) cameraNoRestore: (NSRect)rect { no_restore[0] = YES; } --(void)xyNoRestore: (NSRect) rect +- (void) xyNoRestore: (NSRect)rect { no_restore[1] = YES; } --(void)zNoRestore: (NSRect) rect +- (void) zNoRestore: (NSRect)rect { no_restore[2] = YES; } --newinstance +- (id) newinstance { clearinstance = YES; return self; } --redrawInstance +- (id) redrawInstance { clearinstance = YES; [self flushWindow]; @@ -267,15 +271,15 @@ instance draw the brush after each flush */ - (void) flushWindow { - NSRect rect; - int i; - NSView *cv; + NSRect rect; + int i; + NSView *cv; [super flushWindow]; + // don't lock focus before nib is finished loading if (!running) - return; // don't lock focus before nib is - // finished loading + return; if (_disableFlushWindow) return; @@ -294,7 +298,7 @@ instance draw the brush after each flush } } rect = [cameraview_i frame]; - //rect = [cv convertRect: rect fromView: cameraview_i]; +// rect = [cv convertRect: rect fromView: cameraview_i]; cache_rect[0] = rect = NSIntegralRect (rect); cache[0] = [[NSBitmapImageRep alloc] initWithFocusedViewRect: rect]; @@ -311,14 +315,14 @@ instance draw the brush after each flush [cameraview_i lockFocus]; linestart (0, 0, 0); - [map_i makeSelectedPerform:@selector (CameraDrawSelf)]; + [map_i makeSelectedPerform: @selector (CameraDrawSelf)]; [clipper_i cameraDrawSelf]; lineflush (); [cameraview_i unlockFocus]; [xyview_i lockFocus]; linestart (0, 0, 0); - [map_i makeSelectedPerform:@selector (XYDrawSelf)]; + [map_i makeSelectedPerform: @selector (XYDrawSelf)]; lineflush (); [cameraview_i XYDrawSelf]; [zview_i XYDrawSelf]; @@ -326,7 +330,7 @@ instance draw the brush after each flush [xyview_i unlockFocus]; [zview_i lockFocus]; - [map_i makeSelectedPerform:@selector (ZDrawSelf)]; + [map_i makeSelectedPerform: @selector (ZDrawSelf)]; [cameraview_i ZDrawSelf]; [clipper_i ZDrawSelf]; [zview_i unlockFocus]; @@ -336,7 +340,6 @@ instance draw the brush after each flush [super flushWindow]; } - /* ============================================================================== @@ -345,17 +348,17 @@ App delegate methods ============================================================================== */ --applicationDefined:(NSEvent *) theEvent +- (id) applicationDefined: (NSEvent *)theEvent { - NSEvent *evp; + NSEvent *evp; updateinflight = NO; -// update screen - evp = [NSApp nextEventMatchingMask: NSAnyEventMask - untilDate: [NSDate distantPast] - inMode: NSEventTrackingRunLoopMode - dequeue: NO]; + // update screen + evp = [NSApp nextEventMatchingMask: NSAnyEventMask + untilDate: [NSDate distantPast] + inMode: NSEventTrackingRunLoopMode + dequeue: NO]; if (evp) { postappdefined (); return self; @@ -364,14 +367,17 @@ App delegate methods [self disableFlushWindow]; if ([map_i count] != (unsigned) [entitycount_i intValue]) - [entitycount_i setIntValue:[map_i count]]; + [entitycount_i setIntValue: [map_i count]]; + if ([[map_i currentEntity] count] != (unsigned) [brushcount_i intValue]) - [brushcount_i setIntValue:[[map_i currentEntity] count]]; + [brushcount_i setIntValue: [[map_i currentEntity] count]]; if (updatecamera) [cameraview_i display]; + if (updatexy) [xyview_i display]; + if (updatez) [zview_i display]; @@ -385,152 +391,147 @@ App delegate methods return self; } --(void)awakeFromNib +- (void) awakeFromNib { // XXX [self addToEventMask: - // XXX NSRightMouseDragged|NSLeftMouseDragged]; + // XXX NSRightMouseDragged|NSLeftMouseDragged]; // XXX malloc_error(My_Malloc_Error); quakeed_i = self; dirty = autodirty = NO; - [NSTimer timerWithTimeInterval: 5 * 60 target: self selector:@selector - (AutoSave) - userInfo: nil repeats:YES]; + [NSTimer timerWithTimeInterval: 5 * 60 + target: self + selector: @selector (AutoSave) + userInfo: nil + repeats: YES]; - path =[NSBezierPath new]; + path = [NSBezierPath new]; } --(void)applicationDidFinishLaunching:(NSNotification *) notification +- (void) applicationDidFinishLaunching: (NSNotification *)notification { - NSArray *screens; - NSScreen *scrn; + NSArray *screens; + NSScreen *scrn; running = YES; - g_cmd_out_i = cmd_out_i; // for qprintf + g_cmd_out_i = cmd_out_i; // for qprintf Sys_SetStdPrintf (QuakeEd_print); [preferences_i readDefaults]; [project_i initProject]; - [xyview_i setModeRadio:xy_drawmode_i]; + [xyview_i setModeRadio: xy_drawmode_i]; // because xy view is inside // scrollview and can't be // connected directly in IB - [self setFrameAutosaveName:@"EditorWinFrame"]; - [self clear:self]; + [self setFrameAutosaveName: @"EditorWinFrame"]; + [self clear: self]; -// go to my second monitor - screens =[NSScreen screens]; + // go to my second monitor + screens = [NSScreen screens]; if ([screens count] == 2) { - NSRect frm; - scrn =[screens objectAtIndex:1]; + NSRect frm; + scrn = [screens objectAtIndex: 1]; frm = [scrn frame]; - [self setFrameTopLeftPoint: NSMakePoint (frm.origin.x, - frm.size.height)]; + [self setFrameTopLeftPoint: NSMakePoint (frm.origin.x, frm.size.height)]; } - [self makeKeyAndOrderFront:self]; + [self makeKeyAndOrderFront: self]; -//[self doOpen: "/raid/quake/id1_/maps/amlev1.map"]; // DEBUG +// [self doOpen: "/raid/quake/id1_/maps/amlev1.map"]; // DEBUG [map_i newMap]; Sys_Printf ("ready.\n"); - -//malloc_debug(-1); // DEBUG +// malloc_debug(-1); // DEBUG } --appWillTerminate:sender +- (id) appWillTerminate: sender { -// FIXME: save dialog if dirty + // FIXME: save dialog if dirty return self; } +// =========================================================================== -//=========================================================================== - --textCommand:sender +- (id) textCommand: sender { - char const *t; + char const *t; - t =[[sender stringValue] cString]; + t = [[sender stringValue] cString]; if (!strcmp (t, "texname")) { - texturedef_t *td; - id b; + texturedef_t *td; + id b; - b =[map_i selectedBrush]; + b = [map_i selectedBrush]; if (!b) { Sys_Printf ("nothing selected\n"); return self; } - td =[b texturedef]; + td = [b texturedef]; Sys_Printf ("%s\n", td->texture); return self; - } else + } else { Sys_Printf ("Unknown command\n"); - return self; + } return self; } - --openProject:sender +- (id) openProject: sender { [project_i openProject]; return self; } - --clear:sender +- (id) clear: sender { [map_i newMap]; [self updateAll]; - [regionbutton_i setIntValue:0]; + [regionbutton_i setIntValue: 0]; [self setDefaultFilename]; return self; } - --centerCamera:sender +- (id) centerCamera: sender { - NSRect sbounds; + NSRect sbounds; - sbounds =[[xyview_i superview] bounds]; + sbounds = [[xyview_i superview] bounds]; sbounds.origin.x += sbounds.size.width / 2; sbounds.origin.y += sbounds.size.height / 2; - [cameraview_i setXYOrigin:&sbounds.origin]; + [cameraview_i setXYOrigin: &sbounds.origin]; [self updateAll]; return self; } --centerZChecker:sender +- (id) centerZChecker: sender { - NSRect sbounds; + NSRect sbounds; - sbounds =[[xyview_i superview] bounds]; + sbounds = [[xyview_i superview] bounds]; sbounds.origin.x += sbounds.size.width / 2; sbounds.origin.y += sbounds.size.height / 2; - [zview_i setPoint:&sbounds.origin]; + [zview_i setPoint: &sbounds.origin]; [self updateAll]; return self; } --changeXYLookUp:sender +- (id) changeXYLookUp: sender { - if ([sender intValue]) { + if ([sender intValue]) xy_viewnormal[2] = 1; - } else { + else xy_viewnormal[2] = -1; - } [self updateAll]; return self; } @@ -543,36 +544,35 @@ REGION MODIFICATION ============================================================================== */ - /* ================== applyRegion: ================== */ --applyRegion:sender +- (id) applyRegion: sender { - filter_clip_brushes =[filter_clip_i intValue]; - filter_water_brushes =[filter_water_i intValue]; - filter_light =[filter_light_i intValue]; - filter_path =[filter_path_i intValue]; - filter_entities =[filter_entities_i intValue]; - filter_world =[filter_world_i intValue]; + filter_clip_brushes = [filter_clip_i intValue]; + filter_water_brushes = [filter_water_i intValue]; + filter_light = [filter_light_i intValue]; + filter_path = [filter_path_i intValue]; + filter_entities = [filter_entities_i intValue]; + filter_world = [filter_world_i intValue]; if (![regionbutton_i intValue]) { region_min[0] = region_min[1] = region_min[2] = -9999; region_max[0] = region_max[1] = region_max[2] = 9999; } - [map_i makeGlobalPerform:@selector (newRegion)]; + [map_i makeGlobalPerform: @selector (newRegion)]; [self updateAll]; return self; } --setBrushRegion:sender +- (id) setBrushRegion: sender { - id b; + id b; // get the bounds of the current selection @@ -581,23 +581,23 @@ applyRegion: return self; } - b =[map_i selectedBrush]; - [b getMins: region_min maxs:region_max]; + b = [map_i selectedBrush]; + [b getMins: region_min maxs: region_max]; [b remove]; // turn region on - [regionbutton_i setIntValue:1]; - [self applyRegion:self]; + [regionbutton_i setIntValue: 1]; + [self applyRegion: self]; return self; } --setXYRegion:sender +- (id) setXYRegion: sender { - NSRect bounds; + NSRect bounds; // get xy size - bounds =[[xyview_i superview] bounds]; + bounds = [[xyview_i superview] bounds]; region_min[0] = bounds.origin.x; region_min[1] = bounds.origin.y; @@ -607,8 +607,8 @@ applyRegion: region_max[2] = 99999; // turn region on - [regionbutton_i setIntValue:1]; - [self applyRegion:self]; + [regionbutton_i setIntValue: 1]; + [self applyRegion: self]; return self; } @@ -616,17 +616,16 @@ applyRegion: // // UI querie for other objects // --(BOOL) showCoordinates +- (BOOL) showCoordinates { - return[show_coordinates_i intValue]; + return [show_coordinates_i intValue]; } --(BOOL) showNames +- (BOOL) showNames { - return[show_names_i intValue]; + return [show_names_i intValue]; } - /* ============================================================================== @@ -634,7 +633,6 @@ BSP PROCESSING ============================================================================== */ - void ExpandCommand (const char *in, char *out, char *src, char *dest) { @@ -655,20 +653,19 @@ ExpandCommand (const char *in, char *out, char *src, char *dest) *out = 0; } - /* ============= saveBSP ============= */ --saveBSP:(const char *) cmdline dialog:(BOOL) wt +- (id) saveBSP: (const char *)cmdline dialog: (BOOL)wt { char expandedcmd[1024]; char mappath[1024]; char bsppath[1024]; int oldLightFilter; int oldPathFilter; - const char *destdir; + const char *destdir; if (bsppid) { NSBeep (); @@ -677,32 +674,32 @@ saveBSP // // turn off the filters so all entities get saved // - oldLightFilter =[filter_light_i intValue]; - oldPathFilter =[filter_path_i intValue]; - [filter_light_i setIntValue:0]; - [filter_path_i setIntValue:0]; - [self applyRegion:self]; + oldLightFilter = [filter_light_i intValue]; + oldPathFilter = [filter_path_i intValue]; + [filter_light_i setIntValue: 0]; + [filter_path_i setIntValue: 0]; + [self applyRegion: self]; if ([regionbutton_i intValue]) { strcpy (mappath, filename); // XXX StripExtension (mappath); strcat (mappath, ".reg"); - [map_i writeMapFile: mappath useRegion:YES]; - wt = YES; // allways pop the dialog on region ops - } else + [map_i writeMapFile: mappath useRegion: YES]; + wt = YES; // allways pop the dialog on region ops + } else { strcpy (mappath, filename); + } + // save the entire thing, just in case there is a problem + [self save: self]; -// save the entire thing, just in case there is a problem - [self save:self]; - - [filter_light_i setIntValue:oldLightFilter]; - [filter_path_i setIntValue:oldPathFilter]; - [self applyRegion:self]; + [filter_light_i setIntValue: oldLightFilter]; + [filter_path_i setIntValue: oldPathFilter]; + [self applyRegion: self]; // // write the command to the bsp host -// - destdir =[project_i getFinalMapDirectory]; +// + destdir = [project_i getFinalMapDirectory]; strcpy (bsppath, destdir); strcat (bsppath, "/"); @@ -717,16 +714,17 @@ saveBSP printf ("system: %s", expandedcmd); [project_i addToOutput: (char *) "\n\n========= BUSY =========\n\n"]; - [project_i addToOutput:expandedcmd]; + [project_i addToOutput: expandedcmd]; if ([preferences_i getShowBSP]) - [inspcontrol_i setCurrentInspector:i_output]; - + [inspcontrol_i setCurrentInspector: i_output]; if (wt) { - id panel; - NSModalSession session; + id panel; + NSModalSession session; - panel = NSGetAlertPanel (@"BSP In Progress",[NSString stringWithCString:expandedcmd], NULL, NULL, NULL); + panel = NSGetAlertPanel (@"BSP In Progress", + [NSString stringWithCString: expandedcmd], + NULL, NULL, NULL); session = [NSApp beginModalSessionForWindow: panel]; system (expandedcmd); [NSApp endModalSession: session]; @@ -734,7 +732,7 @@ saveBSP NSReleaseAlertPanel (panel); DisplayCmdOutput (); } else { - // cmdte = DPSAddTimedEntry(1, CheckCmdDone, self, NS_BASETHRESHOLD); +// cmdte = DPSAddTimedEntry(1, CheckCmdDone, self, NS_BASETHRESHOLD); if (!(bsppid = fork ())) { system (expandedcmd); exit (0); @@ -744,38 +742,37 @@ saveBSP return self; } - --BSP_Full:sender +- (id) BSP_Full: sender { - [self saveBSP: [project_i getFullVisCmd] dialog:NO]; + [self saveBSP: [project_i getFullVisCmd] dialog: NO]; return self; } --BSP_FastVis:sender +- (id) BSP_FastVis: sender { - [self saveBSP: [project_i getFastVisCmd] dialog:NO]; + [self saveBSP: [project_i getFastVisCmd] dialog: NO]; return self; } --BSP_NoVis:sender +- (id) BSP_NoVis: sender { - [self saveBSP: [project_i getNoVisCmd] dialog:NO]; + [self saveBSP: [project_i getNoVisCmd] dialog: NO]; return self; } --BSP_relight:sender +- (id) BSP_relight: sender { - [self saveBSP: [project_i getRelightCmd] dialog:NO]; + [self saveBSP: [project_i getRelightCmd] dialog: NO]; return self; } --BSP_entities:sender +- (id) BSP_entities: sender { - [self saveBSP: [project_i getEntitiesCmd] dialog:NO]; + [self saveBSP: [project_i getEntitiesCmd] dialog: NO]; return self; } --BSP_stop:sender +- (id) BSP_stop: sender { if (!bsppid) { NSBeep (); @@ -783,14 +780,12 @@ saveBSP } kill (bsppid, 9); - // CheckCmdDone (cmdte, 0, NULL); +// CheckCmdDone (cmdte, 0, NULL); [project_i addToOutput: (char *) "\n\n========= STOPPED =========\n\n"]; return self; } - - /* ============== doOpen: @@ -798,14 +793,14 @@ doOpen: Called by open or the project panel ============== */ --doOpen:(const char *) fname; +- (id) doOpen: (const char *)fname; { strcpy (filename, fname); - [map_i readMapFile:filename]; + [map_i readMapFile: filename]; - [regionbutton_i setIntValue:0]; - [self setTitleWithRepresentedFilename: [NSString stringWithCString:fname]]; + [regionbutton_i setIntValue: 0]; + [self setTitleWithRepresentedFilename: [NSString stringWithCString: fname]]; [self updateAll]; Sys_Printf ("%s loaded\n", fname); @@ -813,167 +808,169 @@ Called by open or the project panel return self; } - /* ============== open ============== */ --open:sender; +- (id) open: sender; { id openpanel; - NSString *suffixlist[] = { @"map" }; + NSString *suffixlist[] = {@"map"}; - openpanel =[NSOpenPanel new]; + openpanel = [NSOpenPanel new]; - if ([openpanel runModalForDirectory: [NSString stringWithCString:[project_i - getMapDirectory]] - file: @"" types: [NSArray arrayWithObjects: suffixlist count:1]] != - NSOKButton) + if ([openpanel + runModalForDirectory: [NSString stringWithCString: [project_i + getMapDirectory]] + file: @"" + types: [NSArray arrayWithObjects: suffixlist count: 1]] + != NSOKButton) return self; - [self doOpen: [[openpanel filename] cString]]; return self; } - /* ============== save: ============== */ --save:sender; +- (id) save: sender; { - char backup[1024]; + char backup[1024]; // force a name change if using tempname if (!strcmp (filename, FN_TEMPSAVE)) - return[self saveAs:self]; - + return [self saveAs: self]; dirty = autodirty = NO; strcpy (backup, filename); // XXX StripExtension (backup); strcat (backup, ".bak"); - rename (filename, backup); // copy old to .bak + rename (filename, backup); // copy old to .bak - [map_i writeMapFile: filename useRegion:NO]; + [map_i writeMapFile: filename useRegion: NO]; return self; } - /* ============== saveAs ============== */ --saveAs:sender; +- (id) saveAs: sender; { - id panel_i; - char dir[1024]; + id panel_i; + char dir[1024]; - panel_i =[NSSavePanel new]; + panel_i = [NSSavePanel new]; // XXX ExtractFileBase (filename, dir); - [panel_i setRequiredFileType:@"map"]; - if ([panel_i runModalForDirectory: [NSString stringWithCString: [project_i getMapDirectory]] file: [NSString stringWithCString:dir]] != - NSOKButton) + [panel_i setRequiredFileType: @"map"]; + if ([panel_i + runModalForDirectory: [NSString stringWithCString: [project_i + getMapDirectory]] + file: [NSString stringWithCString: dir]] + != NSOKButton) return self; + strcpy (filename, [[panel_i filename] cString]); - strcpy (filename,[[panel_i filename] cString]); + [self setTitleWithRepresentedFilename: [NSString stringWithCString: filename]]; - [self setTitleWithRepresentedFilename: [NSString stringWithCString:filename]]; - - [self save:self]; + [self save: self]; return self; } - /* =============================================================================== - OTHER METHODS + OTHER METHODS =============================================================================== */ - // // AJR - added this for Project info // --(const char *) currentFilename +- (const char *) currentFilename { return filename; } --deselect:sender +- (id) deselect: sender { - if ([clipper_i hide]) // first click hides only the clipper - return[self updateAll]; + if ([clipper_i hide]) // first click hides only the clipper + return [self updateAll]; - [map_i setCurrentEntity: [map_i objectAtIndex:0]]; - // make world selected - [map_i makeSelectedPerform:@selector (deselect)]; + [map_i setCurrentEntity: [map_i objectAtIndex: 0]]; + + // make world selected + [map_i makeSelectedPerform: @selector (deselect)]; [self updateAll]; return self; } - /* =============== keyDown =============== */ --keyDown:(NSEvent *) theEvent +- (id) keyDown: (NSEvent *)theEvent { - NSString *chars = [theEvent characters]; - unichar c = [chars length] == 1 ? [chars characterAtIndex: 0] : '\0'; + NSString *chars = [theEvent characters]; + unichar c = ([chars length] == 1) ? [chars characterAtIndex: 0] : '\0'; +// // function keys +// switch (c) { case NSF2FunctionKey: - [cameraview_i setDrawMode:dr_wire]; + [cameraview_i setDrawMode: dr_wire]; Sys_Printf ("wire draw mode\n"); return self; + case NSF3FunctionKey: - [cameraview_i setDrawMode:dr_flat]; + [cameraview_i setDrawMode: dr_flat]; Sys_Printf ("flat draw mode\n"); return self; + case NSF4FunctionKey: - [cameraview_i setDrawMode:dr_texture]; + [cameraview_i setDrawMode: dr_texture]; Sys_Printf ("texture draw mode\n"); return self; case NSF5FunctionKey: - [xyview_i setDrawMode:dr_wire]; + [xyview_i setDrawMode: dr_wire]; Sys_Printf ("wire draw mode\n"); return self; + case NSF6FunctionKey: Sys_Printf ("texture draw mode\n"); return self; case NSF8FunctionKey: - [cameraview_i homeView:self]; + [cameraview_i homeView: self]; return self; case NSF12FunctionKey: - [map_i subtractSelection:self]; + [map_i subtractSelection: self]; return self; case NSPageUpFunctionKey: - [cameraview_i upFloor:self]; + [cameraview_i upFloor: self]; return self; case NSPageDownFunctionKey: - [cameraview_i downFloor:self]; + [cameraview_i downFloor: self]; return self; case NSEndFunctionKey: - [self deselect:self]; + [self deselect: self]; return self; case NSRightArrowFunctionKey: @@ -990,17 +987,17 @@ keyDown case 'C': case '.': case ',': - [cameraview_i _keyDown:theEvent]; + [cameraview_i _keyDown: theEvent]; break; - case 27: // escape + case 27: // escape autodirty = dirty = YES; - [self deselect:self]; + [self deselect: self]; return self; - case 127: // delete + case 127: // delete autodirty = dirty = YES; - [map_i makeSelectedPerform:@selector (remove)]; + [map_i makeSelectedPerform: @selector (remove)]; [clipper_i hide]; [self updateAll]; break; @@ -1010,56 +1007,58 @@ keyDown [self updateAll]; break; - case 13: // enter + case 13: // enter [clipper_i carve]; [self updateAll]; Sys_Printf ("carved brush\n"); break; case ' ': - [map_i cloneSelection:self]; + [map_i cloneSelection: self]; break; - // // move selection keys -// +// case '2': VectorCopy (vec3_origin, sb_translate); sb_translate[1] = -[xyview_i gridsize]; - [map_i makeSelectedPerform:@selector (translate)]; + [map_i makeSelectedPerform: @selector (translate)]; [self updateAll]; break; + case '8': VectorCopy (vec3_origin, sb_translate); - sb_translate[1] =[xyview_i gridsize]; - [map_i makeSelectedPerform:@selector (translate)]; + sb_translate[1] = [xyview_i gridsize]; + [map_i makeSelectedPerform: @selector (translate)]; [self updateAll]; break; case '4': VectorCopy (vec3_origin, sb_translate); sb_translate[0] = -[xyview_i gridsize]; - [map_i makeSelectedPerform:@selector (translate)]; + [map_i makeSelectedPerform: @selector (translate)]; [self updateAll]; break; + case '6': VectorCopy (vec3_origin, sb_translate); - sb_translate[0] =[xyview_i gridsize]; - [map_i makeSelectedPerform:@selector (translate)]; + sb_translate[0] = [xyview_i gridsize]; + [map_i makeSelectedPerform: @selector (translate)]; [self updateAll]; break; case '-': VectorCopy (vec3_origin, sb_translate); sb_translate[2] = -[xyview_i gridsize]; - [map_i makeSelectedPerform:@selector (translate)]; + [map_i makeSelectedPerform: @selector (translate)]; [self updateAll]; break; + case '+': VectorCopy (vec3_origin, sb_translate); - sb_translate[2] =[xyview_i gridsize]; - [map_i makeSelectedPerform:@selector (translate)]; + sb_translate[2] = [xyview_i gridsize]; + [map_i makeSelectedPerform: @selector (translate)]; [self updateAll]; break; @@ -1067,10 +1066,9 @@ keyDown Sys_Printf ("undefined keypress\n"); NopSound (); break; - } + } /* switch */ return self; } - @end diff --git a/tools/Forge/Bundles/MapEdit/QuakeEd_main.m b/tools/Forge/Bundles/MapEdit/QuakeEd_main.m index 745203afd..5bb8dc286 100644 --- a/tools/Forge/Bundles/MapEdit/QuakeEd_main.m +++ b/tools/Forge/Bundles/MapEdit/QuakeEd_main.m @@ -4,19 +4,18 @@ #include "QuakeEd.h" -@interface QuakeEdApp:NSApplication --(void)sendEvent:(NSEvent *) evt; +@interface QuakeEdApp: NSApplication +- (void) sendEvent: (NSEvent *)evt; @end @implementation QuakeEdApp --(void)sendEvent:(NSEvent *) evt; +- (void) sendEvent: (NSEvent *)evt; { - if ([evt type] == NSApplicationDefined) { + if ([evt type] == NSApplicationDefined) [quakeed_i applicationDefined: evt]; - } else { - [super sendEvent:evt]; - } + else + [super sendEvent: evt]; } @end diff --git a/tools/Forge/Bundles/MapEdit/SetBrush.h b/tools/Forge/Bundles/MapEdit/SetBrush.h index 491d47611..aa7b3d691 100644 --- a/tools/Forge/Bundles/MapEdit/SetBrush.h +++ b/tools/Forge/Bundles/MapEdit/SetBrush.h @@ -7,96 +7,96 @@ #include "TexturePalette.h" -#define MAX_FACES 16 +#define MAX_FACES 16 -typedef struct { - int numpoints; - vec5_t points[8]; // variable sized +typedef struct { + int numpoints; + vec5_t points[8]; // variable sized } winding_t; -#define MAX_POINTS_ON_WINDING 64 +#define MAX_POINTS_ON_WINDING 64 -typedef struct { - vec3_t normal; - float dist; +typedef struct { + vec3_t normal; + float dist; } plane_t; -typedef struct { +typedef struct { // implicit rep - vec3_t planepts[3]; - texturedef_t texture; + vec3_t planepts[3]; + texturedef_t texture; // cached rep plane_t plane; - qtexture_t *qtexture; - float light; // 0 - 1.0 - winding_t *w; + qtexture_t *qtexture; + float light; // 0 - 1.0 + winding_t *w; } face_t; -#define ON_EPSILON 0.1 -#define FP_EPSILON 0.01 -#define VECTOR_EPSILON 0.0001 - -#define SIDE_FRONT 0 -#define SIDE_BACK 1 -#define SIDE_ON 2 +#define ON_EPSILON 0.1 +#define FP_EPSILON 0.01 +#define VECTOR_EPSILON 0.0001 +#define SIDE_FRONT 0 +#define SIDE_BACK 1 +#define SIDE_ON 2 winding_t *ClipWinding (winding_t * in, plane_t *split); winding_t *CopyWinding (winding_t * w); winding_t *NewWinding (int points); - -@interface SetBrush:NSObject +@interface SetBrush: NSObject { - BOOL regioned; // not active - BOOL selected; + BOOL regioned; // not active + 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; - vec3_t entitycolor; - int numfaces; - face_t faces[MAX_FACES]; + id parent; // the entity this brush is in + vec3_t bmins, bmaxs; + vec3_t entitycolor; + int numfaces; + face_t faces[MAX_FACES]; } --initOwner:own mins:(float *)mins maxs:(float *)maxs - texture:(texturedef_t *)tex; +- (SetBrush *) initOwner: (id)own + 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; --setParent:(id) p; +- (id) parent; +- (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) regioned; +- (BOOL) selected; +- (BOOL) regioned; - (void) setSelected: (BOOL)s; - (void) setRegioned: (BOOL)s; - (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs; --(BOOL) containsPoint:(vec3_t) pt; +- (BOOL) containsPoint: (vec3_t)pt; - (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 *) texturedefForFace:(int) f; -- (void) setTexturedef:(texturedef_t *) tex; -- (void) setTexturedef:(texturedef_t *) tex forFace:(int) f; +- (texturedef_t *) texturedef; +- (texturedef_t *) texturedefForFace: (int)f; +- (void) setTexturedef: (texturedef_t *)tex; +- (void) setTexturedef: (texturedef_t *)tex forFace: (int)f; - (void) XYDrawSelf; - (void) ZDrawSelf; @@ -109,59 +109,59 @@ extern vec3_t region_min, region_max; // // single brush actions // -extern int numcontrolpoints; -extern float *controlpoints[MAX_FACES * 3]; +extern int numcontrolpoints; +extern float *controlpoints[MAX_FACES * 3]; - (void) getZdragface: (vec3_t)dragpoint; - (void) getXYdragface: (vec3_t)dragpoint; - (void) getXYShearPoints: (vec3_t)dragpoint; --addFace:(face_t *) f; +- (id) addFace: (face_t *)f; // // multiple brush actions // - (void) carveByClipper; -extern vec3_t sb_translate; +extern vec3_t sb_translate; - (void) translate; -extern id carve_in, carve_out; +extern id carve_in, carve_out; - (void) select; - (void) deselect; - (void) remove; - (void) flushTextures; -extern vec3_t sb_mins, sb_maxs; +extern vec3_t sb_mins, sb_maxs; - (void) addToBBox; -extern vec3_t sel_x, sel_y, sel_z; -extern vec3_t sel_org; +extern vec3_t sel_x, sel_y, sel_z; +extern vec3_t sel_org; - (void) transform; - (void) flipNormals; --carve; +- (id) carve; - (void) setCarveVars; -extern id sb_newowner; +extern id sb_newowner; - (void) moveToEntity; - (void) takeCurrentTexture; -extern vec3_t select_min, select_max; +extern vec3_t select_min, select_max; - (void) selectPartial; - (void) selectComplete; - (void) regionPartial; - (void) regionComplete; -extern float sb_floor_dir, sb_floor_dist; +extern float sb_floor_dir, sb_floor_dist; - (void) feetToFloor; diff --git a/tools/Forge/Bundles/MapEdit/SetBrush.m b/tools/Forge/Bundles/MapEdit/SetBrush.m index cb6a09e10..7ad7f72b4 100644 --- a/tools/Forge/Bundles/MapEdit/SetBrush.m +++ b/tools/Forge/Bundles/MapEdit/SetBrush.m @@ -19,32 +19,31 @@ textureAxisFromPlane ================== */ #if 1 -vec3_t baseaxis[18] = { - {0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor - {0, 0, -1}, {1, 0, 0}, {0, -1, 0}, // ceiling - {1, 0, 0}, {0, 1, 0}, {0, 0, -1}, // west wall - {-1, 0, 0}, {0, 1, 0}, {0, 0, -1}, // east wall - {0, 1, 0}, {1, 0, 0}, {0, 0, -1}, // south wall - {0, -1, 0}, {1, 0, 0}, {0, 0, -1} // north wall +vec3_t baseaxis[18] = { + { 0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor + { 0, 0, -1}, {1, 0, 0}, {0, -1, 0}, // ceiling + { 1, 0, 0}, {0, 1, 0}, {0, 0, -1}, // west wall + {-1, 0, 0}, {0, 1, 0}, {0, 0, -1}, // east wall + { 0, 1, 0}, {1, 0, 0}, {0, 0, -1}, // south wall + { 0, -1, 0}, {1, 0, 0}, {0, 0, -1} // north wall }; #else -vec3_t baseaxis[18] = { - {0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor - {0, 0, -1}, {1, 0, 0}, {0, 1, 0}, // ceiling - {1, 0, 0}, {0, 1, 0}, {0, 0, -1}, // west wall - {-1, 0, 0}, {0, -1, 0}, {0, 0, -1}, // east wall - {0, 1, 0}, {-1, 0, 0}, {0, 0, -1}, // south wall - {0, -1, 0}, {1, 0, 0}, {0, 0, -1} // north wall +vec3_t baseaxis[18] = { + { 0, 0, 1}, { 1, 0, 0}, {0, -1, 0}, // floor + { 0, 0, -1}, { 1, 0, 0}, {0, 1, 0}, // ceiling + { 1, 0, 0}, { 0, 1, 0}, {0, 0, -1}, // west wall + {-1, 0, 0}, { 0, -1, 0}, {0, 0, -1}, // east wall + { 0, 1, 0}, {-1, 0, 0}, {0, 0, -1}, // south wall + { 0, -1, 0}, { 1, 0, 0}, {0, 0, -1} // north wall }; #endif - float TextureAxisFromPlane (plane_t *pln, float *xv, float *yv) { - int bestaxis; - float dot, best; - int i; + int bestaxis; + float dot, best; + int i; best = 0; bestaxis = 0; @@ -63,7 +62,7 @@ TextureAxisFromPlane (plane_t *pln, float *xv, float *yv) return lightaxis[bestaxis >> 1]; } -#define BOGUS_RANGE 18000 +#define BOGUS_RANGE 18000 /* ================= @@ -76,10 +75,10 @@ void CheckFace (face_t * f) { int i, j; - float *p1, *p2; + float *p1, *p2; float d, edgedist; vec3_t dir, edgenormal; - winding_t *w; + winding_t *w; w = f->w; if (!w) @@ -91,9 +90,10 @@ CheckFace (face_t * f) for (i = 0; i < w->numpoints; i++) { p1 = w->points[i]; - for (j = 0; j < 3; j++) + for (j = 0; j < 3; j++) { if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE) Sys_Error ("CheckFace: BUGUS_RANGE: %f", p1[j]); + } j = i + 1 == w->numpoints ? 0 : i + 1; @@ -125,25 +125,23 @@ CheckFace (face_t * f) } } - /* ============================================================================= - TURN PLANES INTO GROUPS OF FACES + TURN PLANES INTO GROUPS OF FACES ============================================================================= */ - /* ================== NewWinding ================== */ -winding_t * +winding_t * NewWinding (int points) { - winding_t *w; + winding_t *w; size_t size; if (points > MAX_POINTS_ON_WINDING) @@ -156,17 +154,16 @@ NewWinding (int points) return w; } - /* ================== CopyWinding ================== */ -winding_t * +winding_t * CopyWinding (winding_t * w) { size_t size; - winding_t *c; + winding_t *c; size = (size_t) ((winding_t *) 0)->points[w->numpoints]; c = malloc (size); @@ -174,7 +171,6 @@ CopyWinding (winding_t * w) return c; } - /* ================== ClipWinding @@ -183,7 +179,7 @@ Clips the winding to the plane, returning the new winding on the positive side Frees the input winding. ================== */ -winding_t * +winding_t * ClipWinding (winding_t * in, plane_t *split) { float dists[MAX_POINTS_ON_WINDING]; @@ -191,13 +187,13 @@ ClipWinding (winding_t * in, plane_t *split) int counts[3]; float dot; int i, j; - float *p1, *p2, *mid; - winding_t *neww; + float *p1, *p2, *mid; + winding_t *neww; int maxpts; counts[0] = counts[1] = counts[2] = 0; -// determine sides for each point + // determine sides for each point for (i = 0; i < in->numpoints; i++) { dot = DotProduct (in->points[i], split->normal); dot -= split->dist; @@ -206,9 +202,8 @@ ClipWinding (winding_t * in, plane_t *split) sides[i] = SIDE_FRONT; else if (dot < -ON_EPSILON) sides[i] = SIDE_BACK; - else { + else sides[i] = SIDE_ON; - } counts[sides[i]]++; } sides[i] = sides[0]; @@ -216,7 +211,6 @@ ClipWinding (winding_t * in, plane_t *split) if (!counts[0] && !counts[1]) return in; - if (!counts[0]) { free (in); return NULL; @@ -224,8 +218,8 @@ ClipWinding (winding_t * in, plane_t *split) if (!counts[1]) return in; - maxpts = in->numpoints + 4; // can't use counts[0]+2 because - // of fp grouping errors + // can't use counts[0]+2 because of fp grouping errors + maxpts = in->numpoints + 4; neww = NewWinding (maxpts); for (i = 0; i < in->numpoints; i++) { @@ -255,7 +249,7 @@ ClipWinding (winding_t * in, plane_t *split) neww->numpoints++; dot = dists[i] / (dists[i] - dists[i + 1]); - for (j = 0; j < 3; j++) { // avoid round off error when possible + for (j = 0; j < 3; j++) { // avoid round off error when possible if (split->normal[j] == 1) mid[j] = split->dist; else if (split->normal[j] == -1) @@ -269,7 +263,7 @@ ClipWinding (winding_t * in, plane_t *split) if (neww->numpoints > maxpts) Sys_Error ("ClipWinding: points exceeded estimate"); -// free the original winding + // free the original winding free (in); return neww; @@ -282,23 +276,22 @@ BasePolyForPlane There has GOT to be a better way of doing this... ================= */ -winding_t * +winding_t * BasePolyForPlane (face_t * f) { - int i, x; - float max, v; - vec3_t org, vright, vup; - vec3_t xaxis, yaxis; - winding_t *w; - texturedef_t *td; - plane_t *p; - float ang, sinv, cosv; - float s, t, ns, nt; + int i, x; + float max, v; + vec3_t org, vright, vup; + vec3_t xaxis, yaxis; + winding_t *w; + texturedef_t *td; + plane_t *p; + float ang, sinv, cosv; + float s, t, ns, nt; p = &f->plane; -// find the major axis - + // find the major axis max = -BOGUS_RANGE; x = -1; for (i = 0; i < 3; i++) { @@ -308,6 +301,7 @@ BasePolyForPlane (face_t * f) max = v; } } + if (x == -1) Sys_Error ("BasePolyForPlane: no axis found"); @@ -317,6 +311,7 @@ BasePolyForPlane (face_t * f) case 1: vup[2] = 1; break; + case 2: vup[0] = 1; break; @@ -333,7 +328,7 @@ BasePolyForPlane (face_t * f) VectorScale (vup, 8192, vup); VectorScale (vright, 8192, vright); -// project a really big axis aligned box onto the plane + // project a really big axis-aligned box onto the plane w = NewWinding (4); w->numpoints = 4; @@ -349,18 +344,19 @@ BasePolyForPlane (face_t * f) VectorSubtract (org, vright, w->points[3]); VectorSubtract (w->points[3], vup, w->points[3]); -// set texture values + // set texture values f->light = TextureAxisFromPlane (&f->plane, xaxis, yaxis); td = &f->texture; -// rotate axis + // rotate axis ang = td->rotate / 180 * M_PI; sinv = sin (ang); cosv = cos (ang); - if (!td->scale[0]) + if (!(td->scale[0])) td->scale[0] = 1; - if (!td->scale[1]) + + if (!(td->scale[1])) td->scale[1] = 1; for (i = 0; i < 4; i++) { @@ -386,12 +382,12 @@ If a face has a NULL winding, it is an overconstraining plane and can be removed. =========== */ --calcWindings +- (id) calcWindings { int i, j, k; float v; - face_t *f; - winding_t *w; + face_t *f; + winding_t *w; plane_t plane; vec3_t t1, t2, t3; BOOL useplane[MAX_FACES]; @@ -425,19 +421,18 @@ can be removed. useplane[i] = YES; for (j = 0; j < i; j++) { if (f->plane.normal[0] == faces[j].plane.normal[0] - && f->plane.normal[1] == faces[j].plane.normal[1] - && f->plane.normal[2] == faces[j].plane.normal[2] - && f->plane.dist == faces[j].plane.dist) { + && f->plane.normal[1] == faces[j].plane.normal[1] + && f->plane.normal[2] == faces[j].plane.normal[2] + && f->plane.dist == faces[j].plane.dist) { useplane[i] = NO; break; } } - } for (i = 0; i < numfaces; i++) { - if (!useplane[i]) - continue; // duplicate plane + if (!useplane[i]) // duplicate plane + continue; f = &faces[i]; @@ -479,31 +474,32 @@ can be removed. return self; } -//============================================================================ +// ============================================================================ /* =========== initOwner::: =========== */ -- (SetBrush *)initOwner: own mins:(float *)mins - maxs:(float *)maxs - texture:(texturedef_t *) tex +- (SetBrush *) initOwner: own + mins: (float *)mins + maxs: (float *)maxs + texture: (texturedef_t *)tex { [super init]; parent = own; - [self setTexturedef:tex]; - [self setMins: mins maxs:maxs]; + [self setTexturedef: tex]; + [self setMins: mins maxs: maxs]; return self; } --setMins:(float *) -mins maxs:(float *) maxs +- (id) setMins: (float *) + mins maxs: (float *)maxs { - int i, j; - vec3_t pts[4][2]; + int i, j; + vec3_t pts[4][2]; for (i = 0; i < 3; i++) { if (maxs[i] - mins[i] <= 0) { @@ -562,7 +558,6 @@ mins maxs:(float *) maxs faces[4].planepts[2][1] = pts[2][1][1]; faces[4].planepts[2][2] = pts[2][1][2]; - faces[5].planepts[0][0] = pts[2][0][0]; faces[5].planepts[0][1] = pts[2][0][1]; faces[5].planepts[0][2] = pts[2][0][2]; @@ -575,43 +570,43 @@ mins maxs:(float *) maxs faces[5].planepts[2][1] = pts[0][0][1]; faces[5].planepts[2][2] = pts[0][0][2]; - [self calcWindings]; return self; } --parent +- (id) parent { return parent; } --setParent:(id) p +- (id) setParent: (id)p { parent = p; return self; } --setEntityColor:(vec3_t) color +- (id) setEntityColor: (vec3_t)color { VectorCopy (color, entitycolor); return self; } --(void)freeWindings +- (void) freeWindings { - int i; + int i; - for (i = 0; i < MAX_FACES; i++) + for (i = 0; i < MAX_FACES; i++) { if (faces[i].w) { free (faces[i].w); faces[i].w = NULL; } + } } --(void) dealloc +- (void) dealloc { [self freeWindings]; - return[super dealloc]; + return [super dealloc]; } /* @@ -619,12 +614,12 @@ mins maxs:(float *) maxs initOwner: fromTokens =========== */ -int numsb; +int numsb; --initFromScript:(script_t *)script owner:own +- (id) initFromScript: (script_t *)script owner: own { - face_t *f; - int i, j; + face_t *f; + int i, j; [self init]; @@ -647,7 +642,8 @@ int numsb; for (j = 0; j < 3; j++) { Script_GetToken (script, false); f->planepts[i][j] = atoi (Script_Token (script)); - } Script_GetToken (script, false); + } + Script_GetToken (script, false); if (strcmp (Script_Token (script), ")")) Sys_Error ("parsing map file"); @@ -675,9 +671,9 @@ int numsb; f->texture.scale[0] = 1; f->texture.scale[1] = 1; - #define TEX_FLIPAXIS 1 - #define TEX_FLIPS 2 - #define TEX_FLIPT 4 +# define TEX_FLIPAXIS 1 +# define TEX_FLIPS 2 +# define TEX_FLIPT 4 if (flags & TEX_FLIPAXIS) { f->texture.rotate = 90; @@ -691,7 +687,7 @@ int numsb; if (flags & TEX_FLIPT) f->texture.scale[1] = -1; } -#endif +#endif /* if 0 */ f++; numfaces++; } while (1); @@ -708,35 +704,32 @@ int numsb; writeToFILE =========== */ -- (void) writeToFILE:(FILE *)f - region:(BOOL) reg +- (void) writeToFILE: (FILE *)f + region: (BOOL)reg { - int i, j; - face_t *fa; - texturedef_t *td; - + int i, j; + face_t *fa; + texturedef_t *td; if (reg && regioned) return; - fprintf (f, "{\n"); for (i = 0; i < numfaces; i++) { fa = &faces[i]; - for (j = 0; j < 3; j++) + for (j = 0; j < 3; j++) { fprintf (f, "( %d %d %d ) ", (int) fa->planepts[j][0], - (int) fa->planepts[j][1], (int) fa->planepts[j][2]); + (int) fa->planepts[j][1], (int) fa->planepts[j][2]); + } td = &fa->texture; fprintf (f, "%s %d %d %d %f %f\n", td->texture, (int) td->shift[0], - (int) td->shift[1], (int) td->rotate, td->scale[0], - td->scale[1]); + (int) td->shift[1], (int) td->rotate, td->scale[0], + td->scale[1]); } fprintf (f, "}\n"); return; } - - /* ============================================================================== @@ -745,35 +738,33 @@ INTERACTION ============================================================================== */ -- (void)getMins:(vec3_t) -mins maxs:(vec3_t) maxs +- (void) getMins: (vec3_t)mins + maxs: (vec3_t)maxs { VectorCopy (bmins, mins); VectorCopy (bmaxs, maxs); } - --(BOOL) selected +- (BOOL) selected { return selected; } -- (void) setSelected:(BOOL) s +- (void) setSelected: (BOOL)s { selected = s; } --(BOOL) regioned +- (BOOL) regioned { return regioned; } -- (void)setRegioned:(BOOL) s +- (void) setRegioned: (BOOL)s { regioned = s; } - /* =========== setTexturedef @@ -781,25 +772,25 @@ setTexturedef */ - (void) setTexturedef: (texturedef_t *)tex { - int i; + int i; for (i = 0; i < MAX_FACES; i++) { faces[i].texture = *tex; - faces[i].qtexture = NULL; // recache next render + faces[i].qtexture = NULL; // recache next render } - [self calcWindings]; // in case texture coords changed + [self calcWindings]; // in case texture coords changed } -- (void) setTexturedef: (texturedef_t *)tex forFace: (int)f +- (void) setTexturedef: (texturedef_t *)tex + forFace: (int)f { if (f > numfaces) Sys_Error ("setTexturedef:forFace: bad face number %i", f); - faces[f].texture = *tex; - faces[f].qtexture = NULL; // recache next render + faces[f].qtexture = NULL; // recache next render - [self calcWindings]; // in case texture coords changed + [self calcWindings]; // in case texture coords changed } /* @@ -807,17 +798,16 @@ setTexturedef texturedef =========== */ --(texturedef_t *) texturedef +- (texturedef_t *) texturedef { return &faces[0].texture; } --(texturedef_t *) texturedefForFace:(int) f +- (texturedef_t *) texturedefForFace: (int)f { return &faces[f].texture; } - /* =========== removeIfInvalid @@ -825,19 +815,20 @@ removeIfInvalid So created veneers don't stay around =========== */ --removeIfInvalid +- (id) removeIfInvalid { - int i, j; + int i, j; for (i = 0; i < numfaces; i++) { if (faces[i].w) continue; for (j = i + 1; j < numfaces; j++) faces[j - 1] = faces[j]; + i--; numfaces--; } - for (; i < MAX_FACES; i++) + for ( ; i < MAX_FACES; i++) faces[i].w = NULL; if (numfaces < 4) { @@ -854,29 +845,35 @@ containsPoint =========== */ --(BOOL) containsPoint:(vec3_t) pt +- (BOOL) containsPoint: (vec3_t)pt { - int i; + int i; - for (i = 0; i < numfaces; i++) + for (i = 0; i < numfaces; i++) { if (DotProduct (faces[i].plane.normal, pt) >= faces[i].plane.dist) return NO; + } return YES; } /* =========== -clipRay +clipRay:::::: =========== */ --clipRay: (vec3_t) p1: (vec3_t) p2: (vec3_t) frontpoint: (int *) f_face: (vec3_t) backpoint:(int *) b_face +- (id) clipRay: (vec3_t)p1 + : (vec3_t)p2 + : (vec3_t)frontpoint + : (int *)f_face + : (vec3_t)backpoint + : (int *)b_face { - int frontface, backface; - int i, j; - face_t *f; - float d1, d2, m; - float *start; + int frontface, backface; + int i, j; + face_t *f; + float d1, d2, m; + float *start; start = p1; @@ -886,27 +883,28 @@ clipRay f = faces; for (i = 0; i < numfaces; i++, f++) { if (!f->w) - continue; // clipped off plane + continue; // clipped off plane d1 = DotProduct (p1, f->plane.normal) - f->plane.dist; d2 = DotProduct (p2, f->plane.normal) - f->plane.dist; - if (d1 >= 0 && d2 >= 0) { // the entire ray is in front of the - // polytope + if (d1 >= 0 && d2 >= 0) { // the whole ray is in front of the polytope *f_face = -1; *b_face = -1; return self; } - if (d1 > 0 && d2 < 0) { // new front plane + if (d1 > 0 && d2 < 0) { // new front plane frontface = i; m = d1 / (d1 - d2); for (j = 0; j < 3; j++) frontpoint[j] = p1[j] + m * (p2[j] - p1[j]); + p1 = frontpoint; } - if (d1 < 0 && d2 > 0) { // new back plane + if (d1 < 0 && d2 > 0) { // new back plane backface = i; m = d1 / (d1 - d2); for (j = 0; j < 3; j++) backpoint[j] = p1[j] + m * (p2[j] - p1[j]); + p2 = backpoint; } } @@ -917,34 +915,34 @@ clipRay return self; } - /* =========== -hitByRay +hitByRay:::: =========== */ -- (void) hitByRay: (vec3_t) p1: (vec3_t) p2: (float *) time:(int *) face +- (void) hitByRay: (vec3_t)p1 + : (vec3_t)p2 + : (float *)time + : (int *)face { - vec3_t frontpoint, backpoint, dir; - int frontface, backface; + vec3_t frontpoint, backpoint, dir; + int frontface, backface; if (regioned) { *time = -1; *face = -1; } - [self clipRay: p1: p2: frontpoint: &frontface: backpoint:&backface]; + [self clipRay: p1 : p2 : frontpoint : &frontface : backpoint : &backface]; - if (frontface == -2 && backface == -2) { // entire ray is inside the - // brush, select first face + if (frontface == -2 && backface == -2) { + // entire ray is inside the brush, select first face *time = 0; *face = 0; } - - if (frontface < 0) { // ray started inside the polytope, - // don't select it + if (frontface < 0) { // ray started inside the polytope, don't select it *time = -1; *face = -1; } @@ -960,7 +958,6 @@ hitByRay *face = frontface; } - /* ============================================================================== @@ -969,20 +966,20 @@ DRAWING ROUTINES ============================================================================== */ -BOOL fakebrush; +BOOL fakebrush; --drawConnections +- (id) drawConnections { id obj; int c, i; vec3_t dest, origin; vec3_t mid; vec3_t forward, right; - const char *targname; + const char *targname; vec3_t min, max, temp; - const char *targ; + const char *targ; - targ =[parent valueForQKey:"target"]; + targ = [parent valueForQKey: "target"]; if (!targ || !targ[0]) return self; @@ -990,14 +987,14 @@ BOOL fakebrush; origin[0] = (bmins[0] + bmaxs[0]) / 2; origin[1] = (bmins[1] + bmaxs[1]) / 2; - c =[map_i count]; + c = [map_i count]; for (i = 0; i < c; i++) { - obj =[map_i objectAtIndex:i]; - targname =[obj valueForQKey:"targetname"]; + obj = [map_i objectAtIndex: i]; + targname = [obj valueForQKey: "targetname"]; if (strcmp (targ, targname)) continue; - [[obj objectAtIndex: 0] getMins: min maxs:max]; + [[obj objectAtIndex: 0] getMins: min maxs: max]; dest[0] = (min[0] + max[0]) / 2; dest[1] = (min[1] + max[1]) / 2; @@ -1010,7 +1007,6 @@ BOOL fakebrush; if (!forward[0] && !forward[1]) continue; - VectorNormalize (forward); forward[0] = 8 * forward[0]; forward[1] = 8 * forward[1]; @@ -1027,28 +1023,27 @@ BOOL fakebrush; temp[0] = mid[0] - right[0] - forward[0]; temp[1] = mid[1] - right[1] - forward[1]; XYlineto (temp); - } return self; } --(BOOL) fakeBrush:(SEL) call +- (BOOL) fakeBrush: (SEL)call { - id copy; - face_t face; + id copy; + face_t face; if (!selected || fakebrush) return NO; - if (![clipper_i getFace:&face]) + if (![clipper_i getFace: &face]) return NO; fakebrush = YES; - copy =[self copy]; - copy =[copy addFace:&face]; + copy = [self copy]; + copy = [copy addFace: &face]; if (copy) { - [copy performSelector:call]; + [copy performSelector: call]; [copy dealloc]; } fakebrush = NO; @@ -1063,45 +1058,45 @@ XYDrawSelf - (void) XYDrawSelf { int i, j; - winding_t *w; + winding_t *w; vec3_t mid, end, s1, s2; - const char *val; + const char *val; float ang; id worldent, currentent; BOOL keybrush; - if ([self fakeBrush:@selector (XYDrawSelf)]) + if ([self fakeBrush: @selector (XYDrawSelf)]) return; - [xyview_i addToScrollRange: bmins[0]:bmins[1]]; - [xyview_i addToScrollRange: bmaxs[0]:bmaxs[1]]; + [xyview_i addToScrollRange: bmins[0] : bmins[1]]; + [xyview_i addToScrollRange: bmaxs[0] : bmaxs[1]]; - worldent =[map_i objectAtIndex:0]; - currentent =[map_i currentEntity]; + worldent = [map_i objectAtIndex: 0]; + currentent = [map_i currentEntity]; - if (parent != worldent && self ==[parent objectAtIndex:0]) + if (parent != worldent && self == [parent objectAtIndex: 0]) keybrush = YES; else keybrush = NO; if (parent != worldent && worldent == currentent) linecolor (entitycolor[0], entitycolor[1], entitycolor[2]); - else if (selected) - linecolor (1, 0, 0); // selected - else if (parent == currentent) - linecolor (0, 0, 0); // unselected, but in same entity - else - linecolor (0, 0.5, 0); // other entity green + else if (selected) // selected + linecolor (1, 0, 0); + else if (parent == currentent) // unselected, but in same entity + linecolor (0, 0, 0); + else // other entity green + linecolor (0, 0.5, 0); if (keybrush) - [self drawConnections]; // target line + [self drawConnections]; // target line if (!selected && - (bmaxs[0] < xy_draw_rect.origin.x - || bmaxs[1] < xy_draw_rect.origin.y - || bmins[0] > xy_draw_rect.origin.x + xy_draw_rect.size.width - || bmins[1] > xy_draw_rect.origin.y + xy_draw_rect.size.height)) - return; // off view, don't bother + (bmaxs[0] < xy_draw_rect.origin.x + || bmaxs[1] < xy_draw_rect.origin.y + || bmins[0] > xy_draw_rect.origin.x + xy_draw_rect.size.width + || bmins[1] > xy_draw_rect.origin.y + xy_draw_rect.size.height)) + return; // off view, don't bother for (i = 0; i < numfaces; i++) { w = faces[i].w; @@ -1116,12 +1111,10 @@ XYDrawSelf } if (keybrush) { -// angle arrow - val =[parent valueForQKey:"angle"]; + val = [parent valueForQKey: "angle"]; // angle arrow if (val && val[0]) { ang = atof (val) * M_PI / 180; - if (ang > 0) // negative values are up/down flags - { + if (ang > 0) { // negative values are up/down flags mid[0] = (bmins[0] + bmaxs[0]) / 2; mid[1] = (bmins[1] + bmaxs[1]) / 2; @@ -1158,13 +1151,13 @@ ZDrawSelf vec3_t p1, p2; vec3_t frontpoint, backpoint; int frontface, backface; - qtexture_t *q; + qtexture_t *q; - if ([self fakeBrush:@selector (ZDrawSelf)]) + if ([self fakeBrush: @selector (ZDrawSelf)]) return; - [zview_i addToHeightRange:bmins[2]]; - [zview_i addToHeightRange:bmaxs[2]]; + [zview_i addToHeightRange: bmins[2]]; + [zview_i addToHeightRange: bmaxs[2]]; if (selected) { [[NSColor redColor] set]; @@ -1174,16 +1167,17 @@ ZDrawSelf [zview_i getPoint: &p]; p1[0] = p.x; p1[1] = p.y; - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { if (bmins[i] >= p1[i] || bmaxs[i] <= p1[i]) return; + } p1[2] = 4096; p2[0] = p1[0]; p2[1] = p1[1]; p2[2] = -4096; - [self clipRay: p1: p2: frontpoint: &frontface: backpoint:&backface]; + [self clipRay: p1 : p2 : frontpoint : &frontface : backpoint : &backface]; if (frontface == -1 || backface == -1) return; @@ -1191,14 +1185,14 @@ ZDrawSelf q = TEX_ForName (faces[frontface].texture.texture); [[NSColor colorWithCalibratedRed: q->flatcolor.chan[0] / 255.0 - green: q->flatcolor.chan[1] / 255.0 - blue: q->flatcolor.chan[2] / 255.0 - alpha: 1.0] set]; + green: q->flatcolor.chan[1] / 255.0 + blue: q->flatcolor.chan[2] / 255.0 + alpha: 1.0] set]; NSRectFill (NSMakeRect (-8, backpoint[2], - 17, frontpoint[2] - backpoint[2] + 1)); + 17, frontpoint[2] - backpoint[2] + 1)); [[NSColor blackColor] set]; NSFrameRect (NSMakeRect (-12, backpoint[2], - 25, frontpoint[2] - backpoint[2] + 1)); + 25, frontpoint[2] - backpoint[2] + 1)); return; } @@ -1211,20 +1205,20 @@ CameraDrawSelf - (void) CameraDrawSelf { int i, j; - winding_t *w; + winding_t *w; id worldent, currentent; - if ([self fakeBrush:@selector (CameraDrawSelf)]) + if ([self fakeBrush: @selector (CameraDrawSelf)]) return; - worldent =[map_i objectAtIndex:0]; - currentent =[map_i currentEntity]; + worldent = [map_i objectAtIndex: 0]; + currentent = [map_i currentEntity]; if (parent != worldent && worldent == currentent) linecolor (entitycolor[0], entitycolor[1], entitycolor[2]); else if (selected) linecolor (1, 0, 0); - else if (parent ==[map_i currentEntity]) + else if (parent == [map_i currentEntity]) linecolor (0, 0, 0); else linecolor (0, 0.5, 0); @@ -1240,7 +1234,6 @@ CameraDrawSelf return; } - /* =========== XYRenderSelf @@ -1248,9 +1241,9 @@ XYRenderSelf */ - (void) XYRenderSelf { - int i; + int i; - if ([self fakeBrush:@selector (XYRenderSelf)]) + if ([self fakeBrush: @selector (XYRenderSelf)]) return; for (i = 0; i < numfaces; i++) @@ -1264,16 +1257,17 @@ XYRenderSelf CameraRenderSelf =========== */ --(void)CameraRenderSelf +- (void) CameraRenderSelf { - int i; - BOOL olddraw; - extern qtexture_t badtex; - pixel32_t p; + int i; + BOOL olddraw; + extern qtexture_t badtex; + pixel32_t p; - if ([self fakeBrush:@selector (CameraRenderSelf)]) + if ([self fakeBrush: @selector (CameraRenderSelf)]) return; -// hack to draw entity boxes as single flat color + + // hack to draw entity boxes as single flat color if (![parent modifiable]) { olddraw = r_drawflat; r_drawflat = YES; @@ -1305,33 +1299,33 @@ SINGLE BRUSH ACTIONS ============================================================================== */ -face_t *dragface, *dragface2; +face_t *dragface, *dragface2; -int numcontrolpoints; -float *controlpoints[MAX_FACES * 3]; +int numcontrolpoints; +float *controlpoints[MAX_FACES * 3]; --(BOOL) checkModifiable +- (BOOL) checkModifiable { // int i; if ([parent modifiable]) return YES; -// don't stretch spawned entities, move all points + // don't stretch spawned entities, move all points #if 0 numcontrolpoints = numfaces * 3; for (i = 0; i < numcontrolpoints; i++) controlpoints[i] = faces[i / 3].planepts[i % 3]; #endif + return NO; } -- (void) getZdragface:(vec3_t) dragpoint +- (void) getZdragface: (vec3_t)dragpoint { - int i, j; - float d; - + int i, j; + float d; if (![self checkModifiable]) return; @@ -1341,6 +1335,7 @@ float *controlpoints[MAX_FACES * 3]; for (i = 0; i < numfaces; i++) { if (!faces[i].w) continue; + if (faces[i].plane.normal[2] == 1) d = dragpoint[2] - faces[i].plane.dist; else if (faces[i].plane.normal[2] == -1) @@ -1358,10 +1353,10 @@ float *controlpoints[MAX_FACES * 3]; } } -- (void) getXYdragface:(vec3_t) dragpoint +- (void) getXYdragface: (vec3_t)dragpoint { - int i, j; - float d; + int i, j; + float d; numcontrolpoints = 0; @@ -1371,6 +1366,7 @@ float *controlpoints[MAX_FACES * 3]; for (i = 0; i < numfaces; i++) { if (!faces[i].w) continue; + if (faces[i].plane.normal[2]) continue; @@ -1385,44 +1381,42 @@ float *controlpoints[MAX_FACES * 3]; } } -- (void) getXYShearPoints:(vec3_t) dragpoint +- (void) getXYShearPoints: (vec3_t)dragpoint { int i, j, k; int facectl; float d; int numdragplanes; BOOL dragplane[MAX_FACES]; - winding_t *w; - face_t *f; + winding_t *w; + face_t *f; BOOL onplane[MAX_POINTS_ON_WINDING]; - if (![self checkModifiable]) return; - numcontrolpoints = 0; numdragplanes = 0; for (i = 0; i < numfaces; i++) { dragplane[i] = NO; if (!faces[i].w) continue; -// if (faces[i].plane.normal[2]) -// continue; +// if (faces[i].plane.normal[2]) +// continue; d = DotProduct (faces[i].plane.normal, dragpoint) - faces[i].plane.dist; if (d <= -ON_EPSILON) continue; - dragplane[i] = YES; numdragplanes++; } -// find faces that just share an edge with a drag plane + // find faces that just share an edge with a drag plane for (i = 0; i < numfaces; i++) { f = &faces[i]; w = f->w; if (!w) continue; + if (dragplane[i] && numdragplanes == 1) { for (j = 0; j < 3; j++) { controlpoints[numcontrolpoints] = faces[i].planepts[j]; @@ -1430,6 +1424,7 @@ float *controlpoints[MAX_FACES * 3]; } continue; } + if (!dragplane[i] && numdragplanes > 1) continue; @@ -1442,7 +1437,7 @@ float *controlpoints[MAX_FACES * 3]; if (k == i) continue; d = DotProduct (w->points[j], faces[k].plane.normal) - - faces[k].plane.dist; + - faces[k].plane.dist; if (fabs (d) > ON_EPSILON) continue; onplane[j] = YES; @@ -1450,6 +1445,7 @@ float *controlpoints[MAX_FACES * 3]; break; } } + if (facectl == 0) continue; @@ -1463,7 +1459,6 @@ float *controlpoints[MAX_FACES * 3]; continue; if (facectl == 3 && !onplane[(j + 2) % w->numpoints]) continue; - VectorCopy (w->points[j], f->planepts[k]); controlpoints[numcontrolpoints] = f->planepts[k]; numcontrolpoints++; @@ -1484,17 +1479,19 @@ float *controlpoints[MAX_FACES * 3]; break; } - for (; j < w->numpoints && k != 3; j++) + for ( ; j < w->numpoints && k != 3; j++) { if (!onplane[j]) { VectorCopy (w->points[j], f->planepts[k]); k++; } + } - for (j = 0; j < w->numpoints && k != 3; j++) + for (j = 0; j < w->numpoints && k != 3; j++) { if (!onplane[j]) { VectorCopy (w->points[j], f->planepts[k]); k++; } + } if (k != 3) { // Sys_Error ("getXYShearPoints: didn't get three points on plane"); @@ -1502,9 +1499,10 @@ float *controlpoints[MAX_FACES * 3]; return; } - for (j = 0; j < 3; j++) + for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) f->planepts[j][k] = rint (f->planepts[j][k]); + } } } @@ -1516,7 +1514,7 @@ MULTIPLE BRUSH ACTIONS ============================================================================== */ -vec3_t region_min, region_max; +vec3_t region_min, region_max; /* =========== @@ -1525,22 +1523,22 @@ newRegion Set the regioned flag based on if the object is containted in region_min/max =========== */ --newRegion +- (id) newRegion { int i; - const char *name; + const char *name; // filter away entities - if (parent !=[map_i objectAtIndex:0]) { + if (parent != [map_i objectAtIndex: 0]) { if (filter_entities) { regioned = YES; return self; } - name =[parent valueForQKey:"classname"]; + name = [parent valueForQKey: "classname"]; if ((filter_light && !strncmp (name, "light", 5)) - || (filter_path && !strncmp (name, "path", 4))) { + || (filter_path && !strncmp (name, "path", 4))) { regioned = YES; return self; } @@ -1572,91 +1570,92 @@ Set the regioned flag based on if the object is containted in region_min/max return self; } -vec3_t select_min, select_max; +vec3_t select_min, select_max; - (void) selectPartial { - int i; + int i; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { if (select_min[i] >= bmaxs[i] || select_max[i] <= bmins[i]) return; + } selected = YES; } --(void)selectComplete +- (void) selectComplete { - int i; + int i; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { if (select_min[i] > bmins[i] || select_max[i] < bmaxs[i]) return; + } selected = YES; } - --(void)regionPartial +- (void) regionPartial { - int i; + int i; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { if (select_min[i] >= bmaxs[i] || select_max[i] <= bmins[i]) - return self; + return; + } selected = YES; } --(void)regionComplete +- (void) regionComplete { - int i; + int i; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { if (select_min[i] > bmins[i] || select_max[i] < bmaxs[i]) return; + } selected = YES; } - -id sb_newowner; +id sb_newowner; - (void) moveToEntity { - id eclass; - float *c; + id eclass; + float *c; - [parent removeObject:self]; + [parent removeObject: self]; parent = sb_newowner; // hack to allow them to be copied to another map if ([parent respondsToSelector: @selector (valueForQKey:)]) { - eclass =[entity_classes_i classForName: [parent valueForQKey:"classname"]]; - c =[eclass drawColor]; - [self setEntityColor:c]; + eclass = [entity_classes_i classForName: [parent valueForQKey: "classname"]]; + c = [eclass drawColor]; + [self setEntityColor: c]; } - [parent addObject:self]; + [parent addObject: self]; } -vec3_t sb_translate; +vec3_t sb_translate; - (void) translate { - int i, j; + int i, j; // move the planes - for (i = 0; i < numfaces; i++) - for (j = 0; j < 3; j++) { - VectorAdd (faces[i].planepts[j], sb_translate, - faces[i].planepts[j]); - } + for (i = 0; i < numfaces; i++) { + for (j = 0; j < 3; j++) + VectorAdd (faces[i].planepts[j], sb_translate, faces[i].planepts[j]); + } [self calcWindings]; } -vec3_t sb_mins, sb_maxs; +vec3_t sb_mins, sb_maxs; - (void) addToBBox { - int k; + int k; if (numfaces < 4) return; @@ -1669,9 +1668,9 @@ vec3_t sb_mins, sb_maxs; } } --(void)flushTextures -{ // call when texture palette changes - int i; +- (void) flushTextures +{ // call when texture palette changes + int i; for (i = 0; i < MAX_FACES; i++) faces[i].qtexture = NULL; @@ -1679,46 +1678,45 @@ vec3_t sb_mins, sb_maxs; [self calcWindings]; } --(void)select +- (void) select { - [map_i setCurrentEntity:parent]; + [map_i setCurrentEntity: parent]; selected = YES; } --(void)deselect +- (void) deselect { selected = NO; -// the last selected brush determines +// the last selected brush determines if (invalid) printf ("WARNING: deselected invalid brush\n"); - [map_i setCurrentMinZ:bmins[2]]; - [map_i setCurrentMaxZ:bmaxs[2]]; + [map_i setCurrentMinZ: bmins[2]]; + [map_i setCurrentMaxZ: bmaxs[2]]; } --(void)remove +- (void) remove { -// the last selected brush determines +// the last selected brush determines if (!invalid) { - [map_i setCurrentMinZ:bmins[2]]; - [map_i setCurrentMaxZ:bmaxs[2]]; + [map_i setCurrentMinZ: bmins[2]]; + [map_i setCurrentMaxZ: bmaxs[2]]; } - [parent removeObject:self]; + [parent removeObject: self]; [self release]; } - -vec3_t sel_x, sel_y, sel_z; -vec3_t sel_org; +vec3_t sel_x, sel_y, sel_z; +vec3_t sel_org; - (void) transform { - int i, j; - vec3_t old; - float *p; + int i, j; + vec3_t old; + float *p; - for (i = 0; i < numfaces; i++) + for (i = 0; i < numfaces; i++) { for (j = 0; j < 3; j++) { p = faces[i].planepts[j]; VectorCopy (p, old); @@ -1728,15 +1726,16 @@ vec3_t sel_org; p[2] = DotProduct (old, sel_z); VectorAdd (p, sel_org, p); } + } [self calcWindings]; } --(void)flipNormals // used after an inside-out transform - // (flip x/y/z) +- (void) flipNormals // used after an inside-out transform + // (flip x/y/z) { - int i; - vec3_t temp; + int i; + vec3_t temp; for (i = 0; i < numfaces; i++) { VectorCopy (faces[i].planepts[0], temp); @@ -1748,41 +1747,40 @@ vec3_t sel_org; - (void) carveByClipper { - face_t face; + face_t face; - if (![clipper_i getFace:&face]) + if (![clipper_i getFace: &face]) return; - [self addFace:&face]; + [self addFace: &face]; } - (void) takeCurrentTexture { - texturedef_t td; + texturedef_t td; - [texturepalette_i getTextureDef:&td]; - [self setTexturedef:&td]; + [texturepalette_i getTextureDef: &td]; + [self setTexturedef: &td]; } - -float sb_floor_dir, sb_floor_dist; +float sb_floor_dir, sb_floor_dist; - (void) feetToFloor { - float oldz; - vec3_t p1, p2; - int frontface, backface; - vec3_t frontpoint, backpoint; - float dist; + float oldz; + vec3_t p1, p2; + int frontface, backface; + vec3_t frontpoint, backpoint; + float dist; - [cameraview_i getOrigin:p1]; + [cameraview_i getOrigin: p1]; VectorCopy (p1, p2); oldz = p1[2] - 48; p1[2] = 4096; p2[2] = -4096; - [self clipRay: p1: p2: frontpoint: &frontface: backpoint:&backface]; + [self clipRay: p1 : p2 : frontpoint : &frontface : backpoint : &backface]; if (frontface == -1) return; @@ -1791,13 +1789,11 @@ float sb_floor_dir, sb_floor_dist; if (sb_floor_dir == 1) { if (dist > 0 && dist < sb_floor_dist) sb_floor_dist = dist; - } else { - if (dist < 0 && dist > sb_floor_dist) + else if (dist < 0 && dist > sb_floor_dist) sb_floor_dist = dist; } } - /* =============================================================================== @@ -1806,18 +1802,17 @@ BRUSH SUBTRACTION =============================================================================== */ -vec3_t carvemin, carvemax; -int numcarvefaces; -face_t *carvefaces; -id carve_in, carve_out; +vec3_t carvemin, carvemax; +int numcarvefaces; +face_t *carvefaces; +id carve_in, carve_out; // returns the new brush formed after the addition of the given plane // nil is returned if it faced all of the original setbrush --addFace:(face_t *) f +- (id) addFace: (face_t *)f { if (numfaces == MAX_FACES) Sys_Error ("addFace: numfaces == MAX_FACES"); - faces[numfaces] = *f; faces[numfaces].texture = faces[0].texture; faces[numfaces].qtexture = NULL; @@ -1826,56 +1821,58 @@ id carve_in, carve_out; [self calcWindings]; // remove any degenerate faces - return[self removeIfInvalid]; + return [self removeIfInvalid]; } -- (void) clipByFace:(face_t *) fa - front:(id *)f - back:(id *) b +- (void) clipByFace: (face_t *)fa + front: (id *)f + back: (id *)b { - id front, back; - face_t fb; - vec3_t temp; + id front, back; + face_t fb; + vec3_t temp; fb = *fa; VectorCopy (fb.planepts[0], temp); VectorCopy (fb.planepts[2], fb.planepts[0]); VectorCopy (temp, fb.planepts[2]); - front =[self copy]; - back =[self copy]; + front = [self copy]; + back = [self copy]; - *b =[back addFace:fa]; - *f =[front addFace:&fb]; + *b = [back addFace: fa]; + *f = [front addFace: &fb]; } --carve +- (id) carve { - int i; - id front, back; + int i; + id front, back; #if 0 if ((i = NSMallocCheck ())) Sys_Error ("MallocCheck failure"); #endif -// check bboxes - for (i = 0; i < 3; i++) + // check bboxes + for (i = 0; i < 3; i++) { if (bmins[i] >= carvemax[i] || bmaxs[i] <= carvemin[i]) { - [carve_out addObject:self]; + [carve_out addObject: self]; return self; } -// carve by the planes - back = self; - for (i = 0; i < numcarvefaces; i++) { - [back clipByFace: &carvefaces[i] front: &front back:&back]; - if (front) - [carve_out addObject:front]; - if (!back) - return nil; // nothing completely inside } - [carve_in addObject:back]; + // carve by the planes + back = self; + for (i = 0; i < numcarvefaces; i++) { + [back clipByFace: &carvefaces[i] front: &front back: &back]; + if (front) + [carve_out addObject: front]; + if (!back) + return nil; // nothing completely inside + } + + [carve_in addObject: back]; return self; } @@ -1892,12 +1889,12 @@ setCarveVars carvefaces = faces; } --(int) getNumBrushFaces +- (int) getNumBrushFaces { return numfaces; } --(face_t *) getBrushFace:(int) which +- (face_t *) getBrushFace: (int)which { return &faces[which]; } diff --git a/tools/Forge/Bundles/MapEdit/Storage.h b/tools/Forge/Bundles/MapEdit/Storage.h index 9e9936c81..6fbd0e44c 100644 --- a/tools/Forge/Bundles/MapEdit/Storage.h +++ b/tools/Forge/Bundles/MapEdit/Storage.h @@ -10,7 +10,7 @@ modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -31,47 +31,50 @@ #include -@interface Storage:NSObject +@interface Storage: NSObject { - @public void *dataPtr; /* data of the Storage object */ - const char *description; /* Element description */ - NSUInteger numElements; /* Actual number of elements */ - NSUInteger maxElements; /* Total allocated elements */ - NSUInteger elementSize; /* Element size */ + @public + void *dataPtr; /* data of the Storage object */ + const char *description; /* Element description */ + NSUInteger numElements; /* Actual number of elements */ + NSUInteger maxElements; /* Total allocated elements */ + NSUInteger elementSize; /* Element size */ } /* Creating, freeing, initializing, and emptying */ --init; --initCount:(NSUInteger) numSlots elementSize:(NSUInteger) sizeInBytes - description:(const char *) elemDesc; --(void) dealloc; --empty; --copy; +- (id) init; +- (id) initCount: (NSUInteger)numSlots + elementSize: (NSUInteger)sizeInBytes + description: (const char *)elemDesc; +- (void) dealloc; +- (id) empty; +- (id) copy; /* Manipulating the elements */ --(BOOL) isEqual:anObject; --(const char *) description; --(NSUInteger) count; --(void *) elementAt:(NSUInteger) index; --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; +- (BOOL) isEqual: anObject; +- (const char *) description; +- (NSUInteger) count; +- (void *) elementAt: (NSUInteger)index; +- (id) replaceElementAt: (NSUInteger)index + with: (void *)anElement; +- (id) setNumSlots: (NSUInteger)numSlots; +- (id) setAvailableCapacity: (NSUInteger)numSlots; +- (id) addElement: (void *)anElement; +- (id) removeLastElement; +- (id) insertElement: (void *)anElement + at: (NSUInteger)index; +- (id) removeElementAt: (NSUInteger)index; /* old-style creation */ -+new; -+newCount:(NSUInteger) count elementSize:(NSUInteger) sizeInBytes - description:(const char *) descriptor; ++ (id) new; ++ (id) newCount: (NSUInteger)count + elementSize: (NSUInteger)sizeInBytes + description: (const char *)descriptor; @end @@ -79,5 +82,4 @@ typedef struct { @defs (Storage) } NXStorageId; - #endif /* __Storage_h_INCLUDE_GNU */ diff --git a/tools/Forge/Bundles/MapEdit/Storage.m b/tools/Forge/Bundles/MapEdit/Storage.m index b586f07f3..1a4c4cd29 100644 --- a/tools/Forge/Bundles/MapEdit/Storage.m +++ b/tools/Forge/Bundles/MapEdit/Storage.m @@ -1,24 +1,24 @@ /* 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 - Dept. of Mathematics and Computer Science, Aalborg U., Denmark + Written by: Kresten Krab Thorup + 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 - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. - 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. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* #include */ @@ -26,29 +26,29 @@ #include #include - -#define GNU_STORAGE_NTH(x,N) \ - ({ GNUStorageId* __s=(GNUStorageId*)(x); \ - (void*)(((char*)__s->dataPtr)+(__s->elementSize*(N))); }) +#define GNU_STORAGE_NTH(x, N) \ + ({GNUStorageId* __s = (GNUStorageId*) (x); \ + (void*) (((char*) __s->dataPtr) + (__s->elementSize * (N))); }) #define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N) -typedef struct { +typedef struct { @defs (Storage) } GNUStorageId; @implementation Storage -+initialize ++ (id) initialize { - if (self ==[Storage class]) - [self setVersion:0]; /* beta release */ + if (self == [Storage class]) + [self setVersion: 0]; /* beta release */ return self; } // INITIALIZING, FREEING; --initCount: (NSUInteger) numSlots elementSize: (NSUInteger) sizeInBytes description:(const char *) - elemDesc; +- (id) initCount: (NSUInteger)numSlots elementSize: (NSUInteger)sizeInBytes + description: (const char *) + elemDesc; { [super init]; numElements = numSlots; @@ -60,31 +60,29 @@ typedef struct { return self; } --init +- (id) init { - return[self initCount: 1 elementSize:sizeof (id) - description:@encode (id)]; + return [self initCount: 1 elementSize: sizeof (id) + description: @encode (id)]; } - --(void) dealloc +- (void) dealloc { if (dataPtr) free (dataPtr); [super dealloc]; } --(const char *) description +- (const char *) description { return description; } - // COPYING; --copy +- (id) copy { - Storage *c =[super copy]; + Storage *c = [super copy]; c->dataPtr = (void *) objc_malloc (maxElements * elementSize); memcpy (c->dataPtr, dataPtr, numElements * elementSize); @@ -93,12 +91,12 @@ typedef struct { // COMPARING TWO STORAGES; --(BOOL) isEqual:anObject +- (BOOL) isEqual: anObject { - if ([anObject isKindOfClass:[Storage class]] - &&[anObject count] ==[self count] - && !memcmp (((GNUStorageId *) anObject)->dataPtr, - dataPtr, numElements * elementSize)) + if ([anObject isKindOfClass: [Storage class]] + && [anObject count] == [self count] + && !memcmp (((GNUStorageId *) anObject)->dataPtr, + dataPtr, numElements * elementSize)) return YES; else return NO; @@ -112,7 +110,8 @@ _makeRoomForAnotherIfNecessary (Storage * self) if (self->numElements == self->maxElements) { self->maxElements *= 2; 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)) { self->maxElements /= 2; 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) { maxElements = numSlots; @@ -135,13 +135,13 @@ _shrinkIfDesired (Storage * self) return self; } --setNumSlots:(NSUInteger) numSlots +- (id) setNumSlots: (NSUInteger)numSlots { if (numSlots > numElements) { maxElements = numSlots; dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize); bzero (STORAGE_NTH (numElements), - (maxElements - numElements) * elementSize); + (maxElements - numElements) * elementSize); } else if (numSlots < numElements) { numElements = numSlots; _shrinkIfDesired (self); @@ -151,20 +151,20 @@ _shrinkIfDesired (Storage * self) /* 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; } --(void *) elementAt:(NSUInteger) index +- (void *) elementAt: (NSUInteger)index { CHECK_INDEX (index); return STORAGE_NTH (index); } --addElement:(void *) anElement +- (id) addElement: (void *)anElement { _makeRoomForAnotherIfNecessary (self); memcpy (STORAGE_NTH (numElements), anElement, elementSize); @@ -172,43 +172,45 @@ _shrinkIfDesired (Storage * self) return self; } --insertElement:(void *) -anElement at:(NSUInteger) index +- (id) insertElement: (void *) + anElement at: (NSUInteger)index { - NSUInteger i; + NSUInteger i; CHECK_INDEX (index); _makeRoomForAnotherIfNecessary (self); #ifndef STABLE_MEMCPY for (i = numElements; i >= index; i--) memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize); + #else memcpy (STORAGE_NTH (index + 1), - STORAGE_NTH (index), elementSize * (numElements - index)); + STORAGE_NTH (index), elementSize * (numElements - index)); #endif memcpy (STORAGE_NTH (i), anElement, elementSize); numElements++; return self; } --removeElementAt:(NSUInteger) index +- (id) removeElementAt: (NSUInteger)index { - NSUInteger i; + NSUInteger i; CHECK_INDEX (index); numElements--; #ifndef STABLE_MEMCPY for (i = index; i < numElements; i++) memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize); + #else memcpy (STORAGE_NTH (index), - STORAGE_NTH (index + 1), elementSize * (numElements - index - 1)); + STORAGE_NTH (index + 1), elementSize * (numElements - index - 1)); #endif _shrinkIfDesired (self); return self; } --removeLastElement +- (id) removeLastElement { if (numElements) { numElements--; @@ -217,8 +219,8 @@ anElement at:(NSUInteger) index return self; } --replaceElementAt:(NSUInteger) -index with:(void *) newElement +- (id) replaceElementAt: (NSUInteger) + index with: (void *)newElement { CHECK_INDEX (index); memcpy (STORAGE_NTH (index), newElement, elementSize); @@ -227,7 +229,7 @@ index with:(void *) newElement /* Emptying the Storage */ --empty +- (id) empty { numElements = 0; maxElements = 1; @@ -235,16 +237,17 @@ index with:(void *) newElement return self; } -+new ++ (id) new { - return[[self alloc] init]; + return [[self alloc] init]; } -+newCount:(NSUInteger) -count elementSize:(NSUInteger) sizeInBytes - description:(const char *) descriptor ++ (id) newCount: (NSUInteger) + count elementSize: (NSUInteger)sizeInBytes + description: (const char *)descriptor { - return[[self alloc] initCount: count elementSize: sizeInBytes description:descriptor]; + return [[self alloc] initCount: count elementSize: sizeInBytes description: + descriptor]; } @end diff --git a/tools/Forge/Bundles/MapEdit/TexturePalette.h b/tools/Forge/Bundles/MapEdit/TexturePalette.h index 3f49cfe6d..18b37103c 100644 --- a/tools/Forge/Bundles/MapEdit/TexturePalette.h +++ b/tools/Forge/Bundles/MapEdit/TexturePalette.h @@ -5,110 +5,109 @@ #include "QF/qtypes.h" -typedef union { +typedef union { byte chan[4]; unsigned p; } pixel32_t; - -typedef struct { - char texture[16]; - float rotate; - float shift[2]; - float scale[2]; +typedef struct { + char texture[16]; + float rotate; + float shift[2]; + float scale[2]; } texturedef_t; +typedef struct { + char name[16]; -typedef struct { - char name[16]; - - int width; - int height; - NSBitmapImageRep *rep; - void *data; - pixel32_t flatcolor; + int width; + int height; + NSBitmapImageRep *rep; + void *data; + pixel32_t flatcolor; } qtexture_t; -#define MAX_TEXTURES 1024 +#define MAX_TEXTURES 1024 -extern int tex_count; -extern qtexture_t qtextures[MAX_TEXTURES]; +extern int tex_count; +extern qtexture_t qtextures[MAX_TEXTURES]; qtexture_t *TEX_ForName (const char *name); -typedef struct { - NSImageRep *image; +typedef struct { + NSImageRep *image; NSRect r; - char *name; + char *name; int index; - int display; // flag (on/off) + int display; // flag (on/off) } texpal_t; -#define TEX_INDENT 10 -#define TEX_SPACING 16 +#define TEX_INDENT 10 +#define TEX_SPACING 16 -extern id texturepalette_i; +extern id texturepalette_i; -@interface TexturePalette:NSObject +@interface TexturePalette: NSObject { - char currentwad[1024]; - id textureList_i; - id textureView_i; - id searchField_i; - id sizeField_i; + char currentwad[1024]; + id textureList_i; + id textureView_i; + id searchField_i; + id sizeField_i; - id field_Xshift_i; - id field_Yshift_i; - id field_Xscale_i; - id field_Yscale_i; - id field_Rotate_i; + id field_Xshift_i; + id field_Yshift_i; + id field_Xscale_i; + id field_Yscale_i; + id field_Rotate_i; - int viewWidth; - int viewHeight; - int selectedTexture; + int viewWidth; + int viewHeight; + int selectedTexture; } --(const char *) currentWad; --initPaletteFromWadfile:(const char *) wf; --computeTextureViewSize; --alphabetize; --getList; --(int) getSelectedTexture; --setSelectedTexture:(int) which; --(int) getSelectedTexIndex; +- (const char *) currentWad; +- (id) initPaletteFromWadfile: (const char *)wf; +- (id) computeTextureViewSize; +- (id) alphabetize; +- (id) getList; +- (int) getSelectedTexture; +- (id) setSelectedTexture: (int)which; +- (int) getSelectedTexIndex; // Called externally --(const char *) getSelTextureName; --setTextureByName:(const char *) name; +- (const char *) getSelTextureName; +- (id) setTextureByName: (const char *)name; // New methods to replace the 2 above ones --setTextureDef:(texturedef_t *) td; --getTextureDef:(texturedef_t *) td; +- (id) setTextureDef: (texturedef_t *)td; +- (id) getTextureDef: (texturedef_t *)td; // Action methods --searchForTexture:sender; +- (id) searchForTexture: sender; --clearTexinfo:sender; +- (id) clearTexinfo: sender; --incXShift:sender; --decXShift:sender; +- (id) incXShift: sender; +- (id) decXShift: sender; --incYShift:sender; --decYShift:sender; +- (id) incYShift: sender; +- (id) decYShift: sender; --incRotate:sender; --decRotate:sender; +- (id) incRotate: sender; +- (id) decRotate: sender; --incXScale:sender; --decXScale:sender; +- (id) incXScale: sender; +- (id) decXScale: sender; --incYScale:sender; --decYScale:sender; +- (id) incYScale: sender; +- (id) decYScale: sender; --texturedefChanged:sender; --onlyShowMapTextures:sender; --(int) searchForTextureInPalette:(const char *) texture; --setDisplayFlag:(int) index to:(int) value; +- (id) texturedefChanged: sender; +- (id) onlyShowMapTextures: sender; +- (int) searchForTextureInPalette: (const char *)texture; +- (id) setDisplayFlag: (int)index + to: (int)value; @end #endif // TexturePalette_h diff --git a/tools/Forge/Bundles/MapEdit/TexturePalette.m b/tools/Forge/Bundles/MapEdit/TexturePalette.m index a12cd8615..08ca9df47 100644 --- a/tools/Forge/Bundles/MapEdit/TexturePalette.m +++ b/tools/Forge/Bundles/MapEdit/TexturePalette.m @@ -15,63 +15,61 @@ #include "Storage.h" -id texturepalette_i; - +id texturepalette_i; int tex_count; qtexture_t qtextures[MAX_TEXTURES]; -typedef struct { +typedef struct { char name[16]; unsigned width, height; - unsigned offsets[4]; // four mip maps stored + unsigned offsets[4]; // four mip maps stored } miptex_t; -unsigned tex_palette[256]; +unsigned tex_palette[256]; -unsigned badtex_d[] = { +unsigned badtex_d[] = { 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, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 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, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 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, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 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, - 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, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 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, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 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, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 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, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -qtexture_t badtex = - { "notexture", 16, 16, NULL, badtex_d, {{0, 0, 255, 255}} }; +qtexture_t badtex = {"notexture", 16, 16, NULL, badtex_d, {{0, 0, 255, 255}}}; void CleanupName (const char *in, char *out) { - int i; + int i; for (i = 0; i < 16; i++) { if (!in[i]) @@ -90,9 +88,9 @@ TEX_InitPalette void TEX_InitPalette (wad_t *wad, lumpinfo_t *pallump) { - byte *pal, *opal; - int r, g, b, v; - int i; + byte *pal, *opal; + int r, g, b, v; + int i; opal = pal = malloc (pallump->size); Qseek (wad->handle, pallump->filepos, SEEK_SET); @@ -112,7 +110,6 @@ TEX_InitPalette (wad_t *wad, lumpinfo_t *pallump) free (opal); } - /* ================= TEX_ImageFromMiptex @@ -121,13 +118,13 @@ TEX_ImageFromMiptex void TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump) { - miptex_t *qtex; - NSBitmapImageRep *bm; - byte *source; - unsigned *dest; - int width, height, i, count; - qtexture_t *q; - int tr, tg, tb; + miptex_t *qtex; + NSBitmapImageRep *bm; + byte *source; + unsigned *dest; + int width, height, i, count; + qtexture_t *q; + int tr, tg, tb; qtex = malloc (qtexlump->size); Qseek (wad->handle, qtexlump->filepos, SEEK_SET); @@ -136,10 +133,19 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump) width = LittleLong (qtex->width); height = LittleLong (qtex->height); - bm =[[NSBitmapImageRep alloc] - initWithBitmapDataPlanes: NULL pixelsWide: width pixelsHigh: height bitsPerSample: 8 samplesPerPixel: 3 hasAlpha: NO isPlanar: NO colorSpaceName: NSCalibratedRGBColorSpace bytesPerRow: width * 4 bitsPerPixel:32]; + bm = [[NSBitmapImageRep alloc] + 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; 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++) { dest[i] = tex_palette[source[i]]; - tr += ((pixel32_t *) & dest[i])->chan[0]; - tg += ((pixel32_t *) & dest[i])->chan[1]; - tb += ((pixel32_t *) & dest[i])->chan[2]; + tr += ((pixel32_t *) &dest[i])->chan[0]; + tg += ((pixel32_t *) &dest[i])->chan[1]; + tb += ((pixel32_t *) &dest[i])->chan[2]; } q->flatcolor.chan[0] = tr / count; @@ -167,7 +173,7 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump) free (qtex); } -//============================================================================= +// ============================================================================= /* ================= @@ -178,10 +184,10 @@ int TEX_InitFromWad (const char *path) { int i; - const char *newpath; + const char *newpath; float start, stop; - wad_t *wad; - lumpinfo_t *lumpinfo; + wad_t *wad; + lumpinfo_t *lumpinfo; start = Sys_DoubleTime (); @@ -191,25 +197,26 @@ TEX_InitFromWad (const char *path) // free any textures for (i = 0; i < tex_count; i++) [qtextures[i].rep release]; + tex_count = 0; - // try to use the cached wadfile + // try to use the cached wadfile Sys_Printf ("TEX_InitFromWad %s\n", newpath); wad = wad_open (newpath); if (!wad) { NSRunAlertPanel (@"Wad Error!", - [NSString stringWithFormat:@"Failed to open '%s'", - newpath], - @"OK", nil, nil); + [NSString stringWithFormat: @"Failed to open '%s'", + newpath], + @"OK", nil, + nil); return 0; } 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); - } TEX_InitPalette (wad, lumpinfo); @@ -217,7 +224,7 @@ TEX_InitFromWad (const char *path) for (i = 1; i < wad->numlumps; i++, lumpinfo++) { if (lumpinfo->type != TYP_MIPTEX) 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); } @@ -239,7 +246,7 @@ TEX_ForName (const char *name) { char newname[16]; int i; - qtexture_t *q; + qtexture_t *q; CleanupName (name, newname); @@ -251,12 +258,10 @@ TEX_ForName (const char *name) return &badtex; } - - -//=========================================================================== +// =========================================================================== @implementation TexturePalette --init +- (id) init { [super init]; texturepalette_i = self; @@ -264,25 +269,24 @@ TEX_ForName (const char *name) return self; } --(void) display +- (void) display { [[textureView_i superview] display]; } - --(const char *) currentWad +- (const char *) currentWad { return currentwad; } --initPaletteFromWadfile:(const char *) wf +- (id) initPaletteFromWadfile: (const char *)wf { int i; texpal_t t; - qtexture_t *q; + qtexture_t *q; strcpy (currentwad, wf); - [map_i makeGlobalPerform:@selector (flushTextures)]; + [map_i makeGlobalPerform: @selector (flushTextures)]; selectedTexture = -1; // Init textures WAD @@ -290,67 +294,65 @@ TEX_ForName (const char *name) return self; // Create STORAGE - if (textureList_i) + if (textureList_i) { [textureList_i empty]; - else - textureList_i = [[Storage alloc] initCount: 0 - elementSize: sizeof (texpal_t) - description: NULL]; - + } else { + textureList_i = [[Storage alloc] initCount: 0 + elementSize: sizeof (texpal_t) + description: NULL]; + } // Init STORAGE for (i = 0, q = qtextures; i < tex_count; i++, q++) { t.image = q->rep; - t.r.size.width =[t.image pixelsWide]; + t.r.size.width = [t.image pixelsWide]; if (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.index = i; t.display = 1; - [textureList_i addElement:&t]; + [textureList_i addElement: &t]; } // Calculate size of TextureView [self alphabetize]; [self computeTextureViewSize]; - [textureView_i setParent:self]; - [self setSelectedTexture:0]; + [textureView_i setParent: self]; + [self setSelectedTexture: 0]; return self; } - - // Return texture STORAGE list --getList +- (id) getList { return textureList_i; } // Alphabetize texture list - reverse order! --alphabetize +- (id) alphabetize { int i; int max; - texpal_t *t1p; - texpal_t *t2p; + texpal_t *t1p; + texpal_t *t2p; texpal_t t1; texpal_t t2; int found; - max =[textureList_i count]; + max = [textureList_i count]; found = 1; while (found) { found = 0; for (i = 0; i < max - 1; i++) { - t1p =[textureList_i elementAt:i]; - t2p =[textureList_i elementAt:i + 1]; + t1p = [textureList_i elementAt: i]; + t2p = [textureList_i elementAt: i + 1]; if (strcmp (t1p->name, t2p->name) < 0) { t1 = *t1p; t2 = *t2p; - [textureList_i replaceElementAt: i with:&t2]; - [textureList_i replaceElementAt: i + 1 with:&t1]; + [textureList_i replaceElementAt: i with: &t2]; + [textureList_i replaceElementAt: i + 1 with: &t1]; found = 1; } } @@ -358,12 +360,12 @@ TEX_ForName (const char *name) return self; } --computeTextureViewSize +- (id) computeTextureViewSize { int i; int max; int x; - texpal_t *t; + texpal_t *t; int y; id view; NSRect b; @@ -371,17 +373,17 @@ TEX_ForName (const char *name) int maxheight; NSPoint pt; - max =[textureList_i count]; + max = [textureList_i count]; y = 0; maxheight = 0; x = TEX_INDENT; - view =[textureView_i superview]; - b =[view bounds]; + view = [textureView_i superview]; + b = [view bounds]; maxwidth = b.size.width; 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) { x = TEX_INDENT; y += maxheight; @@ -398,42 +400,43 @@ TEX_ForName (const char *name) viewWidth = maxwidth; viewHeight = y + TEX_SPACING; - [textureView_i setFrameSize:NSMakeSize (viewWidth, viewHeight)]; + [textureView_i setFrameSize: NSMakeSize (viewWidth, viewHeight)]; pt.x = pt.y = 0; - [textureView_i scrollPoint:pt]; + [textureView_i scrollPoint: pt]; return self; } --windowResized +- (id) windowResized { [self computeTextureViewSize]; return self; } --texturedefChanged:sender +- (id) texturedefChanged: sender { if ([map_i numSelected]) { if ([[map_i currentEntity] modifiable]) { - [map_i makeSelectedPerform:@selector + [map_i makeSelectedPerform: @selector (takeCurrentTexture)]; [quakeed_i updateAll]; - } else + } else { Sys_Printf ("can't modify spawned entities\n"); + } } - [quakeed_i makeFirstResponder:quakeed_i]; + [quakeed_i makeFirstResponder: quakeed_i]; return self; } --clearTexinfo:sender +- (id) clearTexinfo: sender { - [field_Xshift_i setFloatValue:0]; - [field_Yshift_i setFloatValue:0]; - [field_Xscale_i setFloatValue:1]; - [field_Yscale_i setFloatValue:1]; - [field_Rotate_i setFloatValue:0]; + [field_Xshift_i setFloatValue: 0]; + [field_Yshift_i setFloatValue: 0]; + [field_Xscale_i setFloatValue: 1]; + [field_Yscale_i setFloatValue: 1]; + [field_Rotate_i setFloatValue: 0]; - [self texturedefChanged:self]; + [self texturedefChanged: self]; return self; } @@ -441,32 +444,32 @@ TEX_ForName (const char *name) // // Set the selected texture // --setSelectedTexture:(int) which +- (id) setSelectedTexture: (int)which { - texpal_t *t; + texpal_t *t; NSRect r; // wipe the fields - [self clearTexinfo:self]; + [self clearTexinfo: self]; if (which != selectedTexture) { [textureView_i deselect]; selectedTexture = which; - t =[textureList_i elementAt:which]; + t = [textureList_i elementAt: which]; r = t->r; r.size.width += TEX_INDENT * 2; r.size.height += TEX_INDENT * 2; r.origin.x -= TEX_INDENT; r.origin.y -= TEX_INDENT; - [textureView_i scrollRectToVisible:r]; + [textureView_i scrollRectToVisible: r]; [textureView_i display]; [sizeField_i setStringValue: - [NSString stringWithFormat:@"%d x %d", - (int) t->r.size.width, - (int) t->r.size.height - TEX_SPACING]]; + [NSString stringWithFormat: @"%d x %d", + (int) t->r.size.width, + (int) t->r.size.height - TEX_SPACING]]; } - [self texturedefChanged:self]; + [self texturedefChanged: self]; return self; } @@ -474,7 +477,7 @@ TEX_ForName (const char *name) // // Return the selected texture index // --(int) getSelectedTexture +- (int) getSelectedTexture { return selectedTexture; } @@ -483,46 +486,46 @@ TEX_ForName (const char *name) // Return the original tex_ index of the selected texture // so the texture info can be indexed from tex_images, etc. // --(int) getSelectedTexIndex +- (int) getSelectedTexIndex { - texpal_t *t; + texpal_t *t; if (selectedTexture == -1) return -1; - t =[textureList_i elementAt:selectedTexture]; + t = [textureList_i elementAt: selectedTexture]; return t->index; } // // Return the name of the selected texture // --(const char *) getSelTextureName +- (const char *) getSelTextureName { - texpal_t *t; + texpal_t *t; if (selectedTexture == -1) return NULL; - t =[textureList_i elementAt:selectedTexture]; + t = [textureList_i elementAt: selectedTexture]; return t->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 max; - char *nm = strdup (name); + char *nm = strdup (name); - max =[textureList_i count]; - CleanupName(nm,nm); + max = [textureList_i count]; + CleanupName (nm, nm); for (i = 0; i < max; i++) { - t =[textureList_i elementAt:i]; + t = [textureList_i elementAt: i]; if (!strcmp (t->name, nm)) { free (nm); - [self setSelectedTexture:i]; + [self setSelectedTexture: i]; return self; } } @@ -530,24 +533,23 @@ TEX_ForName (const char *name) return self; } -//=================================================== +// =================================================== // // Action methods // -//=================================================== - +// =================================================== // // Search for texture named in searchField // --searchForTexture:sender +- (id) searchForTexture: sender { - int i; - int max; - int len; - NSMutableString *strname; - const char *name; - texpal_t *t; + int i; + int max; + int len; + NSMutableString *strname; + const char *name; + texpal_t *t; if (selectedTexture == -1) return self; @@ -560,43 +562,43 @@ TEX_ForName (const char *name) len = strlen (name); for (i = selectedTexture - 1; i >= 0; i--) { - t =[textureList_i elementAt:i]; + t = [textureList_i elementAt: i]; if (!strncmp (t->name, name, len)) { - [self setTextureByName:t->name]; - [sender selectText:sender]; - [self texturedefChanged:self]; + [self setTextureByName: t->name]; + [sender selectText: sender]; + [self texturedefChanged: self]; return self; } } for (i = max - 1; i >= selectedTexture; i--) { - t =[textureList_i elementAt:i]; + t = [textureList_i elementAt: i]; if (!strncmp (t->name, name, len)) { - [self setTextureByName:t->name]; - [sender selectText:sender]; - [self texturedefChanged:self]; + [self setTextureByName: t->name]; + [sender selectText: sender]; + [self texturedefChanged: self]; return self; } } - [self texturedefChanged:self]; + [self texturedefChanged: self]; return self; } // // 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_Yshift_i setFloatValue:td->shift[1]]; - [field_Xscale_i setFloatValue:td->scale[0]]; - [field_Yscale_i setFloatValue:td->scale[1]]; - [field_Rotate_i setFloatValue:td->rotate]; + [field_Xshift_i setFloatValue: td->shift[0]]; + [field_Yshift_i setFloatValue: td->shift[1]]; + [field_Xscale_i setFloatValue: td->scale[0]]; + [field_Yscale_i setFloatValue: td->scale[1]]; + [field_Rotate_i setFloatValue: td->rotate]; - [self texturedefChanged:self]; + [self texturedefChanged: self]; return self; } @@ -604,7 +606,7 @@ TEX_ForName (const char *name) // // Return the current texture def to passed * // --getTextureDef:(texturedef_t *) td +- (id) getTextureDef: (texturedef_t *)td { if (selectedTexture == -1) { memset (td, 0, sizeof (*td)); @@ -612,32 +614,32 @@ TEX_ForName (const char *name) return self; } - strncpy (td->texture,[self getSelTextureName], 16); + strncpy (td->texture, [self getSelTextureName], 16); - td->shift[0] =[field_Xshift_i floatValue]; - td->shift[1] =[field_Yshift_i floatValue]; - td->scale[0] =[field_Xscale_i floatValue]; - td->scale[1] =[field_Yscale_i floatValue]; - td->rotate =[field_Rotate_i floatValue]; + td->shift[0] = [field_Xshift_i floatValue]; + td->shift[1] = [field_Yshift_i floatValue]; + td->scale[0] = [field_Xscale_i floatValue]; + td->scale[1] = [field_Yscale_i floatValue]; + td->rotate = [field_Rotate_i floatValue]; return self; } -//============================================================================ +// ============================================================================ // // Change value in a field // --changeField:(id) -field by:(int) amount +- (id) changeField: (id) + field by: (int)amount { - int val; + int val; - val =[field intValue]; + val = [field intValue]; val += amount; - [field setIntValue:val]; + [field setIntValue: val]; - [self texturedefChanged:self]; + [self texturedefChanged: self]; return self; } @@ -645,103 +647,101 @@ field by:(int) amount // // 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; } --decXShift:sender +- (id) decXShift: sender { - [self changeField: field_Xshift_i by:-8]; + [self changeField: field_Xshift_i by: -8]; return self; } // // 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; } --decYShift:sender +- (id) decYShift: sender { - [self changeField: field_Yshift_i by:-8]; + [self changeField: field_Yshift_i by: -8]; return self; } // // 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; } --decRotate:sender +- (id) decRotate: sender { - [self changeField: field_Rotate_i by:-90]; + [self changeField: field_Rotate_i by: -90]; return self; } // // Inc/Dec the Xscale field // --incXScale:sender +- (id) incXScale: sender { - [field_Xscale_i setIntValue:1]; - [self texturedefChanged:self]; + [field_Xscale_i setIntValue: 1]; + [self texturedefChanged: self]; return self; } --decXScale:sender +- (id) decXScale: sender { - [field_Xscale_i setIntValue:-1]; - [self texturedefChanged:self]; + [field_Xscale_i setIntValue: -1]; + [self texturedefChanged: self]; return self; } // // Inc/Dec the Yscale field // --incYScale:sender +- (id) incYScale: sender { - [field_Yscale_i setIntValue:1]; - [self texturedefChanged:self]; + [field_Yscale_i setIntValue: 1]; + [self texturedefChanged: self]; return self; } --decYScale:sender +- (id) decYScale: sender { - [field_Yscale_i setIntValue:-1]; - [self texturedefChanged:self]; + [field_Yscale_i setIntValue: -1]; + [self texturedefChanged: self]; return self; } - -//============================================================================ - +// ============================================================================ // // Search for texture in entire palette // Return index of texturedef, or -1 if unsuccessful // --(int) searchForTextureInPalette:(const char *) texture +- (int) searchForTextureInPalette: (const char *)texture { int i; int max; - texpal_t *t; + texpal_t *t; if (selectedTexture == -1) return -1; - max =[textureList_i count]; + max = [textureList_i count]; for (i = 0; i < max; i++) { - t =[textureList_i elementAt:i]; + t = [textureList_i elementAt: i]; if (!strcmp (t->name, texture)) return i; } @@ -751,42 +751,42 @@ field by:(int) amount // // Scan thru map & display only textures that are in map // --onlyShowMapTextures:sender +- (id) onlyShowMapTextures: sender { int max; int i; int j; id brushes; - SetBrush *b; + SetBrush *b; int numfaces; - face_t *f; + face_t *f; int index; // Turn 'em off if ([sender intValue]) { - max =[textureList_i count]; + max = [textureList_i count]; for (i = 0; i < max; i++) - [self setDisplayFlag: i to:0]; + [self setDisplayFlag: i to: 0]; - brushes =[map_i objectAtIndex:0]; - max =[brushes count]; + brushes = [map_i objectAtIndex: 0]; + max = [brushes count]; for (i = 0; i < max; i++) { - b = (SetBrush *)[brushes objectAtIndex:i]; - numfaces =[b getNumBrushFaces]; + b = (SetBrush *) [brushes objectAtIndex: i]; + numfaces = [b getNumBrushFaces]; for (j = 0; j < numfaces; j++) { - f =[b getBrushFace:j]; - index =[self searchForTextureInPalette:f->texture. - texture]; + f = [b getBrushFace: j]; + index = [self searchForTextureInPalette: f->texture. + texture]; if (index >= 0) - [self setDisplayFlag: index to:1]; + [self setDisplayFlag: index to: 1]; } } } // Turn 'em on else { - max =[textureList_i count]; + max = [textureList_i count]; for (i = 0; i < max; i++) - [self setDisplayFlag: i to:1]; + [self setDisplayFlag: i to: 1]; } [textureView_i display]; @@ -794,12 +794,12 @@ field by:(int) amount return self; } --setDisplayFlag:(int) -index to:(int) value +- (id) setDisplayFlag: (int) + index to: (int)value { - texpal_t *tp; + texpal_t *tp; - tp =[textureList_i elementAt:index]; + tp = [textureList_i elementAt: index]; tp->display = value; return self; }; diff --git a/tools/Forge/Bundles/MapEdit/TextureView.h b/tools/Forge/Bundles/MapEdit/TextureView.h index 46bbc0389..2047c6aaf 100644 --- a/tools/Forge/Bundles/MapEdit/TextureView.h +++ b/tools/Forge/Bundles/MapEdit/TextureView.h @@ -3,14 +3,14 @@ #include -@interface TextureView:NSView +@interface TextureView: NSView { - id parent_i; - int deselectIndex; + id parent_i; + int deselectIndex; } --setParent:(id) from; --deselect; +- (id) setParent: (id)from; +- (id) deselect; @end #endif // TextureView_h diff --git a/tools/Forge/Bundles/MapEdit/TextureView.m b/tools/Forge/Bundles/MapEdit/TextureView.m index 03249ef40..4a4a1e00c 100644 --- a/tools/Forge/Bundles/MapEdit/TextureView.m +++ b/tools/Forge/Bundles/MapEdit/TextureView.m @@ -14,48 +14,47 @@ NOTE: I am specifically not using cached image reps, because the data is also ne @implementation TextureView --init +- (id) init { deselectIndex = -1; return self; } --setParent:(id) from +- (id) setParent: (id)from { parent_i = from; return self; } --(BOOL) acceptsFirstMouse +- (BOOL) acceptsFirstMouse { return YES; } --drawRect: (NSRect) rects +- (id) drawRect: (NSRect)rects { int i; int max; id list_i; - texpal_t *t; + texpal_t *t; int x; int y; NSPoint p; NSRect r; int selected; - NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; + NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; - selected =[parent_i getSelectedTexture]; - list_i =[parent_i getList]; + selected = [parent_i getSelectedTexture]; + list_i = [parent_i getList]; [[NSFont systemFontOfSize: FONTSIZE] set]; [[NSColor lightGrayColor] set]; NSRectFill (rects); - if (!list_i) // WADfile didn't init + if (!list_i) // WADfile didn't init return self; - if (deselectIndex != -1) { - t =[list_i elementAt:deselectIndex]; + t = [list_i elementAt: deselectIndex]; r = t->r; r.origin.x -= 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; y = t->r.origin.y + 7; [[NSString stringWithCString: t->name] - drawAtPoint: NSMakePoint (x, y) withAttributes: attribs]; + drawAtPoint: NSMakePoint (x, y) withAttributes: attribs]; deselectIndex = -1; } - max =[list_i count]; + max = [list_i count]; [[NSColor blackColor] set]; for (i = 0; i < max; i++) { - t =[list_i elementAt:i]; + t = [list_i elementAt: i]; r = t->r; r.origin.x -= TEX_INDENT / 2; 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]; NSRectFill (r); [[NSColor redColor] set]; - NSFrameRect(r); + NSFrameRect (r); [[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; y = t->r.origin.y + 7; [[NSString stringWithCString: t->name] - drawAtPoint: NSMakePoint (x, y) withAttributes: attribs]; + drawAtPoint: NSMakePoint (x, y) withAttributes: attribs]; } } return self; } --deselect +- (id) deselect { - deselectIndex =[parent_i getSelectedTexture]; + deselectIndex = [parent_i getSelectedTexture]; return self; } --mouseDown:(NSEvent *) theEvent +- (id) mouseDown: (NSEvent *)theEvent { NSPoint loc; int i; int max; // int oldwindowmask; - texpal_t *t; + texpal_t *t; id list; NSRect r; // oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask]; - loc =[theEvent locationInWindow]; - [self convertPoint: loc fromView:NULL]; + loc = [theEvent locationInWindow]; + [self convertPoint: loc fromView: NULL]; - list =[parent_i getList]; - max =[list count]; + list = [parent_i getList]; + max = [list count]; for (i = 0; i < max; i++) { - t =[list elementAt:i]; + t = [list elementAt: i]; r = t->r; if (NSPointInRect (loc, r) == YES) { [self deselect]; - [parent_i setSelectedTexture:i]; + [parent_i setSelectedTexture: i]; break; } } diff --git a/tools/Forge/Bundles/MapEdit/Things.h b/tools/Forge/Bundles/MapEdit/Things.h index 7de487014..ec3cbb06a 100644 --- a/tools/Forge/Bundles/MapEdit/Things.h +++ b/tools/Forge/Bundles/MapEdit/Things.h @@ -5,43 +5,42 @@ #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_comment_i; // scrolling text window + id entity_browser_i; // browser + 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 valueInput_i; - id flags_i; + id keyInput_i; + id valueInput_i; + id flags_i; } --initEntities; +- (id) initEntities; --newCurrentEntity; --setSelectedKey:(epair_t *) ep; +- (id) newCurrentEntity; +- (id) setSelectedKey: (epair_t *)ep; --clearInputs; --(const char *) spawnName; +- (id) clearInputs; +- (const char *) spawnName; // UI targets --reloadEntityClasses:sender; --selectEntity:sender; --doubleClickEntity:sender; +- (id) reloadEntityClasses: sender; +- (id) selectEntity: sender; +- (id) doubleClickEntity: sender; // Action methods --addPair:sender; --delPair:sender; --setAngle:sender; --setFlags:sender; - +- (id) addPair: sender; +- (id) delPair: sender; +- (id) setAngle: sender; +- (id) setFlags: sender; @end #endif // Things_h diff --git a/tools/Forge/Bundles/MapEdit/Things.m b/tools/Forge/Bundles/MapEdit/Things.m index 5d944e7ba..4d3ff512b 100644 --- a/tools/Forge/Bundles/MapEdit/Things.m +++ b/tools/Forge/Bundles/MapEdit/Things.m @@ -8,11 +8,11 @@ #include "KeypairView.h" #include "Project.h" -id things_i; +id things_i; @implementation Things --init +- (id) init { [super init]; @@ -22,9 +22,9 @@ id things_i; 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 deselectAllCells]; } @@ -32,143 +32,141 @@ id things_i; // // Load the TEXT object with the entity comment // --loadEntityComment:(id) obj +- (id) loadEntityComment: (id)obj { - [entity_comment_i selectAll:self]; - [entity_comment_i replaceCharactersInRange: [entity_comment_i selectedRange] withString: [NSString stringWithCString:[obj - comments]]]; + [entity_comment_i selectAll: self]; + [entity_comment_i + replaceCharactersInRange: [entity_comment_i selectedRange] + withString: [NSString stringWithCString: [obj comments]]]; return self; } - --initEntities +- (id) 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 matrixInColumn: 0] selectCellAtRow: lastSelected column:0]; + [[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0]; [entity_browser_i setDoubleAction: @selector (doubleClickEntity:)]; return self; } --selectEntity:sender +- (id) selectEntity: sender { - id matr; + id matr; - matr =[sender matrixInColumn:0]; - lastSelected =[matr selectedRow]; - [self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]]; - [quakeed_i makeFirstResponder:quakeed_i]; + matr = [sender matrixInColumn: 0]; + lastSelected = [matr selectedRow]; + [self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]]; + [quakeed_i makeFirstResponder: quakeed_i]; return self; } --doubleClickEntity:sender +- (id) doubleClickEntity: sender { - [map_i makeEntity:sender]; - [quakeed_i makeFirstResponder:quakeed_i]; + [map_i makeEntity: sender]; + [quakeed_i makeFirstResponder: quakeed_i]; 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! // --reloadEntityClasses:sender +- (id) reloadEntityClasses: sender { - EntityClass *ent; - const char *path; + EntityClass *ent; + const char *path; path = [[prog_path_i stringValue] cString]; if (!path || !path[0]) { - path =[project_i getProgDirectory]; - [prog_path_i setStringValue: [NSString stringWithCString:path]]; + path = [project_i getProgDirectory]; + [prog_path_i setStringValue: [NSString stringWithCString: path]]; } // Free all entity info in memory... [entity_classes_i removeAllObjects]; [entity_classes_i release]; // Now, RELOAD! - [[EntityClassList alloc] initForSourceDirectory:path]; + [[EntityClassList alloc] initForSourceDirectory: path]; lastSelected = 0; - ent =[entity_classes_i objectAtIndex:lastSelected]; - [self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]]; + ent = [entity_classes_i objectAtIndex: lastSelected]; + [self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]]; [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; } - --selectClass:(const char *) class +- (id) selectClass: (const char *)class { - id classent; + id classent; - classent =[entity_classes_i classForName:class]; + classent = [entity_classes_i classForName: class]; if (!classent) return self; - lastSelected =[entity_classes_i indexOfObject:classent]; + lastSelected = [entity_classes_i indexOfObject: classent]; if (lastSelected < 0) lastSelected = 0; - - [self loadEntityComment:classent]; - [[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0]; - [[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected column:0]; + [self loadEntityComment: classent]; + [[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0]; + [[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected + column: 0]; return self; } - --newCurrentEntity +- (id) newCurrentEntity { id ent, classent, cell; - const char *classname; + const char *classname; int r, c; - const char *flagname; + const char *flagname; int flags; - ent =[map_i currentEntity]; - classname =[ent valueForQKey:"classname"]; - if (ent !=[map_i objectAtIndex:0]) - [self selectClass:classname]; // don't reset for world - classent =[entity_classes_i classForName:classname]; - flagname =[ent valueForQKey:"spawnflags"]; + ent = [map_i currentEntity]; + classname = [ent valueForQKey: "classname"]; + if (ent != [map_i objectAtIndex: 0]) + [self selectClass: classname]; // don't reset for world + classent = [entity_classes_i classForName: classname]; + flagname = [ent valueForQKey: "spawnflags"]; if (!flagname) flags = 0; else flags = atoi (flagname); - //[flags_i setAutodisplay:NO]; - for (r = 0; r < 4; r++) + // [flags_i setAutodisplay:NO]; + for (r = 0; r < 4; r++) { for (c = 0; c < 3; c++) { - cell =[flags_i cellAtRow: r column:c]; + cell = [flags_i cellAtRow: r column: c]; if (c < 2) { - flagname =[classent flagName:c * 4 + r]; - [cell setTitle: [NSString stringWithCString:flagname]]; + flagname = [classent flagName: c * 4 + r]; + [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]; // [keyInput_i setStringValue: ""]; @@ -177,27 +175,27 @@ id things_i; [keypairview_i calcViewSize]; [keypairview_i display]; - [quakeed_i makeFirstResponder:quakeed_i]; + [quakeed_i makeFirstResponder: quakeed_i]; return self; } // // Clicked in the Keypair view - set as selected // --setSelectedKey:(epair_t *) ep; +- (id) setSelectedKey: (epair_t *)ep; { - [keyInput_i setStringValue: [NSString stringWithCString:ep->key]]; - [valueInput_i setStringValue: [NSString stringWithCString:ep->value]]; - [valueInput_i selectText:self]; + [keyInput_i setStringValue: [NSString stringWithCString: ep->key]]; + [valueInput_i setStringValue: [NSString stringWithCString: ep->value]]; + [valueInput_i selectText: self]; return self; } --clearInputs +- (id) clearInputs { // [keyInput_i setStringValue: ""]; // [valueInput_i setStringValue: ""]; - [quakeed_i makeFirstResponder:quakeed_i]; + [quakeed_i makeFirstResponder: quakeed_i]; return self; } @@ -205,14 +203,14 @@ id things_i; // Action methods // --addPair:sender +- (id) addPair: sender { - const char *key, *value; + const char *key, *value; key = [[keyInput_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 display]; @@ -223,11 +221,11 @@ id things_i; 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 display]; @@ -239,23 +237,22 @@ id things_i; return self; } - // // Set the key/value fields to "angle