mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-24 05:11:42 +00:00
tactical whitespace bomb
Add return-type information to all methods, split up lines properly where I could find them, and ran the whole thing through uncrustify. Looks purty now. :)
This commit is contained in:
parent
77e6624de3
commit
fb785c334b
47 changed files with 3544 additions and 3602 deletions
|
@ -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
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#include "QF/sys.h"
|
||||
|
||||
#import <AppKit/NSEvent.h>
|
||||
#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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<number>
|
||||
count =[map_i count];
|
||||
// make a unique name of the form t<number>
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <NSMenuItem> itemPrefs_i; // preferences
|
||||
IBOutlet id <NSMenuItem> itemSettings_i; // project settings
|
||||
IBOutlet id <NSMenuItem> itemOutput_i; // bsp output
|
||||
IBOutlet id <NSMenuItem> itemHelp_i; // docs
|
||||
IBOutlet id <NSMenuItem> itemHelp_i; // docs
|
||||
}
|
||||
|
||||
- (IBAction) changeInspector: (id)sender;
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
extern id keypairview_i;
|
||||
extern id keypairview_i;
|
||||
|
||||
@interface KeypairView:NSView
|
||||
@interface KeypairView: NSView
|
||||
{
|
||||
}
|
||||
|
||||
-calcViewSize;
|
||||
- (id) calcViewSize;
|
||||
|
||||
#define SPACING 4
|
||||
#define FONTSIZE 12
|
||||
#define EXTRASPC 2
|
||||
#define SPACING 4
|
||||
#define FONTSIZE 12
|
||||
#define EXTRASPC 2
|
||||
|
||||
#define LINEHEIGHT 16
|
||||
#define LINEHEIGHT 16
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,15 +3,16 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface PopScrollView:NSScrollView
|
||||
@interface PopScrollView: NSScrollView
|
||||
{
|
||||
id button1, button2;
|
||||
id button1, button2;
|
||||
}
|
||||
|
||||
-initWithFrame:(NSRect)
|
||||
frameRect button1:b1 button2:b2;
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
button1: b1
|
||||
button2: b2;
|
||||
|
||||
-tile;
|
||||
- (id) tile;
|
||||
|
||||
@end
|
||||
#endif // PopScrollView_h
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,84 +3,82 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
extern id preferences_i;
|
||||
extern id preferences_i;
|
||||
|
||||
extern float lightaxis[3];
|
||||
extern float lightaxis[3];
|
||||
|
||||
// these are personal preferences saved in NeXT defaults, not project
|
||||
// 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,111 +4,114 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//======================================
|
||||
// ======================================
|
||||
//
|
||||
// QuakeEd Project Management
|
||||
//
|
||||
//======================================
|
||||
// ======================================
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -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 <name>.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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,106 +3,108 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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 <AppKit/AppKit.h>
|
||||
|
||||
@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 */
|
||||
|
|
|
@ -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 <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
This 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 <config.h> */
|
||||
|
@ -26,29 +26,29 @@
|
|||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
|
||||
#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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <button value>"
|
||||
//
|
||||
-setAngle:sender
|
||||
- (id) setAngle: sender
|
||||
{
|
||||
NSString *value;
|
||||
NSString *value;
|
||||
|
||||
value = [[sender selectedCell] title];
|
||||
if (![value compare:@"Up"])
|
||||
if (![value compare: @"Up"])
|
||||
value = @"-1";
|
||||
else if (![value compare:@"Dn"])
|
||||
else if (![value compare: @"Dn"])
|
||||
value = @"-2";
|
||||
|
||||
[keyInput_i setStringValue:@"angle"];
|
||||
[keyInput_i setStringValue: @"angle"];
|
||||
[valueInput_i setStringValue: value];
|
||||
[self addPair:NULL];
|
||||
[self addPair: NULL];
|
||||
|
||||
[self clearInputs];
|
||||
|
||||
|
@ -264,26 +261,27 @@ id things_i;
|
|||
return self;
|
||||
}
|
||||
|
||||
-setFlags:sender
|
||||
- (id) setFlags: sender
|
||||
{
|
||||
int flags;
|
||||
int r, c, i;
|
||||
id cell;
|
||||
int flags;
|
||||
int r, c, i;
|
||||
id cell;
|
||||
|
||||
[self clearInputs];
|
||||
flags = 0;
|
||||
|
||||
for (r = 0; r < 4; r++)
|
||||
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];
|
||||
i = ([cell intValue] > 0);
|
||||
flags |= (i << ((c * 4) + r));
|
||||
}
|
||||
}
|
||||
|
||||
if (!flags)
|
||||
[[map_i currentEntity] removeKeyPair:"spawnflags"];
|
||||
[[map_i currentEntity] removeKeyPair: "spawnflags"];
|
||||
else
|
||||
[[map_i currentEntity] setKey: "spawnflags" toValue:va ("%i", flags)];
|
||||
[[map_i currentEntity] setKey: "spawnflags" toValue: va ("%i", flags)];
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
[keypairview_i display];
|
||||
|
@ -291,28 +289,29 @@ id things_i;
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Fill the Entity 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;
|
||||
int max;
|
||||
int i;
|
||||
id object;
|
||||
id cell;
|
||||
int max;
|
||||
int i;
|
||||
id object;
|
||||
|
||||
max =[entity_classes_i count];
|
||||
max = [entity_classes_i count];
|
||||
i = 0;
|
||||
while (max--) {
|
||||
object =[entity_classes_i objectAtIndex:i];
|
||||
object = [entity_classes_i objectAtIndex: i];
|
||||
[matrix addRow];
|
||||
cell =[matrix cellAtRow: i++ column:0];
|
||||
[cell setStringValue: [NSString stringWithCString:[object
|
||||
classname]]];
|
||||
[cell setLeaf:YES];
|
||||
[cell setLoaded:YES];
|
||||
cell = [matrix cellAtRow: i++ column: 0];
|
||||
[cell setStringValue: [NSString
|
||||
stringWithCString: [object classname]]];
|
||||
[cell setLeaf: YES];
|
||||
[cell setLoaded: YES];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,16 +9,15 @@
|
|||
|
||||
#include "render.h"
|
||||
|
||||
extern id xyview_i;
|
||||
extern id xyview_i;
|
||||
|
||||
#define MINSCALE 0.125
|
||||
#define MAXSCALE 2.0
|
||||
#define MINSCALE 0.125
|
||||
#define MAXSCALE 2.0
|
||||
|
||||
extern vec3_t xy_viewnormal; // v_forward for xy view
|
||||
extern float xy_viewdist; // clip behind this plane
|
||||
|
||||
extern vec3_t xy_viewnormal; // v_forward for xy view
|
||||
extern float xy_viewdist; // clip behind this plane
|
||||
|
||||
extern NSRect xy_draw_rect;
|
||||
extern NSRect xy_draw_rect;
|
||||
|
||||
void linestart (float r, float g, float b);
|
||||
void lineflush (void);
|
||||
|
@ -27,51 +26,57 @@ void linecolor (float r, float g, float b);
|
|||
void XYmoveto (vec3_t pt);
|
||||
void XYlineto (vec3_t pt);
|
||||
|
||||
|
||||
|
||||
@interface XYView:NSView
|
||||
@interface XYView: NSView
|
||||
{
|
||||
NSRect realbounds, newrect, combinedrect;
|
||||
NSPoint midpoint;
|
||||
int gridsize;
|
||||
float scale;
|
||||
|
||||
//
|
||||
// for textured view
|
||||
//
|
||||
int xywidth, xyheight;
|
||||
float *xyzbuffer;
|
||||
unsigned *xypicbuffer;
|
||||
float *xyzbuffer;
|
||||
unsigned *xypicbuffer;
|
||||
|
||||
drawmode_t drawmode;
|
||||
|
||||
//
|
||||
// UI links
|
||||
id mode_radio_i;
|
||||
//
|
||||
id mode_radio_i;
|
||||
}
|
||||
|
||||
-(float) currentScale;
|
||||
- (float) currentScale;
|
||||
|
||||
-setModeRadio:m;
|
||||
- (id) setModeRadio: m;
|
||||
|
||||
-drawMode:sender;
|
||||
-setDrawMode:(drawmode_t) mode;
|
||||
- (id) drawMode: sender;
|
||||
- (id) setDrawMode: (drawmode_t)mode;
|
||||
|
||||
-newSuperBounds;
|
||||
-newRealBounds:(NSRect) nb;
|
||||
- (id) newSuperBounds;
|
||||
- (id) newRealBounds: (NSRect)nb;
|
||||
|
||||
-addToScrollRange: (float) x:(float) y;
|
||||
-setOrigin:(NSPoint) pt scale:(float) sc;
|
||||
- (id) addToScrollRange: (float)x
|
||||
: (float)y;
|
||||
|
||||
-centerOn:(vec3_t) org;
|
||||
- (id) setOrigin: (NSPoint)pt scale: (float)sc;
|
||||
|
||||
-drawMode:sender;
|
||||
- (id) centerOn: (vec3_t)org;
|
||||
|
||||
-superviewChanged;
|
||||
- (id) drawMode: sender;
|
||||
|
||||
-(int) gridsize;
|
||||
-(float) snapToGrid:(float) f;
|
||||
- (id) superviewChanged;
|
||||
|
||||
- (int) gridsize;
|
||||
- (float) snapToGrid: (float)f;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSView(XYView)
|
||||
-(void) setFrame:(NSRect) frame bounds:(NSRect) bounds scale:(NSSize) scale;
|
||||
@interface NSView (XYView)
|
||||
- (void) setFrame: (NSRect)frame
|
||||
bounds: (NSRect)bounds
|
||||
scale: (NSSize)scale;
|
||||
@end
|
||||
#endif // XYView_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,14 +3,15 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface ZScrollView:NSScrollView
|
||||
@interface ZScrollView: NSScrollView
|
||||
{
|
||||
id button1;
|
||||
id button1;
|
||||
}
|
||||
|
||||
-initWithFrame:(NSRect) frameRect button1:b1;
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
button1: b1;
|
||||
|
||||
-tile;
|
||||
- (id) tile;
|
||||
|
||||
@end
|
||||
#endif // ZScrollView_h
|
||||
|
|
|
@ -8,21 +8,23 @@ initWithFrame: button:
|
|||
Initizes a scroll view with a button at it's lower right corner
|
||||
====================
|
||||
*/
|
||||
- initWithFrame:(NSRect) frameRect button1:b1
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
button1: b1
|
||||
{
|
||||
[super initWithFrame:frameRect];
|
||||
[super initWithFrame: frameRect];
|
||||
|
||||
[self addSubview:b1];
|
||||
[self addSubview: b1];
|
||||
|
||||
button1 = b1;
|
||||
|
||||
[self setHasHorizontalScroller:YES];
|
||||
[self setHasVerticalScroller:YES];
|
||||
[self setHasHorizontalScroller: YES];
|
||||
[self setHasVerticalScroller: YES];
|
||||
|
||||
[self setBorderType:NSBezelBorder];
|
||||
[self setBorderType: NSBezelBorder];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
tile
|
||||
|
@ -30,38 +32,36 @@ tile
|
|||
Adjust the size for the pop up scale menu
|
||||
=================
|
||||
*/
|
||||
-tile
|
||||
- (id) tile
|
||||
{
|
||||
NSRect scrollerframe;
|
||||
NSRect scrollerframe;
|
||||
|
||||
[super tile];
|
||||
scrollerframe =[_horizScroller frame];
|
||||
[button1 setFrame:scrollerframe];
|
||||
scrollerframe = [_horizScroller frame];
|
||||
[button1 setFrame: scrollerframe];
|
||||
|
||||
scrollerframe.size.width = 0;
|
||||
[_horizScroller setFrame:scrollerframe];
|
||||
[_horizScroller setHidden:YES];
|
||||
[_horizScroller setFrame: scrollerframe];
|
||||
[_horizScroller setHidden: YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(BOOL) acceptsFirstResponder
|
||||
- (BOOL) acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
- superviewSizeChanged:(const NSSize *)oldSize
|
||||
#if 0
|
||||
- (id) superviewSizeChanged: (const NSSize *)oldSize
|
||||
{
|
||||
[super superviewSizeChanged: oldSize];
|
||||
|
||||
|
||||
[[self documentView] newSuperBounds];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
|
|
@ -7,43 +7,44 @@
|
|||
|
||||
#include "render.h"
|
||||
|
||||
extern id zview_i;
|
||||
extern id zview_i;
|
||||
|
||||
// zplane controls the objects displayed in the xyview
|
||||
extern float zplane;
|
||||
extern float zplanedir;
|
||||
extern float zplane;
|
||||
extern float zplanedir;
|
||||
|
||||
@interface ZView:NSView
|
||||
@interface ZView: NSView
|
||||
{
|
||||
float minheight, maxheight;
|
||||
float oldminheight, oldmaxheight;
|
||||
float topbound, bottombound; // for floor clipping
|
||||
float minheight, maxheight;
|
||||
float oldminheight, oldmaxheight;
|
||||
float topbound, bottombound; // for floor clipping
|
||||
|
||||
float scale;
|
||||
float scale;
|
||||
|
||||
vec3_t origin;
|
||||
vec3_t origin;
|
||||
|
||||
NSBezierPath *checker;
|
||||
NSBezierPath *checker;
|
||||
}
|
||||
|
||||
-clearBounds;
|
||||
-getBounds: (float *) top:(float *) bottom;
|
||||
- (id) clearBounds;
|
||||
- (id) getBounds: (float *)top
|
||||
: (float *)bottom;
|
||||
|
||||
-getPoint:(NSPoint *) pt;
|
||||
-setPoint:(NSPoint *) pt;
|
||||
- (id) getPoint: (NSPoint *)pt;
|
||||
- (id) setPoint: (NSPoint *)pt;
|
||||
|
||||
-addToHeightRange:(float) height;
|
||||
- (id) addToHeightRange: (float)height;
|
||||
|
||||
-newRealBounds;
|
||||
-newSuperBounds;
|
||||
- (id) newRealBounds;
|
||||
- (id) newSuperBounds;
|
||||
|
||||
-XYDrawSelf;
|
||||
- (void) XYDrawSelf;
|
||||
|
||||
-(BOOL) XYmouseDown:(NSPoint *) pt;
|
||||
- (BOOL) XYmouseDown: (NSPoint *)pt;
|
||||
|
||||
-setXYOrigin:(NSPoint *) pt;
|
||||
- (id) setXYOrigin: (NSPoint *)pt;
|
||||
|
||||
-setOrigin:(NSPoint) pt scale:(float) sc;
|
||||
- (id) setOrigin: (NSPoint)pt scale: (float)sc;
|
||||
|
||||
@end
|
||||
#endif // ZView_h
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
#include "XYView.h"
|
||||
#include "CameraView.h"
|
||||
|
||||
id zview_i;
|
||||
id zview_i;
|
||||
|
||||
id zscrollview_i, zscalemenu_i, zscalebutton_i;
|
||||
id zscrollview_i, zscalemenu_i, zscalebutton_i;
|
||||
|
||||
float zplane;
|
||||
float zplanedir;
|
||||
float zplane;
|
||||
float zplanedir;
|
||||
|
||||
extern NSBezierPath *path;
|
||||
extern NSBezierPath *path;
|
||||
|
||||
@implementation ZView
|
||||
/*
|
||||
|
@ -22,10 +22,10 @@ extern NSBezierPath *path;
|
|||
initWithFrame:
|
||||
==================
|
||||
*/
|
||||
- (id) initWithFrame:(NSRect) frameRect
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
{
|
||||
NSPoint pt;
|
||||
NSBezierPath *path;
|
||||
NSPoint pt;
|
||||
NSBezierPath *path;
|
||||
|
||||
path = checker = [NSBezierPath new];
|
||||
[path setLineWidth: 0.3];
|
||||
|
@ -37,36 +37,37 @@ initWithFrame:
|
|||
origin[0] = 0.333;
|
||||
origin[1] = 0.333;
|
||||
|
||||
[super initWithFrame:frameRect];
|
||||
[super initWithFrame: frameRect];
|
||||
[self allocateGState];
|
||||
[self clearBounds];
|
||||
|
||||
zview_i = self;
|
||||
scale = 1;
|
||||
|
||||
//
|
||||
//
|
||||
// initialize the pop up menus
|
||||
//
|
||||
zscalebutton_i =[[NSPopUpButton alloc] init];
|
||||
[zscalebutton_i setTarget:self];
|
||||
zscalebutton_i = [[NSPopUpButton alloc] init];
|
||||
[zscalebutton_i setTarget: self];
|
||||
[zscalebutton_i setAction: @selector (scaleMenuTarget:)];
|
||||
|
||||
[zscalebutton_i addItemWithTitle:@"12.5%"];
|
||||
[zscalebutton_i addItemWithTitle:@"25%"];
|
||||
[zscalebutton_i addItemWithTitle:@"50%"];
|
||||
[zscalebutton_i addItemWithTitle:@"75%"];
|
||||
[zscalebutton_i addItemWithTitle:@"100%"];
|
||||
[zscalebutton_i addItemWithTitle:@"200%"];
|
||||
[zscalebutton_i addItemWithTitle:@"300%"];
|
||||
[zscalebutton_i selectItemAtIndex:4];
|
||||
[zscalebutton_i addItemWithTitle: @"12.5%"];
|
||||
[zscalebutton_i addItemWithTitle: @"25%"];
|
||||
[zscalebutton_i addItemWithTitle: @"50%"];
|
||||
[zscalebutton_i addItemWithTitle: @"75%"];
|
||||
[zscalebutton_i addItemWithTitle: @"100%"];
|
||||
[zscalebutton_i addItemWithTitle: @"200%"];
|
||||
[zscalebutton_i addItemWithTitle: @"300%"];
|
||||
[zscalebutton_i selectItemAtIndex: 4];
|
||||
|
||||
// initialize the scroll view
|
||||
zscrollview_i =[[ZScrollView alloc] initWithFrame: frameRect
|
||||
button1: zscalebutton_i];
|
||||
[zscrollview_i setAutoresizingMask:NSViewWidthSizable |
|
||||
NSViewHeightSizable];
|
||||
zscrollview_i = [[ZScrollView alloc]
|
||||
initWithFrame: frameRect
|
||||
button1: zscalebutton_i];
|
||||
[zscrollview_i setAutoresizingMask: NSViewWidthSizable |
|
||||
NSViewHeightSizable];
|
||||
|
||||
[zscrollview_i setDocumentView:self];
|
||||
[zscrollview_i setDocumentView: self];
|
||||
|
||||
[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
|
||||
|
||||
|
@ -78,19 +79,19 @@ initWithFrame:
|
|||
|
||||
[self newRealBounds];
|
||||
|
||||
[self setOrigin: pt scale:1];
|
||||
[self setOrigin: pt scale: 1];
|
||||
|
||||
return zscrollview_i;
|
||||
}
|
||||
|
||||
-setXYOrigin:(NSPoint *) pt
|
||||
- (id) setXYOrigin: (NSPoint *)pt
|
||||
{
|
||||
origin[0] = pt->x + 0.333;
|
||||
origin[1] = pt->y + 0.333;
|
||||
return self;
|
||||
}
|
||||
|
||||
-(float) currentScale
|
||||
- (float) currentScale
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
|
@ -100,16 +101,16 @@ initWithFrame:
|
|||
setOrigin:scale:
|
||||
===================
|
||||
*/
|
||||
-setOrigin:(NSPoint) pt scale:(float) sc
|
||||
- (id) setOrigin: (NSPoint)pt scale: (float)sc
|
||||
{
|
||||
NSRect sframe;
|
||||
NSRect bounds;
|
||||
NSRect size;
|
||||
NSRect sframe;
|
||||
NSRect bounds;
|
||||
NSRect size;
|
||||
|
||||
// calculate the area visible in the cliprect
|
||||
scale = sc;
|
||||
|
||||
bounds =[_super_view bounds];
|
||||
bounds = [_super_view bounds];
|
||||
bounds.origin = pt;
|
||||
bounds.size.width /= 1;
|
||||
bounds.size.height /= scale;
|
||||
|
@ -118,7 +119,7 @@ setOrigin:scale:
|
|||
// union with the realbounds
|
||||
bounds = NSUnionRect (size, bounds);
|
||||
// redisplay everything
|
||||
bounds.origin = NSMakePoint (-bounds.size.width/2, bounds.origin.y);
|
||||
bounds.origin = NSMakePoint (-bounds.size.width / 2, bounds.origin.y);
|
||||
sframe = bounds;
|
||||
sframe.origin.x *= 1;
|
||||
sframe.origin.y *= scale;
|
||||
|
@ -127,7 +128,7 @@ setOrigin:scale:
|
|||
|
||||
// size this view
|
||||
[quakeed_i disableFlushWindow];
|
||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
||||
[self setFrame: sframe bounds: bounds scale: NSMakeSize (1, scale)];
|
||||
|
||||
// scroll and scale the clip view
|
||||
pt.x *= 1;
|
||||
|
@ -140,7 +141,6 @@ setOrigin:scale:
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
scaleMenuTarget:
|
||||
|
@ -148,22 +148,21 @@ scaleMenuTarget:
|
|||
Called when the scaler popup on the window is used
|
||||
====================
|
||||
*/
|
||||
-scaleMenuTarget:sender
|
||||
- (id) scaleMenuTarget: sender
|
||||
{
|
||||
char const *item;
|
||||
char const *item;
|
||||
NSRect rect;
|
||||
NSPoint mid, org, orig;
|
||||
float nscale;
|
||||
|
||||
item =[[sender titleOfSelectedItem] cString];
|
||||
item = [[sender titleOfSelectedItem] cString];
|
||||
sscanf (item, "%f", &nscale);
|
||||
nscale /= 100;
|
||||
|
||||
if (nscale == scale)
|
||||
return NULL;
|
||||
|
||||
// keep the center of the view constant
|
||||
rect =[_super_view bounds];
|
||||
// keep the center of the view constant
|
||||
rect = [_super_view bounds];
|
||||
mid.x = rect.size.width / 2;
|
||||
mid.y = rect.size.height / 2;
|
||||
|
||||
|
@ -173,13 +172,12 @@ Called when the scaler popup on the window is used
|
|||
orig.x = org.x - mid.x / 1;
|
||||
orig.y = org.y - mid.y / nscale;
|
||||
|
||||
[self setOrigin: orig scale:nscale];
|
||||
[self setOrigin: orig scale: nscale];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
-clearBounds
|
||||
- (id) clearBounds
|
||||
{
|
||||
topbound = 999999;
|
||||
bottombound = -999999;
|
||||
|
@ -187,20 +185,19 @@ Called when the scaler popup on the window is used
|
|||
return self;
|
||||
}
|
||||
|
||||
-getBounds: (float *) top:(float *) bottom;
|
||||
- (id) getBounds: (float *)top: (float *)bottom;
|
||||
{
|
||||
*top = topbound;
|
||||
*bottom = bottombound;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
addToHeightRange:
|
||||
==================
|
||||
*/
|
||||
-addToHeightRange:(float) height
|
||||
- (id) addToHeightRange: (float)height
|
||||
{
|
||||
if (height < minheight)
|
||||
minheight = height;
|
||||
|
@ -209,7 +206,6 @@ addToHeightRange:
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
newSuperBounds
|
||||
|
@ -217,7 +213,7 @@ newSuperBounds
|
|||
When _super_view is resized
|
||||
==================
|
||||
*/
|
||||
-newSuperBounds
|
||||
- (id) newSuperBounds
|
||||
{
|
||||
oldminheight++;
|
||||
[self newRealBounds];
|
||||
|
@ -225,7 +221,6 @@ When _super_view is resized
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
newRealBounds
|
||||
|
@ -234,17 +229,16 @@ Should only change the scroll bars, not cause any redraws.
|
|||
If realbounds has shrunk, nothing will change.
|
||||
===================
|
||||
*/
|
||||
-newRealBounds
|
||||
- (id) newRealBounds
|
||||
{
|
||||
NSRect bounds;
|
||||
NSRect sframe;
|
||||
NSRect size;
|
||||
NSRect bounds;
|
||||
NSRect sframe;
|
||||
NSRect size;
|
||||
|
||||
NSClipView *cv = (NSClipView *) _super_view;
|
||||
NSClipView *cv = (NSClipView *) _super_view;
|
||||
|
||||
if (minheight == oldminheight && maxheight == oldmaxheight)
|
||||
return self;
|
||||
|
||||
oldminheight = minheight;
|
||||
oldmaxheight = maxheight;
|
||||
|
||||
|
@ -252,7 +246,7 @@ If realbounds has shrunk, nothing will change.
|
|||
maxheight += 16;
|
||||
|
||||
// calculate the area visible in the cliprect
|
||||
bounds =[cv bounds];
|
||||
bounds = [cv bounds];
|
||||
bounds.size.width /= 1;
|
||||
bounds.size.height /= scale;
|
||||
|
||||
|
@ -266,7 +260,7 @@ If realbounds has shrunk, nothing will change.
|
|||
|
||||
// size this view
|
||||
[quakeed_i disableFlushWindow];
|
||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
||||
[self setFrame: sframe bounds: bounds scale: NSMakeSize (1, scale)];
|
||||
|
||||
[[_super_view superview] reflectScrolledClipView: cv];
|
||||
|
||||
|
@ -276,8 +270,6 @@ If realbounds has shrunk, nothing will change.
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
drawGrid
|
||||
|
@ -289,29 +281,30 @@ Rect is in global world (unscaled) coordinates
|
|||
============
|
||||
*/
|
||||
|
||||
-drawGrid:(NSRect) rect
|
||||
- (id) drawGrid: (NSRect)rect
|
||||
{
|
||||
int y, stopy;
|
||||
float top, bottom;
|
||||
int left, right;
|
||||
int gridsize;
|
||||
BOOL showcoords;
|
||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||
int y, stopy;
|
||||
float top, bottom;
|
||||
int left, right;
|
||||
int gridsize;
|
||||
BOOL showcoords;
|
||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||
|
||||
showcoords =[quakeed_i showCoordinates];
|
||||
showcoords = [quakeed_i showCoordinates];
|
||||
|
||||
gridsize =[xyview_i gridsize];
|
||||
gridsize = [xyview_i gridsize];
|
||||
|
||||
left = _bounds.origin.x;
|
||||
right = 24;
|
||||
bottom = rect.origin.y - 1;
|
||||
top = rect.origin.y + rect.size.height + 2;
|
||||
|
||||
//
|
||||
// grid
|
||||
//
|
||||
// can't just divide by grid size because of negetive coordinate
|
||||
// truncating direction
|
||||
//
|
||||
|
||||
// can't just divide by grid size because of negetive coordinate
|
||||
// truncating direction
|
||||
if (gridsize >= 4 / scale) {
|
||||
y = floor (bottom / gridsize);
|
||||
stopy = floor (top / gridsize);
|
||||
|
@ -320,19 +313,23 @@ Rect is in global world (unscaled) coordinates
|
|||
stopy *= gridsize;
|
||||
if (y < bottom)
|
||||
y += gridsize;
|
||||
|
||||
[path removeAllPoints];
|
||||
|
||||
for (; y <= stopy; y += gridsize)
|
||||
for ( ; y <= stopy; y += gridsize) {
|
||||
if (y & 31) {
|
||||
[path moveToPoint:NSMakePoint (left, y)];
|
||||
[path lineToPoint:NSMakePoint (right, y)];
|
||||
[path moveToPoint: NSMakePoint (left, y)];
|
||||
[path lineToPoint: NSMakePoint (right, y)];
|
||||
}
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
[[NSColor colorWithCalibratedRed: 0.8 green: 0.8 blue: 1.0 alpha: 1.0]
|
||||
set]; // thin grid color
|
||||
}
|
||||
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
[[NSColor colorWithCalibratedRed: 0.8
|
||||
green: 0.8
|
||||
blue: 1.0
|
||||
alpha: 1.0] set]; // thin grid color
|
||||
[path stroke];
|
||||
}
|
||||
|
||||
//
|
||||
// half tiles
|
||||
//
|
||||
|
@ -345,12 +342,11 @@ Rect is in global world (unscaled) coordinates
|
|||
stopy *= 32;
|
||||
if (stopy >= top)
|
||||
stopy -= 32;
|
||||
|
||||
[path removeAllPoints];
|
||||
|
||||
for (; y <= stopy; y += 64) {
|
||||
[path moveToPoint:NSMakePoint (left, y)];
|
||||
[path lineToPoint:NSMakePoint (right, y)];
|
||||
for ( ; y <= stopy; y += 64) {
|
||||
[path moveToPoint: NSMakePoint (left, y)];
|
||||
[path lineToPoint: NSMakePoint (right, y)];
|
||||
}
|
||||
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
|
@ -370,36 +366,32 @@ Rect is in global world (unscaled) coordinates
|
|||
y += 64;
|
||||
if (stopy >= top)
|
||||
stopy -= 64;
|
||||
|
||||
[path removeAllPoints];
|
||||
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0]
|
||||
set]; // for text
|
||||
|
||||
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0] set]; // for text
|
||||
[[NSFont systemFontOfSize: 10] set];
|
||||
|
||||
for (; y <= stopy; y += 64) {
|
||||
for ( ; y <= stopy; y += 64) {
|
||||
if (showcoords) {
|
||||
NSString *s = [NSString stringWithFormat: @"%i", y];
|
||||
NSString *s = [NSString stringWithFormat: @"%i", y];
|
||||
[s drawAtPoint: NSMakePoint (left, y) withAttributes: attribs];
|
||||
}
|
||||
[path moveToPoint:NSMakePoint (left + 24, y)];
|
||||
[path lineToPoint:NSMakePoint (right, y)];
|
||||
[path moveToPoint: NSMakePoint (left + 24, y)];
|
||||
[path lineToPoint: NSMakePoint (right, y)];
|
||||
}
|
||||
|
||||
// divider
|
||||
[path moveToPoint:NSMakePoint (0, _bounds.origin.y)];
|
||||
[path lineToPoint:NSMakePoint (0,
|
||||
_bounds.origin.y + _bounds.size.height)];
|
||||
// divider
|
||||
[path moveToPoint: NSMakePoint (0, _bounds.origin.y)];
|
||||
[path lineToPoint: NSMakePoint (0, _bounds.origin.y + _bounds.size.height)];
|
||||
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
[[NSColor colorWithCalibratedWhite: 10.0 / 16.0 alpha: 1.0]
|
||||
set];
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
[[NSColor colorWithCalibratedWhite: 10.0 / 16.0 alpha: 1.0] set];
|
||||
[path stroke];
|
||||
|
||||
//
|
||||
// origin
|
||||
//
|
||||
[[NSColor colorWithCalibratedWhite: 4.0 / 16.0 alpha: 1.0]
|
||||
set];
|
||||
[[NSColor colorWithCalibratedWhite: 4.0 / 16.0 alpha: 1.0] set];
|
||||
[path removeAllPoints];
|
||||
[path setLineWidth: 5];
|
||||
[path moveToPoint: NSMakePoint (right, 0)];
|
||||
|
@ -410,15 +402,13 @@ Rect is in global world (unscaled) coordinates
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
-drawZplane
|
||||
- (id) drawZplane
|
||||
{
|
||||
[[NSColor colorWithCalibratedRed: 0.2 green: 0.2 blue: 0.0 alpha: 1.0]
|
||||
set];
|
||||
[path appendBezierPathWithArcWithCenter: NSMakePoint (0, zplane)
|
||||
radius: 4
|
||||
startAngle: 0
|
||||
endAngle: 180];
|
||||
[[NSColor colorWithCalibratedRed: 0.2 green: 0.2 blue: 0.0 alpha: 1.0] set];
|
||||
[path appendBezierPathWithArcWithCenter: NSMakePoint (0, zplane)
|
||||
radius: 4
|
||||
startAngle: 0
|
||||
endAngle: 180];
|
||||
[path fill];
|
||||
return self;
|
||||
}
|
||||
|
@ -429,15 +419,15 @@ drawSelf
|
|||
===============================================================================
|
||||
*/
|
||||
|
||||
- (void) drawRect: (NSRect) rect
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
//NSRect visRect;
|
||||
//Sys_Printf("ZView:drawRect\n");
|
||||
// NSRect visRect;
|
||||
// Sys_Printf("ZView:drawRect\n");
|
||||
minheight = 999999;
|
||||
maxheight = -999999;
|
||||
|
||||
// allways draw the entire bar
|
||||
//visRect =[self visibleRect];
|
||||
// allways draw the entire bar
|
||||
// visRect =[self visibleRect];
|
||||
rect = [self visibleRect];
|
||||
|
||||
[quakeed_i zNoRestore: rect];
|
||||
|
@ -446,13 +436,13 @@ drawSelf
|
|||
NSEraseRect (rect);
|
||||
|
||||
// draw grid
|
||||
[self drawGrid:rect];
|
||||
[self drawGrid: rect];
|
||||
|
||||
// draw zplane
|
||||
// [self drawZplane]; FIXME zplane doesn't do anything yet
|
||||
|
||||
// draw all entities
|
||||
[map_i makeUnselectedPerform:@selector (ZDrawSelf)];
|
||||
[map_i makeUnselectedPerform: @selector (ZDrawSelf)];
|
||||
|
||||
// possibly resize the view
|
||||
[self newRealBounds];
|
||||
|
@ -465,8 +455,8 @@ XYDrawSelf
|
|||
*/
|
||||
- (void) XYDrawSelf
|
||||
{
|
||||
NSBezierPath *path;
|
||||
NSAffineTransform *trans;
|
||||
NSBezierPath *path;
|
||||
NSAffineTransform *trans;
|
||||
|
||||
[[NSColor colorWithCalibratedRed: 0 green: 0.5 blue: 1.0 alpha: 1.0] set];
|
||||
|
||||
|
@ -479,27 +469,25 @@ XYDrawSelf
|
|||
[path release];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
getPoint: (NSPoint *)pt
|
||||
==============
|
||||
*/
|
||||
-getPoint:(NSPoint *) pt
|
||||
- (id) getPoint: (NSPoint *)pt
|
||||
{
|
||||
pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases
|
||||
pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases
|
||||
pt->y = origin[1] + 0.333;
|
||||
return self;
|
||||
}
|
||||
|
||||
-setPoint:(NSPoint *) pt
|
||||
- (id) setPoint: (NSPoint *)pt
|
||||
{
|
||||
origin[0] = pt->x;
|
||||
origin[1] = pt->y;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
@ -508,53 +496,51 @@ MOUSE CLICKING
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
dragLoop:
|
||||
================
|
||||
*/
|
||||
static NSPoint oldreletive;
|
||||
static NSPoint oldreletive;
|
||||
|
||||
-dragFrom: (NSEvent *) startevent useGrid: (BOOL) ug callback:(void (*)(float dy)) callback
|
||||
- (id) dragFrom: (NSEvent *)startevent
|
||||
useGrid: (BOOL)ug
|
||||
callback: (void (*)(float dy))callback
|
||||
{
|
||||
NSEvent *event;
|
||||
NSEvent *event;
|
||||
NSPoint startpt, newpt;
|
||||
NSPoint reletive, delta;
|
||||
int gridsize;
|
||||
|
||||
gridsize =[xyview_i gridsize];
|
||||
gridsize = [xyview_i gridsize];
|
||||
|
||||
startpt =[startevent locationInWindow];
|
||||
startpt =[self convertPoint: startpt fromView:NULL];
|
||||
startpt = [startevent locationInWindow];
|
||||
startpt = [self convertPoint: startpt fromView: NULL];
|
||||
|
||||
oldreletive.x = oldreletive.y = 0;
|
||||
reletive.x = 0;
|
||||
|
||||
while (1) {
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
||||
| NSApplicationDefinedMask;
|
||||
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate
|
||||
distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode dequeue:YES];
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
||||
| NSApplicationDefinedMask;
|
||||
event = [NSApp nextEventMatchingMask: eventMask untilDate: [NSDate
|
||||
distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode dequeue:
|
||||
YES];
|
||||
|
||||
if ([event type] == NSLeftMouseUp ||[event type] == NSRightMouseUp)
|
||||
if ([event type] == NSLeftMouseUp || [event type] == NSRightMouseUp)
|
||||
break;
|
||||
|
||||
newpt =[event locationInWindow];
|
||||
newpt =[self convertPoint: newpt fromView:NULL];
|
||||
newpt = [event locationInWindow];
|
||||
newpt = [self convertPoint: newpt fromView: NULL];
|
||||
|
||||
reletive.y = newpt.y - startpt.y;
|
||||
|
||||
if (ug) { // we want truncate towards 0 behavior
|
||||
// here
|
||||
if (ug) // we want truncate-towards-0 behavior here
|
||||
reletive.y = gridsize * (int) (reletive.y / gridsize);
|
||||
}
|
||||
|
||||
if (reletive.y == oldreletive.y)
|
||||
continue;
|
||||
|
||||
delta.y = reletive.y - oldreletive.y;
|
||||
oldreletive = reletive;
|
||||
callback (delta.y);
|
||||
|
@ -563,8 +549,7 @@ static NSPoint oldreletive;
|
|||
return self;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
// ============================================================================
|
||||
|
||||
void
|
||||
ZDragCallback (float dy)
|
||||
|
@ -573,21 +558,20 @@ ZDragCallback (float dy)
|
|||
sb_translate[1] = 0;
|
||||
sb_translate[2] = dy;
|
||||
|
||||
[map_i makeSelectedPerform:@selector (translate)];
|
||||
[map_i makeSelectedPerform: @selector (translate)];
|
||||
|
||||
[quakeed_i redrawInstance];
|
||||
}
|
||||
|
||||
-selectionDragFrom:(NSEvent *) theEvent
|
||||
- (id) selectionDragFrom: (NSEvent *)theEvent
|
||||
{
|
||||
Sys_Printf ("dragging selection\n");
|
||||
[self dragFrom: theEvent useGrid: YES callback:ZDragCallback];
|
||||
[self dragFrom: theEvent useGrid: YES callback: ZDragCallback];
|
||||
[quakeed_i updateCamera];
|
||||
return self;
|
||||
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// ============================================================================
|
||||
|
||||
void
|
||||
ZScrollCallback (float dy)
|
||||
|
@ -596,31 +580,31 @@ ZScrollCallback (float dy)
|
|||
NSPoint neworg;
|
||||
float scale;
|
||||
|
||||
basebounds =[[zview_i superview] bounds];
|
||||
basebounds =[zview_i convertRect: basebounds fromView:[zview_i
|
||||
superview]];
|
||||
basebounds = [[zview_i superview] bounds];
|
||||
basebounds = [zview_i convertRect: basebounds fromView: [zview_i
|
||||
superview]];
|
||||
|
||||
neworg.y = basebounds.origin.y - dy;
|
||||
|
||||
scale =[zview_i currentScale];
|
||||
scale = [zview_i currentScale];
|
||||
|
||||
oldreletive.y -= dy;
|
||||
[zview_i setOrigin: neworg scale:scale];
|
||||
[zview_i setOrigin: neworg scale: scale];
|
||||
}
|
||||
|
||||
-scrollDragFrom:(NSEvent *) theEvent
|
||||
- (id) scrollDragFrom: (NSEvent *)theEvent
|
||||
{
|
||||
Sys_Printf ("scrolling view\n");
|
||||
[self dragFrom: theEvent useGrid: YES callback:ZScrollCallback];
|
||||
[self dragFrom: theEvent useGrid: YES callback: ZScrollCallback];
|
||||
return self;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// ============================================================================
|
||||
|
||||
void
|
||||
ZControlCallback (float dy)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numcontrolpoints; i++)
|
||||
controlpoints[i][2] += dy;
|
||||
|
@ -629,31 +613,29 @@ ZControlCallback (float dy)
|
|||
[quakeed_i redrawInstance];
|
||||
}
|
||||
|
||||
-(BOOL) planeDragFrom:(NSEvent *) theEvent
|
||||
- (BOOL) planeDragFrom: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint pt;
|
||||
vec3_t dragpoint;
|
||||
|
||||
if ([map_i numSelected] != 1)
|
||||
return NO;
|
||||
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
pt = [theEvent locationInWindow];
|
||||
pt = [self convertPoint: pt fromView: NULL];
|
||||
|
||||
dragpoint[0] = origin[0];
|
||||
dragpoint[1] = origin[1];
|
||||
dragpoint[2] = pt.y;
|
||||
|
||||
[[map_i selectedBrush] getZdragface:dragpoint];
|
||||
[[map_i selectedBrush] getZdragface: dragpoint];
|
||||
if (!numcontrolpoints)
|
||||
return NO;
|
||||
|
||||
Sys_Printf ("dragging brush plane\n");
|
||||
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
pt = [theEvent locationInWindow];
|
||||
pt = [self convertPoint: pt fromView: NULL];
|
||||
|
||||
[self dragFrom: theEvent useGrid: YES callback:ZControlCallback];
|
||||
[self dragFrom: theEvent useGrid: YES callback: ZControlCallback];
|
||||
|
||||
[[map_i selectedBrush] removeIfInvalid];
|
||||
|
||||
|
@ -661,52 +643,51 @@ ZControlCallback (float dy)
|
|||
return YES;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
// ============================================================================
|
||||
|
||||
/*
|
||||
===================
|
||||
mouseDown
|
||||
===================
|
||||
*/
|
||||
-(void) mouseDown:(NSEvent *) theEvent
|
||||
- (void) mouseDown: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint pt;
|
||||
int flags;
|
||||
vec3_t p1;
|
||||
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
pt = [theEvent locationInWindow];
|
||||
pt = [self convertPoint: pt fromView: NULL];
|
||||
|
||||
p1[0] = origin[0];
|
||||
p1[1] = origin[1];
|
||||
p1[2] = pt.y;
|
||||
|
||||
flags =
|
||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
||||
NSAlternateKeyMask | NSCommandKeyMask);
|
||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
||||
NSAlternateKeyMask | NSCommandKeyMask);
|
||||
|
||||
//
|
||||
// shift click to select / deselect a brush from the world
|
||||
//
|
||||
if (flags == NSShiftKeyMask) {
|
||||
[map_i selectRay: p1: p1:NO];
|
||||
[map_i selectRay: p1: p1: NO];
|
||||
return;
|
||||
}
|
||||
//
|
||||
// alt click = set entire brush texture
|
||||
//
|
||||
if (flags == NSAlternateKeyMask) {
|
||||
[map_i setTextureRay: p1: p1:YES];
|
||||
[map_i setTextureRay: p1: p1: YES];
|
||||
return;
|
||||
}
|
||||
//
|
||||
// control click = position view
|
||||
//
|
||||
if (flags == NSControlKeyMask) {
|
||||
[cameraview_i setZOrigin:pt.y];
|
||||
[cameraview_i setZOrigin: pt.y];
|
||||
[quakeed_i updateAll];
|
||||
[cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]];
|
||||
[cameraview_i ZmouseDown: &pt flags: [theEvent modifierFlags]];
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
@ -714,18 +695,16 @@ mouseDown
|
|||
//
|
||||
if (flags == 0) {
|
||||
// check eye
|
||||
if ([cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]])
|
||||
if ([cameraview_i ZmouseDown: &pt flags: [theEvent modifierFlags]])
|
||||
return;
|
||||
|
||||
if ([map_i numSelected]) {
|
||||
if (pt.x > 0) {
|
||||
if ([self planeDragFrom:theEvent])
|
||||
if ([self planeDragFrom: theEvent])
|
||||
return;
|
||||
}
|
||||
[self selectionDragFrom:theEvent];
|
||||
[self selectionDragFrom: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Sys_Printf ("bad flags for click %x %g %g\n", flags, pt.x, pt.y);
|
||||
|
@ -738,35 +717,31 @@ mouseDown
|
|||
rightMouseDown
|
||||
===================
|
||||
*/
|
||||
-(void) rightMouseDown:(NSEvent *) theEvent
|
||||
- (void) rightMouseDown: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint pt;
|
||||
int flags;
|
||||
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
pt = [theEvent locationInWindow];
|
||||
pt = [self convertPoint: pt fromView: NULL];
|
||||
|
||||
flags =
|
||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
||||
NSAlternateKeyMask | NSCommandKeyMask);
|
||||
|
||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
||||
NSAlternateKeyMask | NSCommandKeyMask);
|
||||
|
||||
//
|
||||
// click = scroll view
|
||||
//
|
||||
if (flags == 0) {
|
||||
[self scrollDragFrom:theEvent];
|
||||
}
|
||||
|
||||
if (flags == 0)
|
||||
[self scrollDragFrom: theEvent];
|
||||
Sys_Printf ("bad flags for click\n");
|
||||
NopSound ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
XY mouse view methods
|
||||
XY mouse view methods
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
@ -776,14 +751,16 @@ rightMouseDown
|
|||
modalMoveLoop
|
||||
================
|
||||
*/
|
||||
-modalMoveLoop: (NSPoint *) basept: (vec3_t) movemod:converter
|
||||
- (id) modalMoveLoop: (NSPoint *)basept
|
||||
: (vec3_t)movemod
|
||||
: converter
|
||||
{
|
||||
vec3_t originbase;
|
||||
NSEvent *event;
|
||||
NSEvent *event;
|
||||
NSPoint newpt;
|
||||
vec3_t delta;
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
VectorCopy (origin, originbase);
|
||||
|
||||
|
@ -792,27 +769,27 @@ modalMoveLoop
|
|||
|
||||
while ([event type] != NSLeftMouseUp) {
|
||||
// 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];
|
||||
|
||||
|
||||
drawentry:
|
||||
// instance draw new frame
|
||||
[quakeed_i newinstance];
|
||||
[self display];
|
||||
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
||||
|
||||
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate
|
||||
distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode dequeue:YES];
|
||||
event = [NSApp nextEventMatchingMask: eventMask untilDate: [NSDate
|
||||
distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode dequeue:
|
||||
YES];
|
||||
}
|
||||
|
||||
// draw the brush back into the window buffer
|
||||
|
@ -826,18 +803,17 @@ modalMoveLoop
|
|||
XYmouseDown
|
||||
===============
|
||||
*/
|
||||
-(BOOL) XYmouseDown:(NSPoint *) pt
|
||||
- (BOOL) XYmouseDown: (NSPoint *)pt
|
||||
{
|
||||
vec3_t movemod;
|
||||
vec3_t movemod;
|
||||
|
||||
if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16)
|
||||
return NO;
|
||||
|
||||
movemod[0] = 1;
|
||||
movemod[1] = 1;
|
||||
movemod[2] = 0;
|
||||
|
||||
[self modalMoveLoop: pt: movemod:xyview_i];
|
||||
[self modalMoveLoop: pt: movemod: xyview_i];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
|
||||
|
||||
|
||||
char token[MAXTOKEN];
|
||||
boolean unget;
|
||||
char *script_p;
|
||||
char *script_p;
|
||||
int scriptline;
|
||||
|
||||
void
|
||||
|
@ -17,38 +14,42 @@ StartTokenParsing (char *data)
|
|||
boolean
|
||||
GetToken (boolean crossline)
|
||||
{
|
||||
char *token_p;
|
||||
char *token_p;
|
||||
|
||||
if (unget) // is a token allready waiting?
|
||||
if (unget) // is a token allready waiting?
|
||||
return true;
|
||||
|
||||
//
|
||||
// skip space
|
||||
//
|
||||
skipspace:
|
||||
skipspace:
|
||||
while (*script_p <= 32) {
|
||||
if (!*script_p) {
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete", scriptline);
|
||||
|
||||
return false;
|
||||
}
|
||||
if (*script_p++ == '\n') {
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete", scriptline);
|
||||
|
||||
scriptline++;
|
||||
}
|
||||
}
|
||||
|
||||
if (script_p[0] == '/' && script_p[1] == '/') // comment field
|
||||
{
|
||||
if (script_p[0] == '/' && script_p[1] == '/') { // comment field
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete\n", scriptline);
|
||||
while (*script_p++ != '\n')
|
||||
|
||||
while (*script_p++ != '\n') {
|
||||
if (!*script_p) {
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete", scriptline);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
goto skipspace;
|
||||
}
|
||||
//
|
||||
|
@ -61,17 +62,19 @@ GetToken (boolean crossline)
|
|||
while (*script_p != '"') {
|
||||
if (!*script_p)
|
||||
Error ("EOF inside quoted token");
|
||||
|
||||
*token_p++ = *script_p++;
|
||||
if (token_p == &token[MAXTOKEN])
|
||||
Error ("Token too large on line %i", scriptline);
|
||||
}
|
||||
script_p++;
|
||||
} else
|
||||
} else {
|
||||
while (*script_p > 32) {
|
||||
*token_p++ = *script_p++;
|
||||
if (token_p == &token[MAXTOKEN])
|
||||
Error ("Token too large on line %i", scriptline);
|
||||
}
|
||||
}
|
||||
|
||||
*token_p = 0;
|
||||
|
||||
|
@ -84,27 +87,22 @@ UngetToken ()
|
|||
unget = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||
qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsprintf (string, fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
[g_cmd_out_i setStringValue: [NSString stringWithCString:string]];
|
||||
[g_cmd_out_i setStringValue: [NSString stringWithCString: string]];
|
||||
// NSPing ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Error
|
||||
|
@ -112,15 +110,16 @@ Error
|
|||
For abnormal program terminations
|
||||
=================
|
||||
*/
|
||||
BOOL in_error;
|
||||
BOOL in_error;
|
||||
void
|
||||
Error (char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
if (in_error)
|
||||
[NSApp terminate:NULL];
|
||||
[NSApp terminate: NULL];
|
||||
|
||||
in_error = YES;
|
||||
|
||||
va_start (argptr, error);
|
||||
|
@ -129,19 +128,16 @@ Error (char *error, ...)
|
|||
|
||||
strcat (string, "\nmap saved to " FN_CRASHSAVE);
|
||||
|
||||
[map_i writeMapFile: FN_CRASHSAVE useRegion:NO];
|
||||
NSRunAlertPanel (@"Error",[NSString stringWithCString:string], NULL, NULL,
|
||||
NULL);
|
||||
|
||||
[NSApp terminate:NULL];
|
||||
[map_i writeMapFile: FN_CRASHSAVE useRegion: NO];
|
||||
NSRunAlertPanel (@"Error", [NSString stringWithCString: string],
|
||||
NULL, NULL, NULL);
|
||||
[NSApp terminate: NULL];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
CleanupName (char *in, char *out)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (!in[i])
|
||||
|
@ -150,20 +146,18 @@ CleanupName (char *in, char *out)
|
|||
out[i] = toupper (in[i]);
|
||||
}
|
||||
|
||||
for (; i < 16; i++)
|
||||
for ( ; i < 16; i++)
|
||||
out[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrintRect (NSRect * r)
|
||||
{
|
||||
printf ("(%4.0f, %4.0f) + (%4.0f, %4.0f) = (%4.0f,%4.0f)\n", r->origin.x,
|
||||
r->origin.y, r->size.width, r->size.height,
|
||||
r->origin.x + r->size.width, r->origin.y + r->size.height);
|
||||
r->origin.y, r->size.width, r->size.height,
|
||||
r->origin.x + r->size.width, r->origin.y + r->size.height);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
FileTime
|
||||
|
@ -174,7 +168,7 @@ returns -1 if not present
|
|||
int
|
||||
FileTime (char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
struct stat buf;
|
||||
|
||||
if (stat (path, &buf) == -1)
|
||||
return -1;
|
||||
|
@ -190,10 +184,10 @@ CreatePath
|
|||
void
|
||||
CreatePath (char *path)
|
||||
{
|
||||
char *ofs;
|
||||
char *ofs;
|
||||
|
||||
for (ofs = path + 1; *ofs; ofs++) {
|
||||
if (*ofs == '/') { // create the directory
|
||||
if (*ofs == '/') { // create the directory
|
||||
*ofs = 0;
|
||||
mkdir (path, 0777);
|
||||
*ofs = '/';
|
||||
|
@ -204,9 +198,8 @@ CreatePath (char *path)
|
|||
int
|
||||
I_FileOpenRead (char *path, int *handle)
|
||||
{
|
||||
int h;
|
||||
struct stat fileinfo;
|
||||
|
||||
int h;
|
||||
struct stat fileinfo;
|
||||
|
||||
h = open (path, O_RDONLY, 0666);
|
||||
*handle = h;
|
||||
|
@ -222,7 +215,7 @@ I_FileOpenRead (char *path, int *handle)
|
|||
int
|
||||
I_FileOpenWrite (char *path)
|
||||
{
|
||||
int handle;
|
||||
int handle;
|
||||
|
||||
umask (0);
|
||||
|
||||
|
@ -244,28 +237,28 @@ Copies a more recent net file to the local drive
|
|||
void
|
||||
Sys_UpdateFile (char *path, char *netpath)
|
||||
{
|
||||
int ltime, ntime;
|
||||
int in, out, size;
|
||||
char *buf;
|
||||
int ltime, ntime;
|
||||
int in, out, size;
|
||||
char *buf;
|
||||
|
||||
ltime = FileTime (path);
|
||||
ntime = FileTime (netpath);
|
||||
|
||||
if (ntime <= ltime)
|
||||
return; // up to date
|
||||
return; // up to date
|
||||
|
||||
// copy the file
|
||||
// copy the file
|
||||
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
|
||||
|
||||
size = I_FileOpenRead (netpath, &in);
|
||||
buf = malloc (size);
|
||||
if (read (in, buf, size) != size)
|
||||
Error ("UpdateFile: couldn't read all of %s", netpath);
|
||||
|
||||
close (in);
|
||||
|
||||
CreatePath (path);
|
||||
out = I_FileOpenWrite (path);
|
||||
write (out, buf, size);
|
||||
close (out);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "mathlib.h"
|
||||
|
||||
#include "EntityClass.h"
|
||||
#include "Project.h"
|
||||
#include "Project.h"
|
||||
#include "QuakeEd.h"
|
||||
#include "Map.h"
|
||||
#include "TexturePalette.h"
|
||||
|
@ -26,35 +26,34 @@
|
|||
#include "CameraView.h"
|
||||
#include "ZView.h"
|
||||
#include "ZScrollView.h"
|
||||
#include "Preferences.h"
|
||||
#include "InspectorControl.h"
|
||||
#include "Preferences.h"
|
||||
#include "InspectorControl.h"
|
||||
#include "PopScrollView.h"
|
||||
#include "KeypairView.h"
|
||||
#include "Things.h"
|
||||
#include "TextureView.h"
|
||||
#include "Clipper.h"
|
||||
|
||||
void PrintRect (NSRect * r);
|
||||
int FileTime (char *path);
|
||||
void Sys_UpdateFile (char *path, char *netpath);
|
||||
void CleanupName (char *in, char *out);
|
||||
|
||||
void PrintRect (NSRect * r);
|
||||
int FileTime (char *path);
|
||||
void Sys_UpdateFile (char *path, char *netpath);
|
||||
void CleanupName (char *in, char *out);
|
||||
extern BOOL in_error;
|
||||
void Error (char *error, ...);
|
||||
|
||||
extern BOOL in_error;
|
||||
void Error (char *error, ...);
|
||||
#define MAXTOKEN 128
|
||||
extern char token[MAXTOKEN];
|
||||
extern int scriptline;
|
||||
|
||||
#define MAXTOKEN 128
|
||||
extern char token[MAXTOKEN];
|
||||
extern int scriptline;
|
||||
void StartTokenParsing (char *data);
|
||||
boolean GetToken (boolean crossline); // returns false at eof
|
||||
void UngetToken ();
|
||||
void StartTokenParsing (char *data);
|
||||
boolean GetToken (boolean crossline); // returns false at eof
|
||||
void UngetToken ();
|
||||
|
||||
|
||||
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
|
||||
#define FN_TEMPSAVE "/qcache/temp.map"
|
||||
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
||||
#define FN_CRASHSAVE "/qcache/ErrorSaveMap.map"
|
||||
#define FN_DEVLOG "/qcache/devlog"
|
||||
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
|
||||
#define FN_TEMPSAVE "/qcache/temp.map"
|
||||
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
||||
#define FN_CRASHSAVE "/qcache/ErrorSaveMap.map"
|
||||
#define FN_DEVLOG "/qcache/devlog"
|
||||
|
||||
#endif // qedefs_h
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
|
||||
#include "SetBrush.h"
|
||||
|
||||
typedef enum { dr_wire, dr_flat, dr_texture } drawmode_t;
|
||||
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
|
||||
|
||||
extern int r_width, r_height;
|
||||
extern unsigned *r_picbuffer;
|
||||
extern float *r_zbuffer;
|
||||
extern int r_width, r_height;
|
||||
extern unsigned *r_picbuffer;
|
||||
extern float *r_zbuffer;
|
||||
|
||||
extern vec3_t r_origin, r_matrix[3];
|
||||
extern BOOL r_drawflat;
|
||||
extern vec3_t r_origin, r_matrix[3];
|
||||
extern BOOL r_drawflat;
|
||||
|
||||
void REN_ClearBuffers (void);
|
||||
void REN_DrawCameraFace (face_t * idpol);
|
||||
void REN_DrawXYFace (face_t * idpol);
|
||||
void REN_BeginCamera (void);
|
||||
void REN_BeginXY (void);
|
||||
void REN_ClearBuffers (void);
|
||||
void REN_DrawCameraFace (face_t * idpol);
|
||||
void REN_DrawXYFace (face_t * idpol);
|
||||
void REN_BeginCamera (void);
|
||||
void REN_BeginXY (void);
|
||||
|
||||
#endif // render_h
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
|
||||
#include "render.h"
|
||||
|
||||
extern vec3_t xy_viewnormal;
|
||||
extern vec3_t xy_viewnormal;
|
||||
|
||||
//define NOLIGHT
|
||||
// define NOLIGHT
|
||||
|
||||
vec3_t r_origin, r_matrix[3];
|
||||
vec3_t r_origin, r_matrix[3];
|
||||
|
||||
int t_width, t_height;
|
||||
unsigned *t_data;
|
||||
unsigned *t_data;
|
||||
int t_widthmask, t_heightmask, t_widthshift;
|
||||
float t_widthadd, t_heightadd;
|
||||
|
||||
int r_width, r_height;
|
||||
float *r_zbuffer;
|
||||
unsigned *r_picbuffer;
|
||||
float *r_zbuffer;
|
||||
unsigned *r_picbuffer;
|
||||
|
||||
vec5_t rightside, leftside, rightstep, leftstep;
|
||||
vec5_t rightside, leftside, rightstep, leftstep;
|
||||
|
||||
face_t *r_face;
|
||||
face_t *r_face;
|
||||
|
||||
BOOL r_drawflat;
|
||||
BOOL r_drawflat;
|
||||
|
||||
pixel32_t r_flatcolor;
|
||||
pixel32_t r_flatcolor;
|
||||
|
||||
int sy[20];
|
||||
int sy[20];
|
||||
|
||||
/*
|
||||
====================
|
||||
|
@ -34,7 +33,7 @@ REN_ClearBuffers
|
|||
void
|
||||
REN_ClearBuffers (void)
|
||||
{
|
||||
int size;
|
||||
int size;
|
||||
|
||||
size = r_width * r_height * 4;
|
||||
|
||||
|
@ -42,22 +41,20 @@ REN_ClearBuffers (void)
|
|||
memset (r_picbuffer, 0, size);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
REN_SetTexture
|
||||
====================
|
||||
*/
|
||||
|
||||
void
|
||||
REN_SetTexture (face_t * face)
|
||||
{
|
||||
int i;
|
||||
int t_heightshift;
|
||||
qtexture_t *q;
|
||||
qtexture_t *q;
|
||||
|
||||
if (!face->qtexture)
|
||||
face->qtexture = TEX_ForName (face->texture.texture); // try to load
|
||||
face->qtexture = TEX_ForName (face->texture.texture); // try to load
|
||||
q = face->qtexture;
|
||||
|
||||
t_width = q->width;
|
||||
|
@ -90,7 +87,7 @@ REN_SetTexture (face_t * face)
|
|||
}
|
||||
|
||||
if ((1 << t_widthshift) != t_width || (1 << t_heightshift) != t_height)
|
||||
t_widthshift = t_heightshift = 0; // non power of two
|
||||
t_widthshift = t_heightshift = 0; // non power of two
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -106,7 +103,7 @@ REN_DrawSpan (int y)
|
|||
int tx, ty;
|
||||
int x1, x2;
|
||||
float ufrac, vfrac, zfrac, lightfrac, ustep, vstep, zstep;
|
||||
pixel32_t *in, *out;
|
||||
pixel32_t *in, *out;
|
||||
float scale;
|
||||
|
||||
if (y < 0 || y >= r_height)
|
||||
|
@ -142,7 +139,6 @@ REN_DrawSpan (int y)
|
|||
|
||||
if (x2 > r_width)
|
||||
x2 = r_width;
|
||||
|
||||
ofs = y * r_width + x1;
|
||||
|
||||
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
||||
|
@ -155,14 +151,14 @@ REN_DrawSpan (int y)
|
|||
if (t_widthshift) {
|
||||
tx = (int) ((ufrac * scale)) & t_widthmask;
|
||||
ty = (int) ((vfrac * scale)) & t_heightmask;
|
||||
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
||||
in = (pixel32_t *) &t_data[(ty << t_widthshift) + tx];
|
||||
} else {
|
||||
tx = (int) ((ufrac * scale) + t_widthadd) % t_width;
|
||||
ty = (int) ((vfrac * scale) + t_heightadd) % t_height;
|
||||
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
||||
in = (pixel32_t *) &t_data[ty * t_width + tx];
|
||||
}
|
||||
|
||||
out = (pixel32_t *) & r_picbuffer[ofs];
|
||||
out = (pixel32_t *) &r_picbuffer[ofs];
|
||||
#ifdef NOLIGHT
|
||||
*out = *in;
|
||||
#else
|
||||
|
@ -177,7 +173,6 @@ REN_DrawSpan (int y)
|
|||
zfrac += zstep;
|
||||
ofs++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -188,11 +183,11 @@ REN_DrawFlatSpan
|
|||
void
|
||||
REN_DrawFlatSpan (int y)
|
||||
{
|
||||
int x, count;
|
||||
int ofs;
|
||||
int x1, x2;
|
||||
float zfrac, zstep;
|
||||
int *out;
|
||||
int x, count;
|
||||
int ofs;
|
||||
int x1, x2;
|
||||
float zfrac, zstep;
|
||||
int *out;
|
||||
|
||||
if (y < 0 || y >= r_height)
|
||||
return;
|
||||
|
@ -228,7 +223,6 @@ REN_DrawFlatSpan (int y)
|
|||
zfrac += zstep;
|
||||
ofs++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -240,12 +234,12 @@ REN_RasterizeFace
|
|||
void
|
||||
REN_RasterizeFace (winding_t * w)
|
||||
{
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
|
||||
//
|
||||
// find top vertex
|
||||
|
@ -271,7 +265,7 @@ REN_RasterizeFace (winding_t * w)
|
|||
rightv = leftv;
|
||||
|
||||
if (top < 0 || bot > r_height || top > bot)
|
||||
return; // shouldn't have to have this...
|
||||
return; // shouldn't have to have this...
|
||||
|
||||
//
|
||||
// render a trapezoid
|
||||
|
@ -283,6 +277,7 @@ REN_RasterizeFace (winding_t * w)
|
|||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
leftside[i] = w->points[leftv][i];
|
||||
|
||||
leftv--;
|
||||
if (leftv == -1)
|
||||
leftv = numvertex - 1;
|
||||
|
@ -295,6 +290,7 @@ REN_RasterizeFace (winding_t * w)
|
|||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
rightside[i] = w->points[rightv][i];
|
||||
|
||||
rightv++;
|
||||
if (rightv == numvertex)
|
||||
rightv = 0;
|
||||
|
@ -318,7 +314,7 @@ REN_RasterizeFace (winding_t * w)
|
|||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// =============================================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
|
@ -333,7 +329,7 @@ REN_DrawSpanLinear (int y)
|
|||
int tx, ty;
|
||||
int x1, x2;
|
||||
float ufrac, vfrac, zfrac, ustep, vstep, zstep;
|
||||
pixel32_t *in, *out;
|
||||
pixel32_t *in, *out;
|
||||
float scale;
|
||||
|
||||
if (y < 0 || y >= r_height)
|
||||
|
@ -359,7 +355,6 @@ REN_DrawSpanLinear (int y)
|
|||
ustep = (rightside[3] - ufrac) * scale;
|
||||
vstep = (rightside[4] - vfrac) * scale;
|
||||
|
||||
|
||||
if (x1 < 0) {
|
||||
ufrac -= x1 * ustep;
|
||||
vfrac -= x1 * vstep;
|
||||
|
@ -379,14 +374,14 @@ REN_DrawSpanLinear (int y)
|
|||
if (t_widthshift) {
|
||||
tx = (int) ufrac & t_widthmask;
|
||||
ty = (int) vfrac & t_heightmask;
|
||||
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
||||
in = (pixel32_t *) &t_data[(ty << t_widthshift) + tx];
|
||||
} else {
|
||||
tx = (int) (ufrac + t_widthadd) % t_width;
|
||||
ty = (int) (vfrac + t_heightadd) % t_height;
|
||||
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
||||
in = (pixel32_t *) &t_data[ty * t_width + tx];
|
||||
}
|
||||
|
||||
out = (pixel32_t *) & r_picbuffer[ofs];
|
||||
out = (pixel32_t *) &r_picbuffer[ofs];
|
||||
*out = *in;
|
||||
}
|
||||
ufrac += ustep;
|
||||
|
@ -394,7 +389,6 @@ REN_DrawSpanLinear (int y)
|
|||
zfrac += zstep;
|
||||
ofs++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -406,12 +400,12 @@ REN_RasterizeFaceLinear
|
|||
void
|
||||
REN_RasterizeFaceLinear (winding_t * w)
|
||||
{
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
|
||||
//
|
||||
// find top vertex
|
||||
|
@ -434,7 +428,7 @@ REN_RasterizeFaceLinear (winding_t * w)
|
|||
rightv = leftv;
|
||||
|
||||
if (top < 0 || bot > r_height || top > bot)
|
||||
return; // shouldn't have to have this...
|
||||
return; // shouldn't have to have this...
|
||||
|
||||
//
|
||||
// render a trapezoid
|
||||
|
@ -446,6 +440,7 @@ REN_RasterizeFaceLinear (winding_t * w)
|
|||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
leftside[i] = w->points[leftv][i];
|
||||
|
||||
leftv--;
|
||||
if (leftv == -1)
|
||||
leftv = numvertex - 1;
|
||||
|
@ -458,6 +453,7 @@ REN_RasterizeFaceLinear (winding_t * w)
|
|||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
rightside[i] = w->points[rightv][i];
|
||||
|
||||
rightv++;
|
||||
if (rightv == numvertex)
|
||||
rightv = 0;
|
||||
|
@ -478,7 +474,7 @@ REN_RasterizeFaceLinear (winding_t * w)
|
|||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// ============================================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
|
@ -494,39 +490,37 @@ REN_BeginCamera (void)
|
|||
r_width_2 = (float) r_width / 2;
|
||||
r_height_3 = (float) r_height / 3;
|
||||
|
||||
|
||||
// clip to right side
|
||||
// clip to right side
|
||||
rfrustum[0].normal[0] = -1;
|
||||
rfrustum[0].normal[1] = 0;
|
||||
rfrustum[0].normal[2] = 1;
|
||||
rfrustum[0].dist = 0;
|
||||
|
||||
// clip to left side
|
||||
// clip to left side
|
||||
rfrustum[1].normal[0] = 1;
|
||||
rfrustum[1].normal[1] = 0;
|
||||
rfrustum[1].normal[2] = 1;
|
||||
rfrustum[1].dist = 0;
|
||||
|
||||
// clip to top side
|
||||
// clip to top side
|
||||
rfrustum[2].normal[0] = 0;
|
||||
rfrustum[2].normal[1] = -1;
|
||||
rfrustum[2].normal[2] = r_height_3 / r_width_2;
|
||||
rfrustum[2].dist = 0;
|
||||
|
||||
// clip to bottom side
|
||||
// clip to bottom side
|
||||
rfrustum[3].normal[0] = 0;
|
||||
rfrustum[3].normal[1] = 1;
|
||||
rfrustum[3].normal[2] = 2 * r_height_3 / r_width_2;
|
||||
rfrustum[3].dist = 0;
|
||||
|
||||
// near Z
|
||||
// near Z
|
||||
rfrustum[4].normal[0] = 0;
|
||||
rfrustum[4].normal[1] = 0;
|
||||
rfrustum[4].normal[2] = 1;
|
||||
rfrustum[4].dist = 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
REN_BeginXY (void)
|
||||
{
|
||||
|
@ -562,11 +556,11 @@ REN_DrawCameraFace (face_t * idpol)
|
|||
int i;
|
||||
float scale;
|
||||
int numvertex;
|
||||
winding_t *w, *in;
|
||||
winding_t *w, *in;
|
||||
vec3_t temp;
|
||||
|
||||
if (!idpol->w)
|
||||
return; // overconstrained plane
|
||||
return; // overconstrained plane
|
||||
|
||||
r_face = idpol;
|
||||
|
||||
|
@ -614,7 +608,6 @@ REN_DrawCameraFace (face_t * idpol)
|
|||
w->points[i][2] = scale;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// draw it
|
||||
//
|
||||
|
@ -624,7 +617,6 @@ REN_DrawCameraFace (face_t * idpol)
|
|||
free (w);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=====================
|
||||
REN_DrawXYFace
|
||||
|
@ -634,14 +626,14 @@ void
|
|||
REN_DrawXYFace (face_t * idpol)
|
||||
{
|
||||
int i, j, numvertex;
|
||||
winding_t *w, *in;
|
||||
float *dest, *source;
|
||||
winding_t *w, *in;
|
||||
float *dest, *source;
|
||||
float temp;
|
||||
|
||||
if (!idpol->w)
|
||||
return; // overconstrained plane
|
||||
w = idpol->w;
|
||||
return; // overconstrained plane
|
||||
|
||||
w = idpol->w;
|
||||
r_face = idpol;
|
||||
|
||||
//
|
||||
|
@ -663,7 +655,7 @@ REN_DrawXYFace (face_t * idpol)
|
|||
// using Z as a scale for the 2D projection
|
||||
w->points[i][0] = (in->points[i][0] - r_origin[0]) * r_origin[2];
|
||||
w->points[i][1] =
|
||||
r_height - (in->points[i][1] - r_origin[1]) * r_origin[2];
|
||||
r_height - (in->points[i][1] - r_origin[1]) * r_origin[2];
|
||||
w->points[i][2] = in->points[i][2] + 3000;
|
||||
w->points[i][3] = in->points[i][3];
|
||||
w->points[i][4] = in->points[i][4];
|
||||
|
@ -695,7 +687,7 @@ REN_DrawXYFace (face_t * idpol)
|
|||
dest[2] = 4096 - dest[2];
|
||||
}
|
||||
|
||||
if (xy_viewnormal[2] > 0) { // flip order when upside down
|
||||
if (xy_viewnormal[2] > 0) { // flip order when upside down
|
||||
for (i = 0; i < w->numpoints / 2; i++) {
|
||||
dest = w->points[i];
|
||||
source = w->points[w->numpoints - 1 - i];
|
||||
|
@ -709,7 +701,6 @@ REN_DrawXYFace (face_t * idpol)
|
|||
|
||||
REN_SetTexture (idpol);
|
||||
|
||||
|
||||
//
|
||||
// draw it
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue