mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-24 13:21:11 +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
|
@ -18,7 +18,7 @@ void CameraLineto (vec3_t p);
|
||||||
|
|
||||||
extern BOOL timedrawing;
|
extern BOOL timedrawing;
|
||||||
|
|
||||||
@interface CameraView:NSView
|
@interface CameraView: NSView
|
||||||
{
|
{
|
||||||
float xa, ya, za;
|
float xa, ya, za;
|
||||||
float move;
|
float move;
|
||||||
|
@ -41,36 +41,36 @@ extern BOOL timedrawing;
|
||||||
|
|
||||||
// UI links
|
// UI links
|
||||||
id mode_radio_i;
|
id mode_radio_i;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-setXYOrigin:(NSPoint *) pt;
|
- (id) setXYOrigin: (NSPoint *)pt;
|
||||||
-setZOrigin:(float) pt;
|
- (id) setZOrigin: (float)pt;
|
||||||
|
|
||||||
-setOrigin:(vec3_t)
|
- (id) setOrigin: (vec3_t)org
|
||||||
org
|
angle: (float)angle;
|
||||||
angle:(float)angle;
|
|
||||||
|
|
||||||
-getOrigin:(vec3_t)org;
|
- (id) getOrigin: (vec3_t)org;
|
||||||
|
|
||||||
-(float) yawAngle;
|
- (float) yawAngle;
|
||||||
|
|
||||||
-matrixFromAngles;
|
- (id) matrixFromAngles;
|
||||||
-_keyDown:(NSEvent *)theEvent;
|
- (id) _keyDown: (NSEvent *)theEvent;
|
||||||
|
|
||||||
-drawMode:sender;
|
- (id) drawMode: sender;
|
||||||
-setDrawMode:(drawmode_t) mode;
|
- (id) setDrawMode: (drawmode_t)mode;
|
||||||
|
|
||||||
-homeView:sender;
|
- (id) homeView: sender;
|
||||||
|
|
||||||
- (void) XYDrawSelf; // for drawing viewpoint in XY view
|
- (void) XYDrawSelf; // for drawing viewpoint in XY view
|
||||||
- (void) ZDrawSelf; // for drawing viewpoint in XY view
|
- (void) ZDrawSelf; // for drawing viewpoint in XY view
|
||||||
-(BOOL) XYmouseDown:(NSPoint *)pt flags:(int)flags;// return YES if brush handled
|
- (BOOL) XYmouseDown: (NSPoint *)pt // return YES if brush handled
|
||||||
|
flags: (int)flags;
|
||||||
|
|
||||||
-(BOOL) ZmouseDown:(NSPoint *)pt flags:(int)flags;// return YES if brush handled
|
- (BOOL) ZmouseDown: (NSPoint *)pt // return YES if brush handled
|
||||||
|
flags: (int)flags;
|
||||||
|
|
||||||
-upFloor:sender;
|
- (id) upFloor: sender;
|
||||||
-downFloor:sender;
|
- (id) downFloor: sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // CameraView_h
|
#endif // CameraView_h
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
|
#import <AppKit/NSEvent.h>
|
||||||
#include "CameraView.h"
|
#include "CameraView.h"
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "QuakeEd.h"
|
#include "QuakeEd.h"
|
||||||
|
@ -17,7 +18,7 @@ BOOL timedrawing = 0;
|
||||||
initWithFrame:
|
initWithFrame:
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
- initWithFrame:(NSRect)frameRect
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ initWithFrame:
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)awakeFromNib
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
NSBezierPath *path;
|
NSBezierPath *path;
|
||||||
|
|
||||||
|
@ -77,20 +78,21 @@ initWithFrame:
|
||||||
[path relativeLineToPoint: NSMakePoint (45, -45)];
|
[path relativeLineToPoint: NSMakePoint (45, -45)];
|
||||||
}
|
}
|
||||||
|
|
||||||
-setXYOrigin:(NSPoint *)pt
|
- (id) setXYOrigin: (NSPoint *)pt
|
||||||
{
|
{
|
||||||
origin[0] = pt->x;
|
origin[0] = pt->x;
|
||||||
origin[1] = pt->y;
|
origin[1] = pt->y;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setZOrigin:(float)pt
|
- (id) setZOrigin: (float)pt
|
||||||
{
|
{
|
||||||
origin[2] = pt;
|
origin[2] = pt;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setOrigin:(vec3_t)org angle:(float)angle
|
- (id) setOrigin: (vec3_t)org
|
||||||
|
angle: (float)angle
|
||||||
{
|
{
|
||||||
VectorCopy (org, origin);
|
VectorCopy (org, origin);
|
||||||
ya = angle;
|
ya = angle;
|
||||||
|
@ -98,18 +100,18 @@ initWithFrame:
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-getOrigin:(vec3_t)org
|
- (id) getOrigin: (vec3_t)org
|
||||||
{
|
{
|
||||||
VectorCopy (origin, org);
|
VectorCopy (origin, org);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float)yawAngle
|
- (float) yawAngle
|
||||||
{
|
{
|
||||||
return ya;
|
return ya;
|
||||||
}
|
}
|
||||||
|
|
||||||
-upFloor:sender
|
- (id) upFloor: sender
|
||||||
{
|
{
|
||||||
sb_floor_dir = 1;
|
sb_floor_dir = 1;
|
||||||
sb_floor_dist = 99999;
|
sb_floor_dist = 99999;
|
||||||
|
@ -124,7 +126,7 @@ initWithFrame:
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-downFloor:sender
|
- (id) downFloor: sender
|
||||||
{
|
{
|
||||||
sb_floor_dir = -1;
|
sb_floor_dir = -1;
|
||||||
sb_floor_dist = -99999;
|
sb_floor_dist = -99999;
|
||||||
|
@ -152,7 +154,7 @@ UI TARGETS
|
||||||
homeView
|
homeView
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
-homeView:sender
|
- (id) homeView: sender
|
||||||
{
|
{
|
||||||
xa = za = 0;
|
xa = za = 0;
|
||||||
|
|
||||||
|
@ -165,14 +167,14 @@ homeView
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-drawMode:sender
|
- (id) drawMode: sender
|
||||||
{
|
{
|
||||||
drawmode =[sender selectedColumn];
|
drawmode = [sender selectedColumn];
|
||||||
[quakeed_i updateCamera];
|
[quakeed_i updateCamera];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setDrawMode:(drawmode_t)mode
|
- (id) setDrawMode: (drawmode_t)mode
|
||||||
{
|
{
|
||||||
drawmode = mode;
|
drawmode = mode;
|
||||||
[mode_radio_i selectCellAtRow: 0 column: mode];
|
[mode_radio_i selectCellAtRow: 0 column: mode];
|
||||||
|
@ -188,39 +190,40 @@ TRANSFORMATION METHODS
|
||||||
===============================================================================
|
===============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
-matrixFromAngles
|
- (id) matrixFromAngles
|
||||||
{
|
{
|
||||||
if (xa > M_PI * 0.4)
|
if (xa > M_PI * 0.4)
|
||||||
xa = M_PI * 0.4;
|
xa = M_PI * 0.4;
|
||||||
if (xa < -M_PI * 0.4)
|
if (xa < -M_PI * 0.4)
|
||||||
xa = -M_PI * 0.4;
|
xa = -M_PI * 0.4;
|
||||||
|
|
||||||
// vpn
|
// vpn
|
||||||
matrix[2][0] = cos (xa) * cos (ya);
|
matrix[2][0] = cos (xa) * cos (ya);
|
||||||
matrix[2][1] = cos (xa) * sin (ya);
|
matrix[2][1] = cos (xa) * sin (ya);
|
||||||
matrix[2][2] = sin (xa);
|
matrix[2][2] = sin (xa);
|
||||||
|
|
||||||
// vup
|
// vup
|
||||||
matrix[1][0] = cos (xa + M_PI / 2) * cos (ya);
|
matrix[1][0] = cos (xa + M_PI / 2) * cos (ya);
|
||||||
matrix[1][1] = cos (xa + M_PI / 2) * sin (ya);
|
matrix[1][1] = cos (xa + M_PI / 2) * sin (ya);
|
||||||
matrix[1][2] = sin (xa + M_PI / 2);
|
matrix[1][2] = sin (xa + M_PI / 2);
|
||||||
|
|
||||||
// vright
|
// vright
|
||||||
CrossProduct (matrix[2], matrix[1], matrix[0]);
|
CrossProduct (matrix[2], matrix[1], matrix[0]);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) inverseTransform: (vec_t *)invec
|
||||||
-inverseTransform:(vec_t *)invec to:(vec_t *)outvec
|
to: (vec_t *)outvec
|
||||||
{
|
{
|
||||||
vec3_t inverse[3];
|
vec3_t inverse[3];
|
||||||
vec3_t temp;
|
vec3_t temp;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++) {
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
inverse[i][j] = matrix[j][i];
|
inverse[i][j] = matrix[j][i];
|
||||||
|
}
|
||||||
|
|
||||||
temp[0] = DotProduct (invec, inverse[0]);
|
temp[0] = DotProduct (invec, inverse[0]);
|
||||||
temp[1] = DotProduct (invec, inverse[1]);
|
temp[1] = DotProduct (invec, inverse[1]);
|
||||||
|
@ -231,8 +234,6 @@ TRANSFORMATION METHODS
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|
||||||
|
@ -296,13 +297,12 @@ MakeCampt (vec3_t in, campt_t * pt)
|
||||||
if (pt->clipflags)
|
if (pt->clipflags)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// project
|
// project
|
||||||
scale = mid_x / pt->trans[2];
|
scale = mid_x / pt->trans[2];
|
||||||
pt->screen[0] = mid_x + pt->trans[0] * scale;
|
pt->screen[0] = mid_x + pt->trans[0] * scale;
|
||||||
pt->screen[1] = mid_y + pt->trans[1] * scale;
|
pt->screen[1] = mid_y + pt->trans[1] * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CameraMoveto (vec3_t p)
|
CameraMoveto (vec3_t p)
|
||||||
{
|
{
|
||||||
|
@ -314,9 +314,8 @@ CameraMoveto (vec3_t p)
|
||||||
pt = &campts[cam_cur];
|
pt = &campts[cam_cur];
|
||||||
cam_cur ^= 1;
|
cam_cur ^= 1;
|
||||||
MakeCampt (p, pt);
|
MakeCampt (p, pt);
|
||||||
if (!pt->clipflags) {
|
if (!pt->clipflags) { // onscreen, so move there immediately
|
||||||
// onscreen, so move there immediately
|
NSPoint point = {pt->screen[0], pt->screen[1]};
|
||||||
NSPoint point = { pt->screen[0], pt->screen[1] };
|
|
||||||
[path moveToPoint: point];
|
[path moveToPoint: point];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,8 +329,7 @@ ClipLine (vec3_t p1, vec3_t p2, int planenum)
|
||||||
float scale;
|
float scale;
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
|
|
||||||
if (planenum == 5) {
|
if (planenum == 5) { // draw it!
|
||||||
// draw it!
|
|
||||||
scale = mid_x / p1[2];
|
scale = mid_x / p1[2];
|
||||||
point.x = mid_x + p1[0] * scale;
|
point.x = mid_x + p1[0] * scale;
|
||||||
point.y = mid_y + p1[1] * scale;
|
point.y = mid_y + p1[1] * scale;
|
||||||
|
@ -348,9 +346,8 @@ ClipLine (vec3_t p1, vec3_t p2, int planenum)
|
||||||
|
|
||||||
d = DotProduct (p1, pl->normal) - pl->dist;
|
d = DotProduct (p1, pl->normal) - pl->dist;
|
||||||
d2 = DotProduct (p2, pl->normal) - pl->dist;
|
d2 = DotProduct (p2, pl->normal) - pl->dist;
|
||||||
if (d <= ON_EPSILON && d2 <= ON_EPSILON) { // off screen
|
if (d <= ON_EPSILON && d2 <= ON_EPSILON) // off screen
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (d >= 0 && d2 >= 0) { // on front
|
if (d >= 0 && d2 >= 0) { // on front
|
||||||
ClipLine (p1, p2, planenum + 1);
|
ClipLine (p1, p2, planenum + 1);
|
||||||
|
@ -381,34 +378,34 @@ CameraLineto (vec3_t p)
|
||||||
p1 = &campts[cam_cur];
|
p1 = &campts[cam_cur];
|
||||||
MakeCampt (p, p2);
|
MakeCampt (p, p2);
|
||||||
|
|
||||||
if (p1->clipflags & p2->clipflags) {
|
if (p1->clipflags & p2->clipflags) { // entirely off screen
|
||||||
c_off++;
|
c_off++;
|
||||||
return; // entirely off screen
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bits = p1->clipflags | p2->clipflags;
|
bits = p1->clipflags | p2->clipflags;
|
||||||
|
if (!bits) { // entirely on screen
|
||||||
|
NSPoint point1 = {p1->screen[0], p1->screen[1]};
|
||||||
|
NSPoint point2 = {p2->screen[0], p2->screen[1]};
|
||||||
|
|
||||||
if (!bits) {
|
|
||||||
NSPoint point1 = { p1->screen[0], p1->screen[1] };
|
|
||||||
NSPoint point2 = { p2->screen[0], p2->screen[1] };
|
|
||||||
c_on++;
|
c_on++;
|
||||||
[path moveToPoint: point1];
|
[path moveToPoint: point1];
|
||||||
[path lineToPoint: point2];
|
[path lineToPoint: point2];
|
||||||
return; // entirely on screen
|
return;
|
||||||
}
|
}
|
||||||
// needs to be clipped
|
|
||||||
|
// needs to be clipped
|
||||||
c_clip++;
|
c_clip++;
|
||||||
|
|
||||||
ClipLine (p1->trans, p2->trans, 0);
|
ClipLine (p1->trans, p2->trans, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
drawSolid
|
drawSolid
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
-drawSolid
|
- (id) drawSolid
|
||||||
{
|
{
|
||||||
unsigned char *planes[5];
|
unsigned char *planes[5];
|
||||||
|
|
||||||
|
@ -442,25 +439,21 @@ drawSolid
|
||||||
|
|
||||||
planes[0] = (unsigned char *) imagebuffer;
|
planes[0] = (unsigned char *) imagebuffer;
|
||||||
NSDrawBitmap (_bounds, r_width, r_height, 8, 3, 32, r_width * 4, NO, NO,
|
NSDrawBitmap (_bounds, r_width, r_height, 8, 3, 32, r_width * 4, NO, NO,
|
||||||
NSCalibratedRGBColorSpace,
|
NSCalibratedRGBColorSpace, (const unsigned char **) planes);
|
||||||
(const unsigned char **) planes);
|
|
||||||
|
|
||||||
[[self window] setBackingType: NSBackingStoreBuffered];
|
[[self window] setBackingType: NSBackingStoreBuffered];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
drawWire
|
drawWire
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-drawWire:(NSRect)rect
|
- (id) drawWire: (NSRect)rect
|
||||||
{
|
{
|
||||||
// copy current info to globals for the C callbacks
|
// copy current info to globals for the C callbacks
|
||||||
mid_x = _bounds.size.width / 2;
|
mid_x = _bounds.size.width / 2;
|
||||||
mid_y = 2 * _bounds.size.height / 3;
|
mid_y = 2 * _bounds.size.height / 3;
|
||||||
|
|
||||||
|
@ -476,10 +469,10 @@ drawWire
|
||||||
|
|
||||||
REN_BeginCamera ();
|
REN_BeginCamera ();
|
||||||
|
|
||||||
// erase window
|
// erase window
|
||||||
NSEraseRect (rect);
|
NSEraseRect (rect);
|
||||||
|
|
||||||
// draw all entities
|
// draw all entities
|
||||||
linestart (0, 0, 0);
|
linestart (0, 0, 0);
|
||||||
[map_i makeUnselectedPerform: @selector (CameraDrawSelf)];
|
[map_i makeUnselectedPerform: @selector (CameraDrawSelf)];
|
||||||
lineflush ();
|
lineflush ();
|
||||||
|
@ -492,7 +485,7 @@ drawWire
|
||||||
drawSelf
|
drawSelf
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
- (void) drawRect:(NSRect)rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
float drawtime = 0;
|
float drawtime = 0;
|
||||||
|
|
||||||
|
@ -513,7 +506,6 @@ drawSelf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
XYDrawSelf
|
XYDrawSelf
|
||||||
|
@ -563,7 +555,6 @@ ZDrawSelf
|
||||||
[path release];
|
[path release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|
||||||
|
@ -577,10 +568,15 @@ ZDrawSelf
|
||||||
modalMoveLoop
|
modalMoveLoop
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
-modalMoveLoop:(NSPoint *)basept :(vec3_t)movemod :converter
|
- (id) modalMoveLoop: (NSPoint *)basept
|
||||||
|
: (vec3_t)movemod
|
||||||
|
: converter
|
||||||
{
|
{
|
||||||
vec3_t originbase;
|
vec3_t originbase;
|
||||||
NSEvent *event = 0;
|
NSEvent *event = 0;
|
||||||
|
unsigned eventMask = (NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||||
|
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
||||||
|
| NSApplicationDefinedMask);
|
||||||
NSPoint newpt;
|
NSPoint newpt;
|
||||||
vec3_t delta;
|
vec3_t delta;
|
||||||
int i;
|
int i;
|
||||||
|
@ -592,10 +588,10 @@ modalMoveLoop
|
||||||
// modal event loop using instance drawing
|
// modal event loop using instance drawing
|
||||||
goto drawentry;
|
goto drawentry;
|
||||||
|
|
||||||
while ([event type] != NSLeftMouseUp &&[event type] != NSRightMouseUp) {
|
while ([event type] != NSLeftMouseUp && [event type] != NSRightMouseUp) {
|
||||||
// calculate new point
|
// calculate new point
|
||||||
newpt =[event locationInWindow];
|
newpt = [event locationInWindow];
|
||||||
newpt =[converter convertPoint: newpt fromView: NULL];
|
newpt = [converter convertPoint: newpt fromView: NULL];
|
||||||
|
|
||||||
delta[0] = newpt.x - basept->x;
|
delta[0] = newpt.x - basept->x;
|
||||||
delta[1] = newpt.y - basept->y;
|
delta[1] = newpt.y - basept->y;
|
||||||
|
@ -611,14 +607,14 @@ modalMoveLoop
|
||||||
id ent;
|
id ent;
|
||||||
vec3_t temp;
|
vec3_t temp;
|
||||||
|
|
||||||
ent =[quakemap_i selectedEntity];
|
ent = [quakemap_i selectedEntity];
|
||||||
if (ent) {
|
if (ent) {
|
||||||
[ent origin: temp];
|
[ent origin: temp];
|
||||||
brushpt.x = temp[0];
|
brushpt.x = temp[0];
|
||||||
brushpt.y = temp[1];
|
brushpt.y = temp[1];
|
||||||
} else
|
} else {
|
||||||
brushpt =[brush_i centerPoint];
|
brushpt = [brush_i centerPoint];
|
||||||
ya = atan2 (brushpt.y - newpt.y, brushpt.x - newpt.x);
|
} ya = atan2 (brushpt.y - newpt.y, brushpt.x - newpt.x);
|
||||||
[self matrixFromAngles];
|
[self matrixFromAngles];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -627,30 +623,29 @@ modalMoveLoop
|
||||||
// instance draw new frame
|
// instance draw new frame
|
||||||
[quakeed_i newinstance];
|
[quakeed_i newinstance];
|
||||||
[self display];
|
[self display];
|
||||||
event = [NSApp nextEventMatchingMask: NSLeftMouseUpMask
|
event = [NSApp nextEventMatchingMask: eventMask
|
||||||
| NSLeftMouseDraggedMask | NSRightMouseUpMask
|
|
||||||
| NSRightMouseDraggedMask | NSApplicationDefinedMask
|
|
||||||
untilDate: [NSDate distantFuture]
|
untilDate: [NSDate distantFuture]
|
||||||
inMode: NSEventTrackingRunLoopMode dequeue: YES];
|
inMode: NSEventTrackingRunLoopMode dequeue:
|
||||||
|
YES];
|
||||||
if ([event type] == NSKeyDown) {
|
if ([event type] == NSKeyDown) {
|
||||||
[self _keyDown: event];
|
[self _keyDown: event];
|
||||||
[self display];
|
[self display];
|
||||||
goto drawentry;
|
goto drawentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
XYmouseDown
|
XYmouseDown
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
-(BOOL) XYmouseDown:(NSPoint *)pt flags:(int)flags
|
- (BOOL) XYmouseDown: (NSPoint *)pt
|
||||||
|
flags: (int)flags
|
||||||
// return YES if brush handled
|
// return YES if brush handled
|
||||||
{
|
{
|
||||||
vec3_t movemod;
|
vec3_t movemod;
|
||||||
|
@ -671,18 +666,18 @@ XYmouseDown
|
||||||
movemod[2] = 0;
|
movemod[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self modalMoveLoop: pt : movemod : xyview_i];
|
[self modalMoveLoop: pt: movemod: xyview_i];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
ZmouseDown
|
ZmouseDown
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
-(BOOL) ZmouseDown:(NSPoint *)pt flags:(int)flags
|
- (BOOL) ZmouseDown: (NSPoint *)pt
|
||||||
|
flags: (int)flags
|
||||||
// return YES if brush handled
|
// return YES if brush handled
|
||||||
{
|
{
|
||||||
vec3_t movemod;
|
vec3_t movemod;
|
||||||
|
@ -694,20 +689,19 @@ ZmouseDown
|
||||||
movemod[1] = 0;
|
movemod[1] = 0;
|
||||||
movemod[2] = 1;
|
movemod[2] = 1;
|
||||||
|
|
||||||
[self modalMoveLoop: pt : movemod : zview_i];
|
[self modalMoveLoop: pt: movemod: zview_i];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
viewDrag:
|
viewDrag:
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-viewDrag:(NSPoint *)pt
|
- (id) viewDrag: (NSPoint *)pt
|
||||||
{
|
{
|
||||||
float dx, dy;
|
float dx, dy;
|
||||||
NSEvent *event = 0;
|
NSEvent *event = 0;
|
||||||
|
@ -722,8 +716,8 @@ viewDrag:
|
||||||
//
|
//
|
||||||
// calculate new point
|
// calculate new point
|
||||||
//
|
//
|
||||||
newpt =[event locationInWindow];
|
newpt = [event locationInWindow];
|
||||||
newpt =[self convertPoint: newpt fromView: NULL];
|
newpt = [self convertPoint: newpt fromView: NULL];
|
||||||
|
|
||||||
dx = newpt.x - pt->x;
|
dx = newpt.x - pt->x;
|
||||||
dy = newpt.y - pt->y;
|
dy = newpt.y - pt->y;
|
||||||
|
@ -740,27 +734,26 @@ viewDrag:
|
||||||
event = [NSApp nextEventMatchingMask: NSRightMouseUpMask
|
event = [NSApp nextEventMatchingMask: NSRightMouseUpMask
|
||||||
| NSRightMouseDraggedMask
|
| NSRightMouseDraggedMask
|
||||||
untilDate: [NSDate distantFuture]
|
untilDate: [NSDate distantFuture]
|
||||||
inMode: NSEventTrackingRunLoopMode dequeue: YES];
|
inMode: NSEventTrackingRunLoopMode dequeue:
|
||||||
|
YES];
|
||||||
if ([event type] == NSKeyDown) {
|
if ([event type] == NSKeyDown) {
|
||||||
[self _keyDown:event];
|
[self _keyDown: event];
|
||||||
[self display];
|
[self display];
|
||||||
goto drawentry;
|
goto drawentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
mouseDown
|
mouseDown
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-(void) mouseDown:(NSEvent *)theEvent
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
int i;
|
int i;
|
||||||
|
@ -768,17 +761,18 @@ mouseDown
|
||||||
float forward, right, up;
|
float forward, right, up;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
pt =[theEvent locationInWindow];
|
pt = [theEvent locationInWindow];
|
||||||
|
|
||||||
pt =[self convertPoint: pt fromView: NULL];
|
pt = [self convertPoint: pt fromView: NULL];
|
||||||
|
|
||||||
VectorCopy (origin, p1);
|
VectorCopy (origin, p1);
|
||||||
forward = 160;
|
forward = 160;
|
||||||
right = pt.x - 160;
|
right = pt.x - 160;
|
||||||
up = pt.y - 240 * 2 / 3;
|
up = pt.y - 240 * 2 / 3;
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++) {
|
||||||
p2[i] =
|
p2[i] =
|
||||||
forward * matrix[2][i] + up * matrix[1][i] + right * matrix[0][i];
|
forward * matrix[2][i] + up * matrix[1][i] + right * matrix[0][i];
|
||||||
|
}
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
p2[i] = p1[i] + 100 * p2[i];
|
p2[i] = p1[i] + 100 * p2[i];
|
||||||
|
|
||||||
|
@ -835,7 +829,6 @@ mouseDown
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Sys_Printf ("bad flags for click %x\n", flags);
|
Sys_Printf ("bad flags for click %x\n", flags);
|
||||||
NopSound ();
|
NopSound ();
|
||||||
|
|
||||||
|
@ -847,18 +840,18 @@ mouseDown
|
||||||
rightMouseDown
|
rightMouseDown
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-(void) rightMouseDown:(NSEvent *)theEvent
|
- (void) rightMouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
pt =[theEvent locationInWindow];
|
pt = [theEvent locationInWindow];
|
||||||
|
|
||||||
[self convertPoint: pt fromView: NULL];
|
[self convertPoint: pt fromView: NULL];
|
||||||
|
|
||||||
flags =
|
flags = [theEvent modifierFlags]
|
||||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
& (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask
|
||||||
NSAlternateKeyMask | NSCommandKeyMask);
|
| NSCommandKeyMask);
|
||||||
|
|
||||||
//
|
//
|
||||||
// click = drag camera
|
// click = drag camera
|
||||||
|
@ -881,11 +874,10 @@ keyDown
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
- (id) _keyDown: (NSEvent *)theEvent
|
||||||
-_keyDown:(NSEvent *)theEvent
|
|
||||||
{
|
{
|
||||||
NSString *chars = [theEvent characters];
|
NSString *chars = [theEvent characters];
|
||||||
unichar c = [chars length] == 1 ? [chars characterAtIndex: 0] : '\0';
|
unichar c = ([chars length] == 1) ? [chars characterAtIndex: 0] : '\0';
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 13:
|
case 13:
|
||||||
|
@ -952,12 +944,9 @@ keyDown
|
||||||
origin[2] -= move;
|
origin[2] -= move;
|
||||||
[quakeed_i updateCamera];
|
[quakeed_i updateCamera];
|
||||||
break;
|
break;
|
||||||
|
} /* switch */
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -9,20 +9,20 @@
|
||||||
|
|
||||||
extern id clipper_i;
|
extern id clipper_i;
|
||||||
|
|
||||||
@interface Clipper:NSObject
|
@interface Clipper: NSObject
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
vec3_t pos[3];
|
vec3_t pos[3];
|
||||||
plane_t plane;
|
plane_t plane;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) hide;
|
- (BOOL) hide;
|
||||||
-XYClick:(NSPoint) pt;
|
- (id) XYClick: (NSPoint)pt;
|
||||||
-(BOOL) XYDrag:(NSPoint *) pt;
|
- (BOOL) XYDrag: (NSPoint *)pt;
|
||||||
-ZClick:(NSPoint) pt;
|
- (id) ZClick: (NSPoint)pt;
|
||||||
-carve;
|
- (id) carve;
|
||||||
- (void) flipNormal;
|
- (void) flipNormal;
|
||||||
-(BOOL) getFace:(face_t *) pl;
|
- (BOOL) getFace: (face_t *)pl;
|
||||||
|
|
||||||
- (void) cameraDrawSelf;
|
- (void) cameraDrawSelf;
|
||||||
- (void) XYDrawSelf;
|
- (void) XYDrawSelf;
|
||||||
|
|
|
@ -12,14 +12,14 @@ extern NSBezierPath *path;
|
||||||
|
|
||||||
@implementation Clipper
|
@implementation Clipper
|
||||||
|
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
clipper_i = self;
|
clipper_i = self;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) hide
|
- (BOOL) hide
|
||||||
{
|
{
|
||||||
int oldnum;
|
int oldnum;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ extern NSBezierPath *path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) getFace:(face_t *) f
|
- (BOOL) getFace: (face_t *)f
|
||||||
{
|
{
|
||||||
vec3_t v1, v2, norm;
|
vec3_t v1, v2, norm;
|
||||||
int i;
|
int i;
|
||||||
|
@ -72,7 +72,7 @@ extern NSBezierPath *path;
|
||||||
if (!norm[0] && !norm[1] && !norm[2])
|
if (!norm[0] && !norm[1] && !norm[2])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
[texturepalette_i getTextureDef:&f->texture];
|
[texturepalette_i getTextureDef: &f->texture];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -82,28 +82,27 @@ extern NSBezierPath *path;
|
||||||
XYClick
|
XYClick
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
-XYClick:(NSPoint) pt
|
- (id) XYClick: (NSPoint)pt
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
vec3_t new;
|
vec3_t new;
|
||||||
|
|
||||||
new[0] =[xyview_i snapToGrid:pt.x];
|
new[0] = [xyview_i snapToGrid: pt.x];
|
||||||
new[1] =[xyview_i snapToGrid:pt.y];
|
new[1] = [xyview_i snapToGrid: pt.y];
|
||||||
new[2] =[map_i currentMinZ];
|
new[2] = [map_i currentMinZ];
|
||||||
|
|
||||||
// see if a point is allready there
|
// see if a point is allready there
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
if (new[0] == pos[i][0] && new[1] == pos[i][1]) {
|
if (new[0] == pos[i][0] && new[1] == pos[i][1]) {
|
||||||
if (pos[i][2] ==[map_i currentMinZ])
|
if (pos[i][2] == [map_i currentMinZ])
|
||||||
pos[i][2] =[map_i currentMaxZ];
|
pos[i][2] = [map_i currentMaxZ];
|
||||||
else
|
else
|
||||||
pos[i][2] =[map_i currentMinZ];
|
pos[i][2] = [map_i currentMinZ];
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (num == 3)
|
if (num == 3)
|
||||||
num = 0;
|
num = 0;
|
||||||
|
|
||||||
|
@ -120,35 +119,32 @@ XYClick
|
||||||
XYDrag
|
XYDrag
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
-(BOOL) XYDrag:(NSPoint *) pt
|
- (BOOL) XYDrag: (NSPoint *)pt
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
if (fabs (pt->x - pos[i][0] > 10) || fabs (pt->y - pos[i][1] > 10))
|
if (fabs (pt->x - pos[i][0] > 10) || fabs (pt->y - pos[i][1] > 10))
|
||||||
continue;
|
continue; // drag this point
|
||||||
// drag this point
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
-ZClick:(NSPoint) pt
|
- (id) ZClick: (NSPoint)pt
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
- (id) carve
|
- (id) carve
|
||||||
{
|
{
|
||||||
[map_i makeSelectedPerform:@selector (carveByClipper)];
|
[map_i makeSelectedPerform: @selector (carveByClipper)];
|
||||||
num = 0;
|
num = 0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) cameraDrawSelf
|
- (void) cameraDrawSelf
|
||||||
{
|
{
|
||||||
vec3_t mid;
|
vec3_t mid;
|
||||||
|
@ -190,9 +186,9 @@ XYDrag
|
||||||
NSString *s = [NSString stringWithFormat: @"%i", i];
|
NSString *s = [NSString stringWithFormat: @"%i", i];
|
||||||
[s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)
|
[s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)
|
||||||
withAttributes: attribs];
|
withAttributes: attribs];
|
||||||
//[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
|
// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
|
||||||
[path appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0],
|
[path
|
||||||
pos[i][1])
|
appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0], pos[i][1])
|
||||||
radius: 10
|
radius: 10
|
||||||
startAngle: 0
|
startAngle: 0
|
||||||
endAngle: 360];
|
endAngle: 360];
|
||||||
|
@ -205,9 +201,7 @@ XYDrag
|
||||||
int i;
|
int i;
|
||||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
[[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
|
[[NSColor colorWithCalibratedRed: 1. green: 0.5 blue: 0. alpha: 1.] set];
|
||||||
set];
|
|
||||||
|
|
||||||
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
|
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
|
||||||
|
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
|
@ -215,9 +209,9 @@ XYDrag
|
||||||
NSString *s = [NSString stringWithFormat: @"%i", i];
|
NSString *s = [NSString stringWithFormat: @"%i", i];
|
||||||
[s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4)
|
[s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4)
|
||||||
withAttributes: attribs];
|
withAttributes: attribs];
|
||||||
//[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
|
// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
|
||||||
[path appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8,
|
[path
|
||||||
pos[i][2])
|
appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8, pos[i][2])
|
||||||
radius: 10
|
radius: 10
|
||||||
startAngle: 0
|
startAngle: 0
|
||||||
endAngle: 360];
|
endAngle: 360];
|
||||||
|
|
|
@ -10,34 +10,34 @@ typedef struct {
|
||||||
char *value;
|
char *value;
|
||||||
} dict_t;
|
} dict_t;
|
||||||
|
|
||||||
@interface Dict:Storage
|
@interface Dict: Storage
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
-initFromFile:(FILE *) fp;
|
- (id) initFromFile: (FILE *)fp;
|
||||||
|
|
||||||
-(id) parseMultipleFrom:(const char *) value;
|
- (id) parseMultipleFrom: (const char *)value;
|
||||||
-(int) getValueUnits:(const char *) key;
|
- (int) getValueUnits: (const char *)key;
|
||||||
-delString:(const char *)string fromValue:(const char *) key;
|
- (id) delString: (const char *)string fromValue: (const char *)key;
|
||||||
|
|
||||||
-addString:(const char *)string toValue:(const char *) key;
|
- (id) addString: (const char *)string toValue: (const char *)key;
|
||||||
|
|
||||||
-(char *) convertListToString:(id) list;
|
- (char *) convertListToString: (id)list;
|
||||||
- (const char *) getStringFor:(const char *) name;
|
- (const char *) getStringFor: (const char *)name;
|
||||||
-removeKeyword:(const char *) key;
|
- (id) removeKeyword: (const char *)key;
|
||||||
-(unsigned int) getValueFor:(const char *) name;
|
- (unsigned int) getValueFor: (const char *)name;
|
||||||
-changeStringFor:(const char *)key to:(const char *) value;
|
- (id) changeStringFor: (const char *)key to: (const char *)value;
|
||||||
|
|
||||||
-(dict_t *) findKeyword:(const char *) key;
|
- (dict_t *) findKeyword: (const char *)key;
|
||||||
|
|
||||||
-writeBlockTo:(FILE *) fp;
|
- (id) writeBlockTo: (FILE *)fp;
|
||||||
-writeFile:(const char *) path;
|
- (id) writeFile: (const char *)path;
|
||||||
|
|
||||||
// INTERNAL
|
// INTERNAL
|
||||||
-init;
|
- (id) init;
|
||||||
-(id) parseBraceBlock:(FILE *) fp;
|
- (id) parseBraceBlock: (FILE *)fp;
|
||||||
-setupMultiple:(const char *) value;
|
- (id) setupMultiple: (const char *)value;
|
||||||
-(char *) getNextParameter;
|
- (char *) getNextParameter;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,20 @@
|
||||||
|
|
||||||
@implementation Dict
|
@implementation Dict
|
||||||
|
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super initCount: 0 elementSize:sizeof (dict_t)
|
[super initCount: 0 elementSize: sizeof (dict_t)
|
||||||
description:NULL];
|
description: NULL];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-print
|
- (id) print
|
||||||
{
|
{
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
for (i = 0; i < numElements; i++) {
|
for (i = 0; i < numElements; i++) {
|
||||||
d =[self elementAt:i];
|
d = [self elementAt: i];
|
||||||
printf ("%s : %s\n", d->key, d->value);
|
printf ("%s : %s\n", d->key, d->value);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -31,16 +31,16 @@ copyFromZone
|
||||||
JDC
|
JDC
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
-copy
|
- (id) copy
|
||||||
{
|
{
|
||||||
id new;
|
id new;
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
char *old;
|
char *old;
|
||||||
|
|
||||||
new =[super copy];
|
new = [super copy];
|
||||||
for (i = 0; i < numElements; i++) {
|
for (i = 0; i < numElements; i++) {
|
||||||
d =[self elementAt:i];
|
d = [self elementAt: i];
|
||||||
old = d->key;
|
old = d->key;
|
||||||
d->key = malloc (strlen (old) + 1);
|
d->key = malloc (strlen (old) + 1);
|
||||||
strcpy (d->key, old);
|
strcpy (d->key, old);
|
||||||
|
@ -53,31 +53,31 @@ JDC
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
-initFromFile:(FILE *) fp
|
- (id) initFromFile: (FILE *)fp
|
||||||
{
|
{
|
||||||
[self init];
|
[self init];
|
||||||
return[self parseBraceBlock:fp];
|
return [self parseBraceBlock: fp];
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
// ===============================================
|
||||||
//
|
//
|
||||||
// Dictionary pair functions
|
// Dictionary pair functions
|
||||||
//
|
//
|
||||||
//===============================================
|
// ===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Write a { } block out to a FILE*
|
// Write a { } block out to a FILE*
|
||||||
//
|
//
|
||||||
-writeBlockTo:(FILE *) fp
|
- (id) writeBlockTo: (FILE *)fp
|
||||||
{
|
{
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
fprintf (fp, "{\n");
|
fprintf (fp, "{\n");
|
||||||
max =[super count];
|
max = [super count];
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
d =[super elementAt:i];
|
d = [super elementAt: i];
|
||||||
fprintf (fp, "\t{\"%s\"\t\"%s\"}\n", d->key, d->value);
|
fprintf (fp, "\t{\"%s\"\t\"%s\"}\n", d->key, d->value);
|
||||||
}
|
}
|
||||||
fprintf (fp, "}\n");
|
fprintf (fp, "}\n");
|
||||||
|
@ -88,7 +88,7 @@ JDC
|
||||||
//
|
//
|
||||||
// Write a single { } block out
|
// Write a single { } block out
|
||||||
//
|
//
|
||||||
-writeFile:(const char *) path
|
- (id) writeFile: (const char *)path
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ JDC
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
printf ("Writing dictionary file %s.\n", path);
|
printf ("Writing dictionary file %s.\n", path);
|
||||||
fprintf (fp, "// QE_Project file %s\n", path);
|
fprintf (fp, "// QE_Project file %s\n", path);
|
||||||
[self writeBlockTo:fp];
|
[self writeBlockTo: fp];
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
} else {
|
} else {
|
||||||
printf ("Error writing %s!\n", path);
|
printf ("Error writing %s!\n", path);
|
||||||
|
@ -106,25 +106,25 @@ JDC
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
// ===============================================
|
||||||
//
|
//
|
||||||
// Utility methods
|
// Utility methods
|
||||||
//
|
//
|
||||||
//===============================================
|
// ===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find a keyword in storage
|
// Find a keyword in storage
|
||||||
// Returns * to dict_t, otherwise NULL
|
// Returns * to dict_t, otherwise NULL
|
||||||
//
|
//
|
||||||
-(dict_t *) findKeyword:(const char *) key
|
- (dict_t *) findKeyword: (const char *)key
|
||||||
{
|
{
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
max =[super count];
|
max = [super count];
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
d =[super elementAt:i];
|
d = [super elementAt: i];
|
||||||
if (!strcmp (d->key, key))
|
if (!strcmp (d->key, key))
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,12 @@ JDC
|
||||||
//
|
//
|
||||||
// Change a keyword's string
|
// Change a keyword's string
|
||||||
//
|
//
|
||||||
-changeStringFor:(const char *) key to:(const char *) value
|
- (id) changeStringFor: (const char *)key to: (const char *)value
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
dict_t newd;
|
dict_t newd;
|
||||||
|
|
||||||
d =[self findKeyword:key];
|
d = [self findKeyword: key];
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
free (d->value);
|
free (d->value);
|
||||||
d->value = malloc (strlen (value) + 1);
|
d->value = malloc (strlen (value) + 1);
|
||||||
|
@ -150,7 +150,7 @@ JDC
|
||||||
strcpy (newd.key, key);
|
strcpy (newd.key, key);
|
||||||
newd.value = malloc (strlen (value) + 1);
|
newd.value = malloc (strlen (value) + 1);
|
||||||
strcpy (newd.value, value);
|
strcpy (newd.value, value);
|
||||||
[self addElement:&newd];
|
[self addElement: &newd];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -158,41 +158,39 @@ JDC
|
||||||
//
|
//
|
||||||
// Search for keyword, return the string *
|
// Search for keyword, return the string *
|
||||||
//
|
//
|
||||||
-(const char *) getStringFor:(const char *) name
|
- (const char *) getStringFor: (const char *)name
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d =[self findKeyword:name];
|
d = [self findKeyword: name];
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
return d->value;
|
return d->value;
|
||||||
|
|
||||||
return (char *) "";
|
return (char *) "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search for keyword, return the value
|
// Search for keyword, return the value
|
||||||
//
|
//
|
||||||
-(unsigned int) getValueFor:(const char *) name
|
- (unsigned int) getValueFor: (const char *)name
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d =[self findKeyword:name];
|
d = [self findKeyword: name];
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
return atol (d->value);
|
return atol (d->value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return # of units in keyword's value
|
// Return # of units in keyword's value
|
||||||
//
|
//
|
||||||
-(int) getValueUnits:(const char *) key
|
- (int) getValueUnits: (const char *)key
|
||||||
{
|
{
|
||||||
id temp;
|
id temp;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
temp =[self parseMultipleFrom:key];
|
temp = [self parseMultipleFrom: key];
|
||||||
count =[temp count];
|
count = [temp count];
|
||||||
[temp release];
|
[temp release];
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
@ -201,17 +199,17 @@ JDC
|
||||||
//
|
//
|
||||||
// Convert List to string
|
// Convert List to string
|
||||||
//
|
//
|
||||||
-(char *) convertListToString:(id) list
|
- (char *) convertListToString: (id)list
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
dstring_t *tempstr;
|
dstring_t *tempstr;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
max =[list count];
|
max = [list count];
|
||||||
tempstr = dstring_newstr ();
|
tempstr = dstring_newstr ();
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
s =[list elementAt:i];
|
s = [list elementAt: i];
|
||||||
dstring_appendstr (tempstr, s);
|
dstring_appendstr (tempstr, s);
|
||||||
dstring_appendstr (tempstr, " ");
|
dstring_appendstr (tempstr, " ");
|
||||||
}
|
}
|
||||||
|
@ -222,21 +220,21 @@ JDC
|
||||||
//
|
//
|
||||||
// JDC: I wrote this to simplify removing vectors
|
// JDC: I wrote this to simplify removing vectors
|
||||||
//
|
//
|
||||||
-removeKeyword:(const char *) key
|
- (id) removeKeyword: (const char *)key
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d =[self findKeyword:key];
|
d = [self findKeyword: key];
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return self;
|
return self;
|
||||||
[self removeElementAt:d - (dict_t *) dataPtr];
|
[self removeElementAt: d - (dict_t *) dataPtr];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Delete string from keyword's value
|
// Delete string from keyword's value
|
||||||
//
|
//
|
||||||
-delString:(const char *) string fromValue:(const char *) key
|
- (id) delString: (const char *)string fromValue: (const char *)key
|
||||||
{
|
{
|
||||||
id temp;
|
id temp;
|
||||||
int count;
|
int count;
|
||||||
|
@ -244,17 +242,17 @@ JDC
|
||||||
char *s;
|
char *s;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d =[self findKeyword:key];
|
d = [self findKeyword: key];
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
temp =[self parseMultipleFrom:key];
|
temp = [self parseMultipleFrom: key];
|
||||||
count =[temp count];
|
count = [temp count];
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
s =[temp elementAt:i];
|
s = [temp elementAt: i];
|
||||||
if (!strcmp (s, string)) {
|
if (!strcmp (s, string)) {
|
||||||
[temp removeElementAt:i];
|
[temp removeElementAt: i];
|
||||||
free (d->value);
|
free (d->value);
|
||||||
d->value =[self convertListToString:temp];
|
d->value = [self convertListToString: temp];
|
||||||
[temp release];
|
[temp release];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -266,12 +264,12 @@ JDC
|
||||||
//
|
//
|
||||||
// Add string to keyword's value
|
// Add string to keyword's value
|
||||||
//
|
//
|
||||||
-addString:(const char *) string toValue:(const char *) key
|
- (id) addString: (const char *)string toValue: (const char *)key
|
||||||
{
|
{
|
||||||
char *newstr;
|
char *newstr;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d =[self findKeyword:key];
|
d = [self findKeyword: key];
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
newstr = nva ("%s\t%s", d->value, string);
|
newstr = nva ("%s\t%s", d->value, string);
|
||||||
|
@ -281,21 +279,21 @@ JDC
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
// ===============================================
|
||||||
//
|
//
|
||||||
// Use these for multiple parameters in a keyword value
|
// Use these for multiple parameters in a keyword value
|
||||||
//
|
//
|
||||||
//===============================================
|
// ===============================================
|
||||||
const char *searchStr;
|
const char *searchStr;
|
||||||
char item[4096];
|
char item[4096];
|
||||||
|
|
||||||
-setupMultiple:(const char *) value
|
- (id) setupMultiple: (const char *)value
|
||||||
{
|
{
|
||||||
searchStr = value;
|
searchStr = value;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(char *) getNextParameter
|
- (char *) getNextParameter
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
@ -303,9 +301,9 @@ char item[4096];
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy (item, searchStr);
|
strcpy (item, searchStr);
|
||||||
s = FindWhitespcInBuffer (item);
|
s = FindWhitespcInBuffer (item);
|
||||||
if (!*s)
|
if (!*s) {
|
||||||
searchStr = NULL;
|
searchStr = NULL;
|
||||||
else {
|
} else {
|
||||||
*s = 0;
|
*s = 0;
|
||||||
searchStr = FindNonwhitespcInBuffer (s + 1);
|
searchStr = FindNonwhitespcInBuffer (s + 1);
|
||||||
}
|
}
|
||||||
|
@ -315,40 +313,39 @@ char item[4096];
|
||||||
//
|
//
|
||||||
// Parses a keyvalue string & returns a Storage full of those items
|
// Parses a keyvalue string & returns a Storage full of those items
|
||||||
//
|
//
|
||||||
-(id) parseMultipleFrom:(const char *) key
|
- (id) parseMultipleFrom: (const char *)key
|
||||||
{
|
{
|
||||||
#define ITEMSIZE 128
|
#define ITEMSIZE 128
|
||||||
id stuff;
|
id stuff;
|
||||||
char string[ITEMSIZE];
|
char string[ITEMSIZE];
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
s =[self getStringFor:key];
|
s = [self getStringFor: key];
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
stuff = [[Storage alloc]
|
||||||
|
initCount: 0 elementSize: ITEMSIZE description: NULL];
|
||||||
|
|
||||||
stuff =[[Storage alloc]
|
[self setupMultiple: s];
|
||||||
initCount: 0 elementSize: ITEMSIZE description:NULL];
|
while ((s = [self getNextParameter])) {
|
||||||
|
|
||||||
[self setupMultiple:s];
|
|
||||||
while ((s =[self getNextParameter])) {
|
|
||||||
bzero (string, ITEMSIZE);
|
bzero (string, ITEMSIZE);
|
||||||
strcpy (string, s);
|
strcpy (string, s);
|
||||||
[stuff addElement:string];
|
[stuff addElement: string];
|
||||||
}
|
}
|
||||||
|
|
||||||
return stuff;
|
return stuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
// ===============================================
|
||||||
//
|
//
|
||||||
// Dictionary pair parsing
|
// Dictionary pair parsing
|
||||||
//
|
//
|
||||||
//===============================================
|
// ===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// parse all keyword/value pairs within { } 's
|
// parse all keyword/value pairs within { } 's
|
||||||
//
|
//
|
||||||
-(id) parseBraceBlock:(FILE *) fp
|
- (id) parseBraceBlock: (FILE *)fp
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
dict_t pair;
|
dict_t pair;
|
||||||
|
@ -357,23 +354,25 @@ char item[4096];
|
||||||
c = FindBrace (fp);
|
c = FindBrace (fp);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while ((c = FindBrace (fp)) != '}') {
|
while ((c = FindBrace (fp)) != '}') {
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
// c = FindNonwhitespc(fp);
|
|
||||||
// if (c == -1)
|
#if 0
|
||||||
// return NULL;
|
c = FindNonwhitespc (fp);
|
||||||
// CopyUntilWhitespc(fp,string);
|
if (c == -1)
|
||||||
|
return NULL;
|
||||||
|
CopyUntilWhitespc (fp, string);
|
||||||
|
#endif
|
||||||
|
|
||||||
// JDC: fixed to allow quoted keys
|
// JDC: fixed to allow quoted keys
|
||||||
c = FindNonwhitespc (fp);
|
c = FindNonwhitespc (fp);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
c = fgetc (fp);
|
c = fgetc (fp);
|
||||||
if (c == '\"')
|
if (c == '\"') {
|
||||||
CopyUntilQuote (fp, string);
|
CopyUntilQuote (fp, string);
|
||||||
else {
|
} else {
|
||||||
ungetc (c, fp);
|
ungetc (c, fp);
|
||||||
CopyUntilWhitespc (fp, string);
|
CopyUntilWhitespc (fp, string);
|
||||||
}
|
}
|
||||||
|
@ -386,7 +385,7 @@ char item[4096];
|
||||||
pair.value = malloc (strlen (string) + 1);
|
pair.value = malloc (strlen (string) + 1);
|
||||||
strcpy (pair.value, string);
|
strcpy (pair.value, string);
|
||||||
|
|
||||||
[super addElement:&pair];
|
[super addElement: &pair];
|
||||||
c = FindBrace (fp);
|
c = FindBrace (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,12 +393,13 @@ char item[4096];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
//===============================================
|
|
||||||
|
// ===============================================
|
||||||
//
|
//
|
||||||
// C routines for string parsing
|
// C routines for string parsing
|
||||||
//
|
//
|
||||||
//===============================================
|
// ===============================================
|
||||||
int
|
int
|
||||||
GetNextChar (FILE * fp)
|
GetNextChar (FILE * fp)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
@ -408,15 +408,18 @@ GetNextChar (FILE * fp)
|
||||||
c = getc (fp);
|
c = getc (fp);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return -1;
|
return -1;
|
||||||
if (c == '/') // parse comments
|
|
||||||
{
|
if (c == '/') { // parse comments
|
||||||
c2 = getc (fp);
|
c2 = getc (fp);
|
||||||
if (c2 == '/') {
|
if (c2 == '/') {
|
||||||
while ((c2 = getc (fp)) != '\n');
|
while ((c2 = getc (fp)) != '\n')
|
||||||
|
;
|
||||||
|
|
||||||
c = getc (fp);
|
c = getc (fp);
|
||||||
} else
|
} else {
|
||||||
ungetc (c2, fp);
|
ungetc (c2, fp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +433,7 @@ CopyUntilWhitespc (FILE * fp, char *buffer)
|
||||||
c = GetNextChar (fp);
|
c = GetNextChar (fp);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (c <= ' ') {
|
if (c <= ' ') {
|
||||||
*buffer = 0;
|
*buffer = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -448,10 +452,12 @@ CopyUntilQuote (FILE * fp, char *buffer)
|
||||||
c = GetNextChar (fp);
|
c = GetNextChar (fp);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (c == '\"') {
|
if (c == '\"') {
|
||||||
*buffer = 0;
|
*buffer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*buffer++ = c;
|
*buffer++ = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,6 +472,7 @@ FindBrace (FILE * fp)
|
||||||
c = GetNextChar (fp);
|
c = GetNextChar (fp);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (c == '{' || c == '}')
|
if (c == '{' || c == '}')
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -480,8 +487,10 @@ FindQuote (FILE * fp)
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
c = GetNextChar (fp);
|
c = GetNextChar (fp);
|
||||||
|
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (c == '\"')
|
if (c == '\"')
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -530,11 +539,12 @@ FindWhitespcInBuffer (char *buffer)
|
||||||
int count = 1000;
|
int count = 1000;
|
||||||
char *b = buffer;
|
char *b = buffer;
|
||||||
|
|
||||||
while (count--)
|
while (count--) {
|
||||||
if (*b <= ' ')
|
if (*b <= ' ')
|
||||||
return b;
|
return b;
|
||||||
else
|
else
|
||||||
b++;
|
b++;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,10 +554,11 @@ FindNonwhitespcInBuffer (char *buffer)
|
||||||
int count = 1000;
|
int count = 1000;
|
||||||
char *b = buffer;
|
char *b = buffer;
|
||||||
|
|
||||||
while (count--)
|
while (count--) {
|
||||||
if (*b > ' ')
|
if (*b > ' ')
|
||||||
return b;
|
return b;
|
||||||
else
|
else
|
||||||
b++;
|
b++;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
@interface DictList:NSMutableArray
|
@interface DictList: NSMutableArray
|
||||||
{
|
{
|
||||||
NSMutableArray *array;
|
NSMutableArray *array;
|
||||||
}
|
}
|
||||||
|
|
||||||
-initListFromFile:(FILE *) fp;
|
- (id) initListFromFile: (FILE *)fp;
|
||||||
-writeListFile:(const char *) filename;
|
- (id) writeListFile: (const char *)filename;
|
||||||
-(id) findDictKeyword:(const char *) key;
|
- (id) findDictKeyword: (const char *)key;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // DictList_h
|
#endif // DictList_h
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include "DictList.h"
|
#include "DictList.h"
|
||||||
#include "Dict.h"
|
#include "Dict.h"
|
||||||
|
|
||||||
|
@ -9,16 +8,16 @@
|
||||||
//
|
//
|
||||||
// Read in variable # of objects from FILE *
|
// Read in variable # of objects from FILE *
|
||||||
//
|
//
|
||||||
- initListFromFile:(FILE *) fp
|
- (id) initListFromFile: (FILE *)fp
|
||||||
{
|
{
|
||||||
id d;
|
id d;
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
array = [[NSMutableArray alloc] init];
|
array = [[NSMutableArray alloc] init];
|
||||||
do {
|
do {
|
||||||
d =[(Dict *)[Dict alloc] initFromFile:fp];
|
d = [(Dict *)[Dict alloc] initFromFile: fp];
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
[self addObject:d];
|
[self addObject: d];
|
||||||
} while (d != NULL);
|
} while (d != NULL);
|
||||||
[d release];
|
[d release];
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@
|
||||||
//
|
//
|
||||||
// Write out list file
|
// Write out list file
|
||||||
//
|
//
|
||||||
-writeListFile:(const char *) filename
|
- (id) writeListFile: (const char *)filename
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
|
@ -37,12 +36,11 @@
|
||||||
fp = fopen (filename, "w+t");
|
fp = fopen (filename, "w+t");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fprintf (fp, "// Object List written by QuakeEd\n");
|
fprintf (fp, "// Object List written by QuakeEd\n");
|
||||||
|
|
||||||
for (i = 0; i <[self count]; i++) {
|
for (i = 0; i < [self count]; i++) {
|
||||||
obj =[self objectAtIndex:i];
|
obj = [self objectAtIndex: i];
|
||||||
[obj writeBlockTo:fp];
|
[obj writeBlockTo: fp];
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
|
@ -52,15 +50,15 @@
|
||||||
//
|
//
|
||||||
// Find the keyword in all the Dict objects
|
// Find the keyword in all the Dict objects
|
||||||
//
|
//
|
||||||
-(id) findDictKeyword:(const char *) key
|
- (id) findDictKeyword: (const char *)key
|
||||||
{
|
{
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
id dict;
|
id dict;
|
||||||
|
|
||||||
for (i = 0; i <[self count]; i++) {
|
for (i = 0; i < [self count]; i++) {
|
||||||
dict =[self objectAtIndex:i];
|
dict = [self objectAtIndex: i];
|
||||||
d =[(Dict *) dict findKeyword:key];
|
d = [(Dict *) dict findKeyword: key];
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,34 +13,34 @@ typedef struct epair_s {
|
||||||
|
|
||||||
// an Entity is a list of brush objects, with additional key / value info
|
// an Entity is a list of brush objects, with additional key / value info
|
||||||
|
|
||||||
@interface Entity:NSMutableArray
|
@interface Entity: NSMutableArray
|
||||||
{
|
{
|
||||||
NSMutableArray *array;
|
NSMutableArray *array;
|
||||||
epair_t *epairs;
|
epair_t *epairs;
|
||||||
BOOL modifiable;
|
BOOL modifiable;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (Entity *) initClass:(const char *) classname;
|
- (Entity *) initClass: (const char *)classname;
|
||||||
- (Entity *) initFromScript: (struct script_s *) script;
|
- (Entity *) initFromScript: (struct script_s *)script;
|
||||||
|
|
||||||
- (oneway void) dealloc;
|
- (oneway void) dealloc;
|
||||||
|
|
||||||
-(BOOL) modifiable;
|
- (BOOL) modifiable;
|
||||||
- (void) setModifiable:(BOOL) m;
|
- (void) setModifiable: (BOOL)m;
|
||||||
|
|
||||||
-(const char *) targetname;
|
- (const char *) targetname;
|
||||||
|
|
||||||
- (void) writeToFILE:(FILE *)f region:(BOOL) reg;
|
- (void) writeToFILE: (FILE *)f region: (BOOL)reg;
|
||||||
|
|
||||||
-(const char *) valueForQKey:(const char *) k;
|
- (const char *) valueForQKey: (const char *)k;
|
||||||
- (void) getVector:(vec3_t)v forKey:(const char *) k;
|
- (void) getVector: (vec3_t)v forKey: (const char *)k;
|
||||||
|
|
||||||
- (void) setKey:(const char *)k
|
- (void) setKey: (const char *)k
|
||||||
toValue:(const char *)v;
|
toValue: (const char *)v;
|
||||||
|
|
||||||
-(int) numPairs;
|
- (int) numPairs;
|
||||||
-(epair_t *) epairs;
|
- (epair_t *) epairs;
|
||||||
- (void) removeKeyPair:(const char *) key;
|
- (void) removeKeyPair: (const char *)key;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // Entity_h
|
#endif // Entity_h
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
@implementation Entity
|
@implementation Entity
|
||||||
|
|
||||||
vec3_t bad_mins = { -8, -8, -8 };
|
vec3_t bad_mins = {-8, -8, -8};
|
||||||
vec3_t bad_maxs = { 8, 8, 8 };
|
vec3_t bad_maxs = {8, 8, 8};
|
||||||
|
|
||||||
-createFixedBrush:(vec3_t) org
|
- (id) createFixedBrush: (vec3_t)org
|
||||||
{
|
{
|
||||||
vec3_t emins, emaxs;
|
vec3_t emins, emaxs;
|
||||||
float *v, *v2, *color;
|
float *v, *v2, *color;
|
||||||
|
@ -26,16 +26,16 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
texturedef_t td;
|
texturedef_t td;
|
||||||
|
|
||||||
// get class
|
// get class
|
||||||
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
|
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
||||||
if (new) {
|
if (new) {
|
||||||
v =[new mins];
|
v = [new mins];
|
||||||
v2 =[new maxs];
|
v2 = [new maxs];
|
||||||
} else {
|
} else {
|
||||||
v = bad_mins;
|
v = bad_mins;
|
||||||
v2 = bad_maxs;
|
v2 = bad_maxs;
|
||||||
}
|
}
|
||||||
|
|
||||||
color =[new drawColor];
|
color = [new drawColor];
|
||||||
|
|
||||||
modifiable = NO;
|
modifiable = NO;
|
||||||
memset (&td, 0, sizeof (td));
|
memset (&td, 0, sizeof (td));
|
||||||
|
@ -43,10 +43,10 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
|
|
||||||
VectorAdd (org, v, emins);
|
VectorAdd (org, v, emins);
|
||||||
VectorAdd (org, v2, emaxs);
|
VectorAdd (org, v2, emaxs);
|
||||||
new =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
new = [[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td];
|
||||||
[new setEntityColor:color];
|
[new setEntityColor: color];
|
||||||
|
|
||||||
[self addObject:new];
|
[self addObject: new];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
[self setKey: "classname" toValue: classname];
|
[self setKey: "classname" toValue: classname];
|
||||||
|
|
||||||
// get class
|
// get class
|
||||||
new = [entity_classes_i classForName: [self valueForQKey:"classname"]];
|
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
||||||
if (!new)
|
if (!new)
|
||||||
esize = esize_model;
|
esize = esize_model;
|
||||||
else
|
else
|
||||||
|
@ -76,16 +76,17 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
// create a brush if needed
|
// create a brush if needed
|
||||||
if (esize == esize_fixed) {
|
if (esize == esize_fixed) {
|
||||||
v = [new mins];
|
v = [new mins];
|
||||||
[[map_i selectedBrush] getMins: min maxs:max];
|
[[map_i selectedBrush] getMins: min maxs: max];
|
||||||
VectorSubtract (min, v, min);
|
VectorSubtract (min, v, min);
|
||||||
VectorCopy (min, org); // convert to integer
|
VectorCopy (min, org);
|
||||||
|
|
||||||
[self setKey:"origin" toValue:va ("%i %i %i", org[0], org[1], org[2])];
|
// convert to integer
|
||||||
|
[self setKey: "origin" toValue: va ("%i %i %i", org[0], org[1], org[2])];
|
||||||
|
|
||||||
[self createFixedBrush: min];
|
[self createFixedBrush: min];
|
||||||
} else
|
} else {
|
||||||
modifiable = YES;
|
modifiable = YES;
|
||||||
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) modifiable
|
- (BOOL) modifiable
|
||||||
{
|
{
|
||||||
return modifiable;
|
return modifiable;
|
||||||
}
|
}
|
||||||
|
@ -114,27 +115,28 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) removeObject: (id)o
|
- (void) removeObject: (id)o
|
||||||
{
|
{
|
||||||
[super removeObject:o];
|
[super removeObject: o];
|
||||||
if ([self count])
|
if ([self count])
|
||||||
return;
|
return;
|
||||||
// the entity is empty, so remove the entire thing
|
|
||||||
if (self ==[map_i objectAtIndex:0])
|
|
||||||
return; // never remove the world
|
|
||||||
|
|
||||||
[map_i removeObject:self];
|
// the entity is empty, so remove the entire thing
|
||||||
|
if (self == [map_i objectAtIndex: 0]) // unless it's the world...
|
||||||
|
return;
|
||||||
|
|
||||||
|
[map_i removeObject: self];
|
||||||
[self release];
|
[self release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (const char *) valueForQKey: (const char *)k
|
||||||
-(const char *) valueForQKey:(const char *) k
|
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
|
|
||||||
for (e = epairs; e; e = e->next)
|
for (e = epairs; e; e = e->next) {
|
||||||
if (!strcmp (k, e->key))
|
if (!strcmp (k, e->key))
|
||||||
return e->value;
|
return e->value;
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +145,13 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
{
|
{
|
||||||
const char *c;
|
const char *c;
|
||||||
|
|
||||||
c =[self valueForQKey:k];
|
c = [self valueForQKey: k];
|
||||||
|
|
||||||
v[0] = v[1] = v[2] = 0;
|
v[0] = v[1] = v[2] = 0;
|
||||||
|
|
||||||
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
|
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
-print
|
- (id) print
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
|
|
||||||
|
@ -160,15 +161,17 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setKey:(const char *)k
|
- (void) setKey: (const char *)k
|
||||||
toValue:(const char *) v
|
toValue: (const char *)v
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
|
|
||||||
while (*k && *k <= ' ')
|
while (*k && *k <= ' ')
|
||||||
k++;
|
k++;
|
||||||
|
|
||||||
|
// don't set NULL values
|
||||||
if (!*k)
|
if (!*k)
|
||||||
return; // don't set NULL values
|
return;
|
||||||
|
|
||||||
for (e = epairs; e; e = e->next) {
|
for (e = epairs; e; e = e->next) {
|
||||||
if (!strcmp (k, e->key)) {
|
if (!strcmp (k, e->key)) {
|
||||||
|
@ -185,7 +188,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
epairs = e;
|
epairs = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(int) numPairs
|
- (int) numPairs
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
|
@ -193,15 +196,16 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
i = 0;
|
i = 0;
|
||||||
for (e = epairs; e; e = e->next)
|
for (e = epairs; e; e = e->next)
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(epair_t *) epairs
|
- (epair_t *) epairs
|
||||||
{
|
{
|
||||||
return epairs;
|
return epairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeKeyPair:(char *) key
|
- (void) removeKeyPair: (char *)key
|
||||||
{
|
{
|
||||||
epair_t *e, *e2;
|
epair_t *e, *e2;
|
||||||
|
|
||||||
|
@ -215,7 +219,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; e; e = e->next) {
|
for ( ; e; e = e->next) {
|
||||||
if (e->next && !strcmp (e->next->key, key)) {
|
if (e->next && !strcmp (e->next->key, key)) {
|
||||||
e2 = e->next;
|
e2 = e->next;
|
||||||
e->next = e2->next;
|
e->next = e2->next;
|
||||||
|
@ -228,7 +232,6 @@ vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
=============
|
||||||
targetname
|
targetname
|
||||||
|
@ -236,23 +239,23 @@ targetname
|
||||||
If the entity does not have a "targetname" key, a unique one is generated
|
If the entity does not have a "targetname" key, a unique one is generated
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
-(const char *) targetname
|
- (const char *) targetname
|
||||||
{
|
{
|
||||||
const char *t;
|
const char *t;
|
||||||
int i, count;
|
int i, count;
|
||||||
id ent;
|
id ent;
|
||||||
int tval, maxt;
|
int tval, maxt;
|
||||||
|
|
||||||
t =[self valueForQKey:"targetname"];
|
t = [self valueForQKey: "targetname"];
|
||||||
if (t && t[0])
|
if (t && t[0])
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
// make a unique name of the form t<number>
|
// make a unique name of the form t<number>
|
||||||
count =[map_i count];
|
count = [map_i count];
|
||||||
maxt = 0;
|
maxt = 0;
|
||||||
for (i = 1; i < count; i++) {
|
for (i = 1; i < count; i++) {
|
||||||
ent =[map_i objectAtIndex:i];
|
ent = [map_i objectAtIndex: i];
|
||||||
t =[ent valueForQKey:"targetname"];
|
t = [ent valueForQKey: "targetname"];
|
||||||
if (!t || t[0] != 't')
|
if (!t || t[0] != 't')
|
||||||
continue;
|
continue;
|
||||||
tval = atoi (t + 1);
|
tval = atoi (t + 1);
|
||||||
|
@ -260,9 +263,9 @@ If the entity does not have a "targetname" key, a unique one is generated
|
||||||
maxt = tval;
|
maxt = tval;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self setKey: "targetname" toValue:va ("t%i", maxt + 1)];
|
[self setKey: "targetname" toValue: va ("t%i", maxt + 1)];
|
||||||
|
|
||||||
return [self valueForQKey:"targetname"];
|
return [self valueForQKey: "targetname"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -275,7 +278,7 @@ FILE METHODS
|
||||||
|
|
||||||
int nument;
|
int nument;
|
||||||
|
|
||||||
- (Entity *) initFromScript:(script_t *) script
|
- (Entity *) initFromScript: (script_t *)script
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
id eclass, brush;
|
id eclass, brush;
|
||||||
|
@ -305,13 +308,13 @@ int nument;
|
||||||
break;
|
break;
|
||||||
if (!strcmp (Script_Token (script), "{")) {
|
if (!strcmp (Script_Token (script), "{")) {
|
||||||
// read a brush
|
// read a brush
|
||||||
brush =[[SetBrush alloc] initFromScript: script owner:self];
|
brush = [[SetBrush alloc] initFromScript: script owner: self];
|
||||||
[self addObject:brush];
|
[self addObject: brush];
|
||||||
} else {
|
} else {
|
||||||
// read a key / value pair
|
// read a key / value pair
|
||||||
key = strdup (Script_Token (script));
|
key = strdup (Script_Token (script));
|
||||||
Script_GetToken (script, false);
|
Script_GetToken (script, false);
|
||||||
[self setKey: key toValue:Script_Token (script)];
|
[self setKey: key toValue: Script_Token (script)];
|
||||||
free (key);
|
free (key);
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
@ -319,12 +322,12 @@ int nument;
|
||||||
nument++;
|
nument++;
|
||||||
|
|
||||||
// get class
|
// get class
|
||||||
spawn =[self valueForQKey:"classname"];
|
spawn = [self valueForQKey: "classname"];
|
||||||
eclass =[entity_classes_i classForName:spawn];
|
eclass = [entity_classes_i classForName: spawn];
|
||||||
|
|
||||||
esize =[eclass esize];
|
esize = [eclass esize];
|
||||||
|
|
||||||
[self getVector: org forKey:"origin"];
|
[self getVector: org forKey: "origin"];
|
||||||
|
|
||||||
if ([self count] && esize != esize_model) {
|
if ([self count] && esize != esize_model) {
|
||||||
printf ("WARNING:Entity with brushes and wrong model type\n");
|
printf ("WARNING:Entity with brushes and wrong model type\n");
|
||||||
|
@ -332,36 +335,38 @@ int nument;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![self count] && esize == esize_model) {
|
if (![self count] && esize == esize_model) {
|
||||||
printf ("WARNING:Entity with no brushes and esize_model: %s\n", [self valueForQKey:"classname"]);
|
printf ("WARNING:Entity with no brushes and esize_model: %s\n",
|
||||||
[texturepalette_i getTextureDef:&td];
|
[self valueForQKey: "classname"]);
|
||||||
|
[texturepalette_i getTextureDef: &td];
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
emins[i] = org[i] - 8;
|
emins[i] = org[i] - 8;
|
||||||
emaxs[i] = org[i] + 8;
|
emaxs[i] = org[i] + 8;
|
||||||
}
|
}
|
||||||
brush =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
brush =
|
||||||
[self addObject:brush];
|
[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td];
|
||||||
|
[self addObject: brush];
|
||||||
}
|
}
|
||||||
// create a brush if needed
|
|
||||||
|
// create a brush if needed
|
||||||
if (esize == esize_fixed)
|
if (esize == esize_fixed)
|
||||||
[self createFixedBrush:org];
|
[self createFixedBrush: org];
|
||||||
else
|
else
|
||||||
modifiable = YES;
|
modifiable = YES;
|
||||||
|
|
||||||
// set all the brush colors
|
// set all the brush colors
|
||||||
color =[eclass drawColor];
|
color = [eclass drawColor];
|
||||||
|
|
||||||
c =[self count];
|
c = [self count];
|
||||||
for (i = 0; i < c; i++) {
|
for (i = 0; i < c; i++) {
|
||||||
brush =[self objectAtIndex:i];
|
brush = [self objectAtIndex: i];
|
||||||
[brush setEntityColor:color];
|
[brush setEntityColor: color];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) writeToFILE: (FILE *)f
|
||||||
- (void) writeToFILE:(FILE *)f
|
region: (BOOL)reg;
|
||||||
region:(BOOL) reg;
|
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
int ang;
|
int ang;
|
||||||
|
@ -373,32 +378,32 @@ int nument;
|
||||||
char *oldang = 0;
|
char *oldang = 0;
|
||||||
|
|
||||||
if (reg) {
|
if (reg) {
|
||||||
if (!strcmp ([self valueForQKey:"classname"], "info_player_start")) {
|
if (!strcmp ([self valueForQKey: "classname"], "info_player_start")) {
|
||||||
// move the playerstart temporarily to the camera position
|
// move the playerstart temporarily to the camera position
|
||||||
oldang = strdup ([self valueForQKey:"angle"]);
|
oldang = strdup ([self valueForQKey: "angle"]);
|
||||||
ang = (int) ([cameraview_i yawAngle] * 180 / M_PI);
|
ang = (int) ([cameraview_i yawAngle] * 180 / M_PI);
|
||||||
[self setKey: "angle" toValue: va ("%i", ang)];
|
[self setKey: "angle" toValue: va ("%i", ang)];
|
||||||
} else if (self != [map_i objectAtIndex:0]
|
} else if (self != [map_i objectAtIndex: 0]
|
||||||
&& [[self objectAtIndex:0] regioned]) {
|
&& [[self objectAtIndex: 0] regioned]) {
|
||||||
return; // skip the entire entity definition
|
return; // skip the entire entity definition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f, "{\n");
|
fprintf (f, "{\n");
|
||||||
|
|
||||||
// set an origin epair
|
// set an origin epair
|
||||||
if (!modifiable) {
|
if (!modifiable) {
|
||||||
[[self objectAtIndex: 0] getMins: mins maxs:maxs];
|
[[self objectAtIndex: 0] getMins: mins maxs: maxs];
|
||||||
if (oldang) {
|
if (oldang) {
|
||||||
[cameraview_i getOrigin:mins];
|
[cameraview_i getOrigin: mins];
|
||||||
mins[0] -= 16;
|
mins[0] -= 16;
|
||||||
mins[1] -= 16;
|
mins[1] -= 16;
|
||||||
mins[2] -= 48;
|
mins[2] -= 48;
|
||||||
}
|
}
|
||||||
new =[entity_classes_i classForName:
|
new = [entity_classes_i classForName:
|
||||||
[self valueForQKey:"classname"]];
|
[self valueForQKey: "classname"]];
|
||||||
if (new)
|
if (new)
|
||||||
v =[new mins];
|
v = [new mins];
|
||||||
else
|
else
|
||||||
v = vec3_origin;
|
v = vec3_origin;
|
||||||
|
|
||||||
|
@ -410,16 +415,16 @@ int nument;
|
||||||
for (e = epairs; e; e = e->next)
|
for (e = epairs; e; e = e->next)
|
||||||
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
|
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
|
||||||
|
|
||||||
// fixed size entities don't save out brushes
|
// fixed size entities don't save out brushes
|
||||||
if (modifiable) {
|
if (modifiable) {
|
||||||
for (i = 0; i <[self count]; i++)
|
for (i = 0; i < [self count]; i++)
|
||||||
[[self objectAtIndex: i] writeToFILE: f region:reg];
|
[[self objectAtIndex: i] writeToFILE: f region: reg];
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f, "}\n");
|
fprintf (f, "}\n");
|
||||||
|
|
||||||
if (oldang) {
|
if (oldang) {
|
||||||
[self setKey: "angle" toValue:oldang];
|
[self setKey: "angle" toValue: oldang];
|
||||||
free (oldang);
|
free (oldang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
#include "QF/mathlib.h"
|
#include "QF/mathlib.h"
|
||||||
|
|
||||||
typedef enum { esize_model, esize_fixed } esize_t;
|
typedef enum {esize_model, esize_fixed} esize_t;
|
||||||
|
|
||||||
#define MAX_FLAGS 8
|
#define MAX_FLAGS 8
|
||||||
|
|
||||||
@interface EntityClass:NSObject
|
@interface EntityClass: NSObject
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
esize_t esize;
|
esize_t esize;
|
||||||
|
@ -19,28 +19,28 @@ typedef enum { esize_model, esize_fixed } esize_t;
|
||||||
char *flagnames[MAX_FLAGS];
|
char *flagnames[MAX_FLAGS];
|
||||||
}
|
}
|
||||||
|
|
||||||
-initFromText:(const char *)text source:(const char *) filename;
|
- (id) initFromText: (const char *)text source: (const char *)filename;
|
||||||
|
|
||||||
-(const char *) classname;
|
- (const char *) classname;
|
||||||
-(esize_t) esize;
|
- (esize_t) esize;
|
||||||
-(float *) mins; // only for esize_fixed
|
- (float *) mins; // only for esize_fixed
|
||||||
-(float *) maxs; // only for esize_fixed
|
- (float *) maxs; // only for esize_fixed
|
||||||
-(float *) drawColor;
|
- (float *) drawColor;
|
||||||
-(const char *) comments;
|
- (const char *) comments;
|
||||||
-(const char *) flagName:(unsigned) flagnum;
|
- (const char *) flagName: (unsigned)flagnum;
|
||||||
|
|
||||||
@end extern id entity_classes_i;
|
@end extern id entity_classes_i;
|
||||||
|
|
||||||
@interface EntityClassList:NSMutableArray
|
@interface EntityClassList: NSMutableArray
|
||||||
{
|
{
|
||||||
NSMutableArray *array;
|
NSMutableArray *array;
|
||||||
id nullclass;
|
id nullclass;
|
||||||
char *source_path;
|
char *source_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
-initForSourceDirectory:(const char *) path;
|
- (id) initForSourceDirectory: (const char *)path;
|
||||||
-(id) classForName:(const char *) name;
|
- (id) classForName: (const char *)name;
|
||||||
-(void) scanDirectory;
|
- (void) scanDirectory;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // EntityClass_h
|
#endif // EntityClass_h
|
||||||
|
|
|
@ -18,11 +18,9 @@ parse_vector (script_t * script, vec3_t vec)
|
||||||
return 0;
|
return 0;
|
||||||
if (strcmp (Script_Token (script), "("))
|
if (strcmp (Script_Token (script), "("))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
|
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
|
||||||
if (r != 3)
|
if (r != 3)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (strcmp (Script_Token (script), ")")) {
|
while (strcmp (Script_Token (script), ")")) {
|
||||||
if (!Script_GetToken (script, 0))
|
if (!Script_GetToken (script, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -38,9 +36,10 @@ parse_vector (script_t * script, vec3_t vec)
|
||||||
//
|
//
|
||||||
// Flag names can follow the size description:
|
// Flag names can follow the size description:
|
||||||
//
|
//
|
||||||
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
|
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY
|
||||||
|
// SILVER_KEY
|
||||||
|
|
||||||
-initFromText:(const char *) text source:(const char *) filename
|
- (id) initFromText: (const char *)text source: (const char *)filename
|
||||||
{
|
{
|
||||||
const char *t;
|
const char *t;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -80,7 +79,6 @@ parse_vector (script_t * script, vec3_t vec)
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the flags
|
// get the flags
|
||||||
// any remaining words on the line are parm flags
|
// any remaining words on the line are parm flags
|
||||||
for (i = 0; i < MAX_FLAGS; i++) {
|
for (i = 0; i < MAX_FLAGS; i++) {
|
||||||
|
@ -105,38 +103,37 @@ parse_vector (script_t * script, vec3_t vec)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(esize_t) esize
|
- (esize_t) esize
|
||||||
{
|
{
|
||||||
return esize;
|
return esize;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) classname
|
- (const char *) classname
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float *) mins
|
- (float *) mins
|
||||||
{
|
{
|
||||||
return mins;
|
return mins;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float *) maxs
|
- (float *) maxs
|
||||||
{
|
{
|
||||||
return maxs;
|
return maxs;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float *) drawColor
|
- (float *) drawColor
|
||||||
{
|
{
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) comments
|
- (const char *) comments
|
||||||
{
|
{
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (const char *) flagName: (unsigned)flagnum
|
||||||
-(const char *) flagName:(unsigned) flagnum
|
|
||||||
{
|
{
|
||||||
if (flagnum >= MAX_FLAGS)
|
if (flagnum >= MAX_FLAGS)
|
||||||
Sys_Error ("EntityClass flagName: bad number");
|
Sys_Error ("EntityClass flagName: bad number");
|
||||||
|
@ -144,7 +141,7 @@ parse_vector (script_t * script, vec3_t vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
//===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
#define THING EntityClassList
|
#define THING EntityClassList
|
||||||
#include "THING+NSArray.m"
|
#include "THING+NSArray.m"
|
||||||
|
@ -155,28 +152,27 @@ parse_vector (script_t * script, vec3_t vec)
|
||||||
insertEC:
|
insertEC:
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
- (void) insertEC:ec
|
- (void) insertEC: ec
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
name =[ec classname];
|
name = [ec classname];
|
||||||
for (i = 0; i <[self count]; i++) {
|
for (i = 0; i < [self count]; i++) {
|
||||||
if (strcasecmp (name,[[self objectAtIndex:i] classname]) < 0) {
|
if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0) {
|
||||||
[self insertObject: ec atIndex:i];
|
[self insertObject: ec atIndex: i];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[self addObject:ec];
|
[self addObject: ec];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
scanFile
|
scanFile
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
-(void) scanFile:(const char *) filename
|
- (void) scanFile: (const char *)filename
|
||||||
{
|
{
|
||||||
int size, line;
|
int size, line;
|
||||||
char *data;
|
char *data;
|
||||||
|
@ -199,10 +195,11 @@ scanFile
|
||||||
line = 1;
|
line = 1;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
if (!strncmp (data + i, "/*QUAKED", 8)) {
|
if (!strncmp (data + i, "/*QUAKED", 8)) {
|
||||||
cl =[[EntityClass alloc] initFromText:(data + i)
|
cl = [[EntityClass alloc]
|
||||||
source:va ("%s:%d", filename, line)];
|
initFromText: (data + i)
|
||||||
|
source: va ("%s:%d", filename, line)];
|
||||||
if (cl)
|
if (cl)
|
||||||
[self insertEC:cl];
|
[self insertEC: cl];
|
||||||
} else if (data[i] == '\n') {
|
} else if (data[i] == '\n') {
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
|
@ -211,13 +208,12 @@ scanFile
|
||||||
free (data);
|
free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
scanDirectory
|
scanDirectory
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
-(void) scanDirectory
|
- (void) scanDirectory
|
||||||
{
|
{
|
||||||
int count, i;
|
int count, i;
|
||||||
struct dirent **namelist, *ent;
|
struct dirent **namelist, *ent;
|
||||||
|
@ -234,45 +230,41 @@ scanDirectory
|
||||||
if (len <= 3)
|
if (len <= 3)
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp (ent->d_name + len - 3, ".qc"))
|
if (!strcmp (ent->d_name + len - 3, ".qc"))
|
||||||
[self scanFile:ent->d_name];
|
[self scanFile: ent->d_name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
id entity_classes_i;
|
id entity_classes_i;
|
||||||
|
|
||||||
|
- (id) initForSourceDirectory: (const char *)path
|
||||||
-initForSourceDirectory:(const char *) path
|
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
array = [[NSMutableArray alloc] init];
|
array = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
source_path = strdup (path); //FIXME leak?
|
source_path = strdup (path); // FIXME leak?
|
||||||
[self scanDirectory];
|
[self scanDirectory];
|
||||||
|
|
||||||
entity_classes_i = self;
|
entity_classes_i = self;
|
||||||
|
|
||||||
nullclass =[[EntityClass alloc]
|
nullclass = [[EntityClass alloc]
|
||||||
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/" source:va ("%s:%d", __FILE__,
|
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/"
|
||||||
__LINE__ -
|
source: va ("%s:%d", __FILE__, __LINE__ - 1)];
|
||||||
1)];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) classForName:(const char *) name
|
- (id) classForName: (const char *)name
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
id o;
|
id o;
|
||||||
|
|
||||||
for (i = 0; i <[self count]; i++) {
|
for (i = 0; i < [self count]; i++) {
|
||||||
o =[self objectAtIndex:i];
|
o = [self objectAtIndex: i];
|
||||||
if (!strcmp (name,[o classname]))
|
if (!strcmp (name, [o classname]))
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullclass;
|
return nullclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -100,10 +100,8 @@ InspectorControl *inspcontrol_i;
|
||||||
NSRect r;
|
NSRect r;
|
||||||
NSRect f;
|
NSRect f;
|
||||||
|
|
||||||
if (which == currentInspectorType) {
|
if (which == currentInspectorType)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
currentInspectorType = which;
|
currentInspectorType = which;
|
||||||
newView = [contentList objectAtIndex: which];
|
newView = [contentList objectAtIndex: which];
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
extern id keypairview_i;
|
extern id keypairview_i;
|
||||||
|
|
||||||
@interface KeypairView:NSView
|
@interface KeypairView: NSView
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
-calcViewSize;
|
- (id) calcViewSize;
|
||||||
|
|
||||||
#define SPACING 4
|
#define SPACING 4
|
||||||
#define FONTSIZE 12
|
#define FONTSIZE 12
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include "KeypairView.h"
|
#include "KeypairView.h"
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
@ -12,20 +11,19 @@ id keypairview_i;
|
||||||
initWithFrame:
|
initWithFrame:
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
- initWithFrame:(NSRect) frameRect
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame: frameRect];
|
||||||
keypairview_i = self;
|
keypairview_i = self;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) isFlipped
|
- (BOOL) isFlipped
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) calcViewSize
|
||||||
-calcViewSize
|
|
||||||
{
|
{
|
||||||
NSRect b;
|
NSRect b;
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
|
@ -37,13 +35,13 @@ initWithFrame:
|
||||||
|
|
||||||
b = [[self superview] bounds];
|
b = [[self superview] bounds];
|
||||||
b.size.height = LINEHEIGHT * count + SPACING;
|
b.size.height = LINEHEIGHT * count + SPACING;
|
||||||
[self setFrameSize:b.size];
|
[self setFrameSize: b.size];
|
||||||
pt.x = pt.y = 0;
|
pt.x = pt.y = 0;
|
||||||
[self scrollPoint:pt];
|
[self scrollPoint: pt];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-drawRect: (NSRect) rects
|
- (id) drawRect: (NSRect)rects
|
||||||
{
|
{
|
||||||
epair_t *pair;
|
epair_t *pair;
|
||||||
int y;
|
int y;
|
||||||
|
@ -55,11 +53,12 @@ initWithFrame:
|
||||||
[[NSFont systemFontOfSize: FONTSIZE] set];
|
[[NSFont systemFontOfSize: FONTSIZE] set];
|
||||||
[[NSColor blackColor] set];
|
[[NSColor blackColor] set];
|
||||||
|
|
||||||
pair =[[map_i currentEntity] epairs];
|
pair = [[map_i currentEntity] epairs];
|
||||||
y = _bounds.size.height - LINEHEIGHT;
|
y = _bounds.size.height - LINEHEIGHT;
|
||||||
for (; pair; pair = pair->next) {
|
for ( ; pair; pair = pair->next) {
|
||||||
NSString *key = [NSString stringWithCString: pair->key];
|
NSString *key = [NSString stringWithCString: pair->key];
|
||||||
NSString *value = [NSString stringWithCString: pair->value];
|
NSString *value = [NSString stringWithCString: pair->value];
|
||||||
|
|
||||||
[key drawAtPoint: NSMakePoint (SPACING, y) withAttributes: attribs];
|
[key drawAtPoint: NSMakePoint (SPACING, y) withAttributes: attribs];
|
||||||
[value drawAtPoint: NSMakePoint (100, y) withAttributes: attribs];
|
[value drawAtPoint: NSMakePoint (100, y) withAttributes: attribs];
|
||||||
y -= LINEHEIGHT;
|
y -= LINEHEIGHT;
|
||||||
|
@ -68,18 +67,18 @@ initWithFrame:
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) mouseDown:(NSEvent *) theEvent
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint loc;
|
NSPoint loc;
|
||||||
int i;
|
int i;
|
||||||
epair_t *p;
|
epair_t *p;
|
||||||
|
|
||||||
loc =[theEvent locationInWindow];
|
loc = [theEvent locationInWindow];
|
||||||
loc =[self convertPoint: loc fromView:NULL];
|
loc = [self convertPoint: loc fromView: NULL];
|
||||||
|
|
||||||
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
|
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
|
||||||
|
|
||||||
p =[[map_i currentEntity] epairs];
|
p = [[map_i currentEntity] epairs];
|
||||||
while (i) {
|
while (i) {
|
||||||
p = p->next;
|
p = p->next;
|
||||||
if (!p)
|
if (!p)
|
||||||
|
@ -87,7 +86,7 @@ initWithFrame:
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
if (p)
|
if (p)
|
||||||
[things_i setSelectedKey:p];
|
[things_i setSelectedKey: p];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
extern id map_i;
|
extern id map_i;
|
||||||
|
|
||||||
@interface Map:NSMutableArray
|
@interface Map: NSMutableArray
|
||||||
{
|
{
|
||||||
NSMutableArray *array;
|
NSMutableArray *array;
|
||||||
id currentEntity;
|
id currentEntity;
|
||||||
|
@ -17,60 +17,60 @@ extern id map_i;
|
||||||
float minz, maxz;
|
float minz, maxz;
|
||||||
}
|
}
|
||||||
|
|
||||||
-newMap;
|
- (id) newMap;
|
||||||
|
|
||||||
-writeStats;
|
- (id) writeStats;
|
||||||
|
|
||||||
-readMapFile:(const char *) fname;
|
- (id) readMapFile: (const char *)fname;
|
||||||
-writeMapFile:(const char *)fname useRegion:(BOOL) reg;
|
- (id) writeMapFile: (const char *)fname useRegion: (BOOL)reg;
|
||||||
|
|
||||||
-entityConnect: (vec3_t) p1:(vec3_t) p2;
|
- (id) entityConnect: (vec3_t)p1: (vec3_t)p2;
|
||||||
|
|
||||||
-selectRay: (vec3_t) p1: (vec3_t) p2:(BOOL) ef;
|
- (id) selectRay: (vec3_t)p1: (vec3_t)p2: (BOOL)ef;
|
||||||
-grabRay: (vec3_t) p1:(vec3_t) p2;
|
- (id) grabRay: (vec3_t)p1: (vec3_t)p2;
|
||||||
-setTextureRay: (vec3_t) p1: (vec3_t) p2:(BOOL) allsides;
|
- (id) setTextureRay: (vec3_t)p1: (vec3_t)p2: (BOOL)allsides;
|
||||||
-getTextureRay: (vec3_t) p1:(vec3_t) p2;
|
- (id) getTextureRay: (vec3_t)p1: (vec3_t)p2;
|
||||||
|
|
||||||
-currentEntity;
|
- (id) currentEntity;
|
||||||
-setCurrentEntity:ent;
|
- (id) setCurrentEntity: ent;
|
||||||
|
|
||||||
-(float) currentMinZ;
|
- (float) currentMinZ;
|
||||||
-setCurrentMinZ:(float) m;
|
- (id) setCurrentMinZ: (float)m;
|
||||||
-(float) currentMaxZ;
|
- (float) currentMaxZ;
|
||||||
-setCurrentMaxZ:(float) m;
|
- (id) setCurrentMaxZ: (float)m;
|
||||||
|
|
||||||
-(int) numSelected;
|
- (int) numSelected;
|
||||||
-selectedBrush; // returns the first selected brush
|
- (id) selectedBrush; // returns the first selected brush
|
||||||
|
|
||||||
//
|
//
|
||||||
// operations on current selection
|
// operations on current selection
|
||||||
//
|
//
|
||||||
-makeSelectedPerform:(SEL) sel;
|
- (id) makeSelectedPerform: (SEL)sel;
|
||||||
-makeUnselectedPerform:(SEL) sel;
|
- (id) makeUnselectedPerform: (SEL)sel;
|
||||||
-makeAllPerform:(SEL) sel;
|
- (id) makeAllPerform: (SEL)sel;
|
||||||
-makeGlobalPerform:(SEL) sel; // in and out of region
|
- (id) makeGlobalPerform: (SEL)sel; // in and out of region
|
||||||
|
|
||||||
-cloneSelection:sender;
|
- (id) cloneSelection: sender;
|
||||||
|
|
||||||
-makeEntity:sender;
|
- (id) makeEntity: sender;
|
||||||
|
|
||||||
-subtractSelection:sender;
|
- (id) subtractSelection: sender;
|
||||||
|
|
||||||
-selectCompletelyInside:sender;
|
- (id) selectCompletelyInside: sender;
|
||||||
-selectPartiallyInside:sender;
|
- (id) selectPartiallyInside: sender;
|
||||||
|
|
||||||
-tallBrush:sender;
|
- (id) tallBrush: sender;
|
||||||
-shortBrush:sender;
|
- (id) shortBrush: sender;
|
||||||
|
|
||||||
-rotate_x:sender;
|
- (id) rotate_x: sender;
|
||||||
-rotate_y:sender;
|
- (id) rotate_y: sender;
|
||||||
-rotate_z:sender;
|
- (id) rotate_z: sender;
|
||||||
|
|
||||||
-flip_x:sender;
|
- (id) flip_x: sender;
|
||||||
-flip_y:sender;
|
- (id) flip_y: sender;
|
||||||
-flip_z:sender;
|
- (id) flip_z: sender;
|
||||||
|
|
||||||
-selectCompleteEntity:sender;
|
- (id) selectCompleteEntity: sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,15 +3,16 @@
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
@interface PopScrollView:NSScrollView
|
@interface PopScrollView: NSScrollView
|
||||||
{
|
{
|
||||||
id button1, button2;
|
id button1, button2;
|
||||||
}
|
}
|
||||||
|
|
||||||
-initWithFrame:(NSRect)
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
frameRect button1:b1 button2:b2;
|
button1: b1
|
||||||
|
button2: b2;
|
||||||
|
|
||||||
-tile;
|
- (id) tile;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // PopScrollView_h
|
#endif // PopScrollView_h
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include "PopScrollView.h"
|
#include "PopScrollView.h"
|
||||||
|
|
||||||
@implementation PopScrollView
|
@implementation PopScrollView
|
||||||
|
@ -9,23 +8,26 @@ initWithFrame: button:
|
||||||
Initizes a scroll view with a button at it's lower right corner
|
Initizes a scroll view with a button at it's lower right corner
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
- initWithFrame:(NSRect)
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
frameRect button1:b1 button2:b2 {
|
button1: b1
|
||||||
[super initWithFrame:frameRect];
|
button2: b2
|
||||||
|
{
|
||||||
|
[super initWithFrame: frameRect];
|
||||||
|
|
||||||
[self addSubview:b1];
|
[self addSubview: b1];
|
||||||
[self addSubview:b2];
|
[self addSubview: b2];
|
||||||
|
|
||||||
button1 = b1;
|
button1 = b1;
|
||||||
button2 = b2;
|
button2 = b2;
|
||||||
|
|
||||||
[self setHasHorizontalScroller:YES];
|
[self setHasHorizontalScroller: YES];
|
||||||
[self setHasVerticalScroller:YES];
|
[self setHasVerticalScroller: YES];
|
||||||
|
|
||||||
[self setBorderType:NSBezelBorder];
|
[self setBorderType: NSBezelBorder];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
tile
|
tile
|
||||||
|
@ -33,35 +35,36 @@ tile
|
||||||
Adjust the size for the pop up scale menu
|
Adjust the size for the pop up scale menu
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
-tile
|
- (id) tile
|
||||||
{
|
{
|
||||||
NSRect scrollerframe;
|
NSRect scrollerframe;
|
||||||
NSRect buttonframe, buttonframe2;
|
NSRect buttonframe, buttonframe2;
|
||||||
NSRect newframe;
|
NSRect newframe;
|
||||||
|
|
||||||
[super tile];
|
[super tile];
|
||||||
buttonframe =[button1 frame];
|
buttonframe = [button1 frame];
|
||||||
buttonframe2 =[button2 frame];
|
buttonframe2 = [button2 frame];
|
||||||
scrollerframe =[_horizScroller frame];
|
scrollerframe = [_horizScroller frame];
|
||||||
|
|
||||||
newframe.origin.y = scrollerframe.origin.y;
|
newframe.origin.y = scrollerframe.origin.y;
|
||||||
newframe.origin.x = scrollerframe.origin.x + scrollerframe.size.width - buttonframe.size.width;
|
newframe.origin.x = scrollerframe.origin.x + scrollerframe.size.width -
|
||||||
|
buttonframe.size.width;
|
||||||
newframe.size.width = buttonframe.size.width;
|
newframe.size.width = buttonframe.size.width;
|
||||||
newframe.size.height = scrollerframe.size.height;
|
newframe.size.height = scrollerframe.size.height;
|
||||||
scrollerframe.size.width -= newframe.size.width;
|
scrollerframe.size.width -= newframe.size.width;
|
||||||
[button1 setFrame:newframe];
|
[button1 setFrame: newframe];
|
||||||
newframe.size.width = buttonframe2.size.width;
|
newframe.size.width = buttonframe2.size.width;
|
||||||
newframe.origin.x -= newframe.size.width;
|
newframe.origin.x -= newframe.size.width;
|
||||||
[button2 setFrame:newframe];
|
[button2 setFrame: newframe];
|
||||||
scrollerframe.size.width -= newframe.size.width;
|
scrollerframe.size.width -= newframe.size.width;
|
||||||
|
|
||||||
[_horizScroller setFrame:scrollerframe];
|
[_horizScroller setFrame: scrollerframe];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- superviewSizeChanged:(const NSSize *)oldSize
|
- (id) superviewSizeChanged: (const NSSize *)oldSize
|
||||||
{
|
{
|
||||||
[super superviewSizeChanged: oldSize];
|
[super superviewSizeChanged: oldSize];
|
||||||
|
|
||||||
|
@ -71,11 +74,9 @@ Adjust the size for the pop up scale menu
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
-(BOOL) acceptsFirstResponder
|
- (BOOL) acceptsFirstResponder
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -10,7 +10,7 @@ extern float lightaxis[3];
|
||||||
// these are personal preferences saved in NeXT defaults, not project
|
// these are personal preferences saved in NeXT defaults, not project
|
||||||
// parameters saved in the quake.qe_project file
|
// parameters saved in the quake.qe_project file
|
||||||
|
|
||||||
@interface Preferences:NSObject
|
@interface Preferences: NSObject
|
||||||
{
|
{
|
||||||
id bspSound_i; // actual sound object
|
id bspSound_i; // actual sound object
|
||||||
|
|
||||||
|
@ -44,43 +44,41 @@ extern float lightaxis[3];
|
||||||
NSUserDefaults *prefs;
|
NSUserDefaults *prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
-readDefaults;
|
- (id) readDefaults;
|
||||||
|
|
||||||
//
|
//
|
||||||
// validate and set methods called by UI or defaults
|
// validate and set methods called by UI or defaults
|
||||||
//
|
//
|
||||||
-setProjectPath:(const char *) path;
|
- (id) setProjectPath: (const char *)path;
|
||||||
-setBspSoundPath:(const char *) path; // set the path of the soundfile
|
- (id) setBspSoundPath: (const char *)path; // set the path of the soundfile
|
||||||
// externally
|
- (id) setShowBSP: (int)state; // set the state of ShowBSP
|
||||||
-setShowBSP:(int) state; // set the state of ShowBSP
|
- (id) setBrushOffset: (int)state; // set the state of BrushOffset
|
||||||
-setBrushOffset:(int) state; // set the state of BrushOffset
|
- (id) setStartWad: (int)value; // set start wad (0-2)
|
||||||
-setStartWad:(int) value; // set start wad (0-2)
|
- (id) setXlight: (float)value; // set Xlight value for CameraView
|
||||||
-setXlight:(float) value; // set Xlight value for CameraView
|
- (id) setYlight: (float)value; // set Ylight value for CameraView
|
||||||
-setYlight:(float) value; // set Ylight value for CameraView
|
- (id) setZlight: (float)value; // set Zlight value for CameraView
|
||||||
-setZlight:(float) value; // set Zlight value for CameraView
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// UI targets
|
// UI targets
|
||||||
//
|
//
|
||||||
-setBspSound:sender; // use OpenPanel to select sound
|
- (id) setBspSound: sender; // use OpenPanel to select sound
|
||||||
-setCurrentProject:sender; // make current roject the default
|
- (id) setCurrentProject: sender; // make current project the default
|
||||||
-UIChanged:sender; // target for all checks and fields
|
- (id) UIChanged: sender; // target for all checks and fields
|
||||||
|
|
||||||
//
|
//
|
||||||
// methods used by other objects to retreive defaults
|
// methods used by other objects to retreive defaults
|
||||||
//
|
//
|
||||||
-playBspSound;
|
- (id) playBspSound;
|
||||||
|
|
||||||
-(const char *) getProjectPath;
|
- (const char *) getProjectPath;
|
||||||
-(int) getBrushOffset; // get the state
|
- (int) getBrushOffset; // get the state
|
||||||
-(int) getShowBSP; // get the state
|
- (int) getShowBSP; // get the state
|
||||||
|
|
||||||
-(float) getXlight; // get Xlight value
|
- (float) getXlight; // get Xlight value
|
||||||
-(float) getYlight; // get Ylight value
|
- (float) getYlight; // get Ylight value
|
||||||
-(float) getZlight; // get Zlight value
|
- (float) getZlight; // get Zlight value
|
||||||
|
|
||||||
-(int) getStartWad;
|
|
||||||
|
|
||||||
|
- (int) getStartWad;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // Preferences_h
|
#endif // Preferences_h
|
||||||
|
|
|
@ -12,7 +12,7 @@ id preferences_i;
|
||||||
|
|
||||||
#define DEFOWNER "QuakeEd2"
|
#define DEFOWNER "QuakeEd2"
|
||||||
|
|
||||||
float lightaxis[3] = { 1, 0.6, 0.75 };
|
float lightaxis[3] = {1, 0.6, 0.75};
|
||||||
|
|
||||||
@implementation Preferences
|
@implementation Preferences
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ WriteStringDefault (id prefs, const char *name, const char *value)
|
||||||
{
|
{
|
||||||
NSString *key = [NSString stringWithCString: name];
|
NSString *key = [NSString stringWithCString: name];
|
||||||
NSString *val = [NSString stringWithCString: value];
|
NSString *val = [NSString stringWithCString: value];
|
||||||
[prefs setObject:val forKey:key];
|
|
||||||
|
[prefs setObject: val forKey: key];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -30,7 +31,7 @@ WriteNumericDefault (id prefs, const char *name, float value)
|
||||||
WriteStringDefault (prefs, name, va ("%f", value));
|
WriteStringDefault (prefs, name, va ("%f", value));
|
||||||
}
|
}
|
||||||
|
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
preferences_i = self;
|
preferences_i = self;
|
||||||
|
@ -47,7 +48,7 @@ WriteNumericDefault (id prefs, const char *name, float value)
|
||||||
WriteNumericDefault (defaults, "Zlight", 0);
|
WriteNumericDefault (defaults, "Zlight", 0);
|
||||||
|
|
||||||
prefs = [[NSUserDefaults standardUserDefaults] retain];
|
prefs = [[NSUserDefaults standardUserDefaults] retain];
|
||||||
[prefs registerDefaults:defaults];
|
[prefs registerDefaults: defaults];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +57,7 @@ _atoi (const char *c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return atoi (c);
|
return atoi (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,86 +66,87 @@ _atof (const char *c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return atof (c);
|
return atof (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read in at start of program
|
// Read in at start of program
|
||||||
//
|
//
|
||||||
-readDefaults
|
- (id) readDefaults
|
||||||
{
|
{
|
||||||
const char *string;
|
const char *string;
|
||||||
float value = 0;
|
float value = 0;
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"ProjectPath"] cString];
|
string = [[prefs stringForKey: @"ProjectPath"] cString];
|
||||||
[self setProjectPath:string];
|
[self setProjectPath: string];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"BspSoundPath"] cString];
|
string = [[prefs stringForKey: @"BspSoundPath"] cString];
|
||||||
[self setBspSoundPath:string];
|
[self setBspSoundPath: string];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"ShowBSPOutput"] cString];
|
string = [[prefs stringForKey: @"ShowBSPOutput"] cString];
|
||||||
value = _atoi (string);
|
value = _atoi (string);
|
||||||
[self setShowBSP:value];
|
[self setShowBSP: value];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"OffsetBrushCopy"] cString];
|
string = [[prefs stringForKey: @"OffsetBrushCopy"] cString];
|
||||||
value = _atoi (string);
|
value = _atoi (string);
|
||||||
[self setBrushOffset:value];
|
[self setBrushOffset: value];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"StartWad"] cString];
|
string = [[prefs stringForKey: @"StartWad"] cString];
|
||||||
value = _atoi (string);
|
value = _atoi (string);
|
||||||
[self setStartWad:value];
|
[self setStartWad: value];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"Xlight"] cString];
|
string = [[prefs stringForKey: @"Xlight"] cString];
|
||||||
value = _atof (string);
|
value = _atof (string);
|
||||||
[self setXlight:value];
|
[self setXlight: value];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"Ylight"] cString];
|
string = [[prefs stringForKey: @"Ylight"] cString];
|
||||||
value = _atof (string);
|
value = _atof (string);
|
||||||
[self setYlight:value];
|
[self setYlight: value];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"Zlight"] cString];
|
string = [[prefs stringForKey: @"Zlight"] cString];
|
||||||
value = _atof (string);
|
value = _atof (string);
|
||||||
[self setZlight:value];
|
[self setZlight: value];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) setProjectPath: (const char *)path
|
||||||
-setProjectPath:(const char *) path
|
|
||||||
{
|
{
|
||||||
if (!path)
|
if (!path)
|
||||||
path = "";
|
path = "";
|
||||||
|
|
||||||
strcpy (projectpath, path);
|
strcpy (projectpath, path);
|
||||||
[startproject_i setStringValue: [NSString stringWithCString:path]];
|
[startproject_i setStringValue: [NSString stringWithCString: path]];
|
||||||
WriteStringDefault (prefs, "ProjectPath", path);
|
WriteStringDefault (prefs, "ProjectPath", path);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setCurrentProject:sender
|
- (id) setCurrentProject: sender
|
||||||
{
|
{
|
||||||
[startproject_i setStringValue: [NSString stringWithCString:[project_i
|
[startproject_i setStringValue: [NSString stringWithCString: [project_i
|
||||||
currentProjectFile]]];
|
currentProjectFile
|
||||||
[self UIChanged:self];
|
]]];
|
||||||
|
[self UIChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) getProjectPath
|
- (const char *) getProjectPath
|
||||||
{
|
{
|
||||||
return projectpath;
|
return projectpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//===============================================
|
// ===============================================
|
||||||
// BSP sound stuff
|
// BSP sound stuff
|
||||||
//===============================================
|
// ===============================================
|
||||||
//
|
//
|
||||||
// Set the BSP sound using an OpenPanel
|
// Set the BSP sound using an OpenPanel
|
||||||
//
|
//
|
||||||
-setBspSound:sender
|
- (id) setBspSound: sender
|
||||||
{
|
{
|
||||||
id panel;
|
id panel;
|
||||||
NSString *types[] = { @"snd" };
|
NSString *types[] = {@"snd"};
|
||||||
int rtn;
|
int rtn;
|
||||||
NSArray *filenames;
|
NSArray *filenames;
|
||||||
char path[1024], file[64];
|
char path[1024], file[64];
|
||||||
|
@ -153,37 +156,36 @@ _atof (const char *c)
|
||||||
// XXX ExtractFilePath (bspSound, path);
|
// XXX ExtractFilePath (bspSound, path);
|
||||||
// XXX ExtractFileBase (bspSound, file);
|
// XXX ExtractFileBase (bspSound, file);
|
||||||
|
|
||||||
rtn = [panel runModalForDirectory: [NSString stringWithCString:path]
|
rtn = [panel runModalForDirectory: [NSString stringWithCString: path]
|
||||||
file: [NSString stringWithCString:file]
|
file: [NSString stringWithCString: file]
|
||||||
types: [NSArray arrayWithObjects: types count:1]];
|
types: [NSArray arrayWithObjects: types count: 1]
|
||||||
|
];
|
||||||
|
|
||||||
if (rtn) {
|
if (rtn) {
|
||||||
filenames =[panel filenames];
|
filenames = [panel filenames];
|
||||||
strcpy (bspSound,[[panel directory] cString]);
|
strcpy (bspSound, [[panel directory] cString]);
|
||||||
strcat (bspSound, "/");
|
strcat (bspSound, "/");
|
||||||
strcat (bspSound,[[filenames objectAtIndex:0] cString]);
|
strcat (bspSound, [[filenames objectAtIndex: 0] cString]);
|
||||||
[self setBspSoundPath:bspSound];
|
[self setBspSoundPath: bspSound];
|
||||||
[self playBspSound];
|
[self playBspSound];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Play the BSP sound
|
// Play the BSP sound
|
||||||
//
|
//
|
||||||
-playBspSound
|
- (id) playBspSound
|
||||||
{
|
{
|
||||||
[bspSound_i play];
|
[bspSound_i play];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the bspSound path
|
// Set the bspSound path
|
||||||
//
|
//
|
||||||
-setBspSoundPath:(const char *) path
|
- (id) setBspSoundPath: (const char *)path
|
||||||
{
|
{
|
||||||
if (!path)
|
if (!path)
|
||||||
path = "";
|
path = "";
|
||||||
|
@ -193,30 +195,32 @@ _atof (const char *c)
|
||||||
[bspSound_i release];
|
[bspSound_i release];
|
||||||
bspSound_i = nil;
|
bspSound_i = nil;
|
||||||
}
|
}
|
||||||
if (path[0] && access (path, R_OK))
|
if (path[0] && access (path, R_OK)) {
|
||||||
bspSound_i =[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:bspSound] byReference: YES];
|
bspSound_i =
|
||||||
if (!bspSound_i) {
|
[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:
|
||||||
return self;
|
bspSound] byReference: YES];
|
||||||
}
|
}
|
||||||
|
if (!bspSound_i)
|
||||||
|
return self;
|
||||||
|
|
||||||
[bspSoundField_i setStringValue: [NSString stringWithCString:bspSound]];
|
[bspSoundField_i setStringValue: [NSString stringWithCString: bspSound]];
|
||||||
|
|
||||||
WriteStringDefault (prefs, "BspSoundPath", bspSound);
|
WriteStringDefault (prefs, "BspSoundPath", bspSound);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
// ===============================================
|
||||||
// Show BSP Output management
|
// Show BSP Output management
|
||||||
//===============================================
|
// ===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the state
|
// Set the state
|
||||||
//
|
//
|
||||||
-setShowBSP:(int) state
|
- (id) setShowBSP: (int)state
|
||||||
{
|
{
|
||||||
showBSP = state;
|
showBSP = state;
|
||||||
[showBSP_i setIntValue:state];
|
[showBSP_i setIntValue: state];
|
||||||
WriteNumericDefault (prefs, "ShowBSPOutput", showBSP);
|
WriteNumericDefault (prefs, "ShowBSPOutput", showBSP);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -225,23 +229,22 @@ _atof (const char *c)
|
||||||
//
|
//
|
||||||
// Get the state
|
// Get the state
|
||||||
//
|
//
|
||||||
-(int) getShowBSP
|
- (int) getShowBSP
|
||||||
{
|
{
|
||||||
return showBSP;
|
return showBSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===============================================
|
||||||
//===============================================
|
|
||||||
// "Offset Brush ..." management
|
// "Offset Brush ..." management
|
||||||
//===============================================
|
// ===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the state
|
// Set the state
|
||||||
//
|
//
|
||||||
-setBrushOffset:(int) state
|
- (id) setBrushOffset: (int)state
|
||||||
{
|
{
|
||||||
brushOffset = state;
|
brushOffset = state;
|
||||||
[brushOffset_i setIntValue:state];
|
[brushOffset_i setIntValue: state];
|
||||||
WriteNumericDefault (prefs, "OffsetBrushCopy", state);
|
WriteNumericDefault (prefs, "OffsetBrushCopy", state);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -249,68 +252,67 @@ _atof (const char *c)
|
||||||
//
|
//
|
||||||
// Get the state
|
// Get the state
|
||||||
//
|
//
|
||||||
-(int) getBrushOffset
|
- (int) getBrushOffset
|
||||||
{
|
{
|
||||||
return brushOffset;
|
return brushOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
// ===============================================
|
||||||
// StartWad
|
// StartWad
|
||||||
//===============================================
|
// ===============================================
|
||||||
|
|
||||||
-setStartWad:(int) value // set start wad (0-2)
|
- (id) setStartWad: (int)value // set start wad (0-2)
|
||||||
{
|
{
|
||||||
startwad = value;
|
startwad = value;
|
||||||
if (startwad < 0 || startwad > 2)
|
if (startwad < 0 || startwad > 2)
|
||||||
startwad = 0;
|
startwad = 0;
|
||||||
|
|
||||||
[startwad_i selectCellAtRow: startwad column:0];
|
[startwad_i selectCellAtRow: startwad column: 0];
|
||||||
|
|
||||||
WriteNumericDefault (prefs, "StartWad", value);
|
WriteNumericDefault (prefs, "StartWad", value);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(int) getStartWad
|
- (int) getStartWad
|
||||||
{
|
{
|
||||||
return startwad;
|
return startwad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===============================================
|
||||||
//===============================================
|
|
||||||
// X,Y,Z light values
|
// X,Y,Z light values
|
||||||
//===============================================
|
// ===============================================
|
||||||
//
|
//
|
||||||
// Set the state
|
// Set the state
|
||||||
//
|
//
|
||||||
-setXlight:(float) value
|
- (id) setXlight: (float)value
|
||||||
{
|
{
|
||||||
xlight = value;
|
xlight = value;
|
||||||
if (xlight < 0.25 || xlight > 1)
|
if (xlight < 0.25 || xlight > 1)
|
||||||
xlight = 0.6;
|
xlight = 0.6;
|
||||||
lightaxis[1] = xlight;
|
lightaxis[1] = xlight;
|
||||||
[xlight_i setFloatValue:xlight];
|
[xlight_i setFloatValue: xlight];
|
||||||
WriteNumericDefault (prefs, "Xlight", xlight);
|
WriteNumericDefault (prefs, "Xlight", xlight);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setYlight:(float) value
|
- (id) setYlight: (float)value
|
||||||
{
|
{
|
||||||
ylight = value;
|
ylight = value;
|
||||||
if (ylight < 0.25 || ylight > 1)
|
if (ylight < 0.25 || ylight > 1)
|
||||||
ylight = 0.75;
|
ylight = 0.75;
|
||||||
lightaxis[2] = ylight;
|
lightaxis[2] = ylight;
|
||||||
[ylight_i setFloatValue:ylight];
|
[ylight_i setFloatValue: ylight];
|
||||||
WriteNumericDefault (prefs, "Ylight", ylight);
|
WriteNumericDefault (prefs, "Ylight", ylight);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setZlight:(float) value
|
- (id) setZlight: (float)value
|
||||||
{
|
{
|
||||||
zlight = value;
|
zlight = value;
|
||||||
if (zlight < 0.25 || zlight > 1)
|
if (zlight < 0.25 || zlight > 1)
|
||||||
zlight = 1;
|
zlight = 1;
|
||||||
lightaxis[0] = zlight;
|
lightaxis[0] = zlight;
|
||||||
[zlight_i setFloatValue:zlight];
|
[zlight_i setFloatValue: zlight];
|
||||||
WriteNumericDefault (prefs, "Zlight", zlight);
|
WriteNumericDefault (prefs, "Zlight", zlight);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -318,23 +320,21 @@ _atof (const char *c)
|
||||||
//
|
//
|
||||||
// Get the state
|
// Get the state
|
||||||
//
|
//
|
||||||
-(float) getXlight
|
- (float) getXlight
|
||||||
{
|
{
|
||||||
return[xlight_i floatValue];
|
return [xlight_i floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float) getYlight
|
- (float) getYlight
|
||||||
{
|
{
|
||||||
return[ylight_i floatValue];
|
return [ylight_i floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float) getZlight
|
- (float) getZlight
|
||||||
{
|
{
|
||||||
return[zlight_i floatValue];
|
return [zlight_i floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
UIChanged
|
UIChanged
|
||||||
|
@ -342,24 +342,23 @@ UIChanged
|
||||||
Grab all the current UI state
|
Grab all the current UI state
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
-UIChanged:sender
|
- (id) UIChanged: sender
|
||||||
{
|
{
|
||||||
Sys_Printf ("defaults updated\n");
|
Sys_Printf ("defaults updated\n");
|
||||||
|
|
||||||
[self setProjectPath:[[startproject_i stringValue] cString]];
|
[self setProjectPath: [[startproject_i stringValue] cString]];
|
||||||
[self setBspSoundPath:[[bspSoundField_i stringValue] cString]];
|
[self setBspSoundPath: [[bspSoundField_i stringValue] cString]];
|
||||||
[self setShowBSP:[showBSP_i intValue]];
|
[self setShowBSP: [showBSP_i intValue]];
|
||||||
[self setBrushOffset:[brushOffset_i intValue]];
|
[self setBrushOffset: [brushOffset_i intValue]];
|
||||||
[self setStartWad:[startwad_i selectedRow]];
|
[self setStartWad: [startwad_i selectedRow]];
|
||||||
[self setXlight:[xlight_i floatValue]];
|
[self setXlight: [xlight_i floatValue]];
|
||||||
[self setYlight:[ylight_i floatValue]];
|
[self setYlight: [ylight_i floatValue]];
|
||||||
[self setZlight:[zlight_i floatValue]];
|
[self setZlight: [zlight_i floatValue]];
|
||||||
|
|
||||||
[map_i makeGlobalPerform:@selector (flushTextures)];
|
[map_i makeGlobalPerform: @selector (flushTextures)];
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ extern id project_i;
|
||||||
id descList; // list of map descriptions (Storage)
|
id descList; // list of map descriptions (Storage)
|
||||||
id wadList; // list of wad names (Storage)
|
id wadList; // list of wad names (Storage)
|
||||||
|
|
||||||
id pis_panel_i; // outlet to Project Info Settings
|
id pis_panel_i; // outlet to Project Info Settings (PIS)
|
||||||
// (PIS) panel
|
// panel
|
||||||
|
|
||||||
id pis_basepath_i; // outlet to PIS->base path
|
id pis_basepath_i; // outlet to PIS->base path
|
||||||
id pis_wads_i; // outlet to PIS->wad browser
|
id pis_wads_i; // outlet to PIS->wad browser
|
||||||
|
@ -69,46 +69,49 @@ extern id project_i;
|
||||||
time_t lastModified; // last time project file was modified
|
time_t lastModified; // last time project file was modified
|
||||||
}
|
}
|
||||||
|
|
||||||
-initProject;
|
- (id) initProject;
|
||||||
-initVars;
|
- (id) initVars;
|
||||||
|
|
||||||
-(const char *) currentProjectFile;
|
- (const char *) currentProjectFile;
|
||||||
|
|
||||||
-setTextureWad:(const char *) wf;
|
- (id) setTextureWad: (const char *)wf;
|
||||||
|
|
||||||
-addToOutput:(const char *) string;
|
- (id) addToOutput: (const char *)string;
|
||||||
-clearBspOutput:sender;
|
- (id) clearBspOutput: (id)sender;
|
||||||
-initProjSettings;
|
- (id) initProjSettings;
|
||||||
-changeChar:(char) f to:(char) t in:(id) obj;
|
- (id) changeChar: (char)f
|
||||||
|
to: (char)t
|
||||||
|
in: (id)obj;
|
||||||
|
|
||||||
-(int) searchForString:(const char *) str in:(id) obj;
|
- (int) searchForString: (const char *)str
|
||||||
|
in: (id)obj;
|
||||||
|
|
||||||
-parseProjectFile; // read defaultsdatabase for project
|
- (id) parseProjectFile; // read defaultsdatabase for project path
|
||||||
// path
|
- (id) openProjectFile: (const char *)path; // called by openProject, newProject
|
||||||
-openProjectFile:(const char *) path; // called by openProject and newProject
|
- (id) openProject;
|
||||||
-openProject;
|
- (id) clickedOnMap: sender; // called if clicked on map in browser
|
||||||
-clickedOnMap:sender; // called if clicked on map in browser
|
- (id) clickedOnWad: sender; // called if clicked on wad in browser
|
||||||
-clickedOnWad:sender; // called if clicked on wad in browser
|
|
||||||
|
|
||||||
// methods to querie the project file
|
//
|
||||||
|
// methods to query the project file
|
||||||
|
//
|
||||||
|
- (const char *) getMapDirectory;
|
||||||
|
- (const char *) getFinalMapDirectory;
|
||||||
|
- (const char *) getProgDirectory;
|
||||||
|
|
||||||
-(const char *) getMapDirectory;
|
- (const char *) getWAD8;
|
||||||
-(const char *) getFinalMapDirectory;
|
- (const char *) getWAD9;
|
||||||
-(const char *) getProgDirectory;
|
- (const char *) getWAD0;
|
||||||
|
|
||||||
-(const char *) getWAD8;
|
- (const char *) getFullVisCmd;
|
||||||
-(const char *) getWAD9;
|
- (const char *) getFastVisCmd;
|
||||||
-(const char *) getWAD0;
|
- (const char *) getNoVisCmd;
|
||||||
|
- (const char *) getRelightCmd;
|
||||||
|
- (const char *) getLeaktestCmd;
|
||||||
|
- (const char *) getEntitiesCmd;
|
||||||
|
|
||||||
-(const char *) getFullVisCmd;
|
@end
|
||||||
-(const char *) getFastVisCmd;
|
|
||||||
-(const char *) getNoVisCmd;
|
|
||||||
-(const char *) getRelightCmd;
|
|
||||||
-(const char *) getLeaktestCmd;
|
|
||||||
-(const char *) getEntitiesCmd;
|
|
||||||
|
|
||||||
@end void
|
|
||||||
changeString (char cf, char ct, char *string);
|
|
||||||
|
|
||||||
|
void changeString (char cf, char ct, char *string);
|
||||||
|
|
||||||
#endif // Project_h
|
#endif // Project_h
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//======================================
|
// ======================================
|
||||||
//
|
//
|
||||||
// QuakeEd Project Management
|
// QuakeEd Project Management
|
||||||
//
|
//
|
||||||
//======================================
|
// ======================================
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -18,24 +18,23 @@
|
||||||
#include "Things.h"
|
#include "Things.h"
|
||||||
#include "TexturePalette.h"
|
#include "TexturePalette.h"
|
||||||
|
|
||||||
|
|
||||||
id project_i;
|
id project_i;
|
||||||
|
|
||||||
@implementation Project
|
@implementation Project
|
||||||
|
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
project_i = self;
|
project_i = self;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================
|
// ===========================================================
|
||||||
//
|
//
|
||||||
// Project code
|
// Project code
|
||||||
//
|
//
|
||||||
//===========================================================
|
// ===========================================================
|
||||||
-initVars
|
- (id) initVars
|
||||||
{
|
{
|
||||||
const char *s;
|
const char *s;
|
||||||
const char *pe;
|
const char *pe;
|
||||||
|
@ -55,11 +54,11 @@ id project_i;
|
||||||
strcpy (path_finalmapdir, ts);
|
strcpy (path_finalmapdir, ts);
|
||||||
strcat (path_finalmapdir, SUBDIR_MAPS); // dest dir
|
strcat (path_finalmapdir, SUBDIR_MAPS); // dest dir
|
||||||
|
|
||||||
[basepathinfo_i setStringValue: [NSString stringWithCString:ts]];
|
|
||||||
// in Project Inspector
|
// in Project Inspector
|
||||||
|
[basepathinfo_i setStringValue: [NSString stringWithCString: ts]];
|
||||||
|
|
||||||
#if 0 // FIXME: for "out-of-tree" projects
|
#if 0 // FIXME: for "out-of-tree" projects ?
|
||||||
if ((s =[projectInfo getStringFor:BASEPATHKEY])) {
|
if ((s = [projectInfo getStringFor: BASEPATHKEY])) {
|
||||||
strcpy (path_basepath, s);
|
strcpy (path_basepath, s);
|
||||||
|
|
||||||
strcpy (path_progdir, s);
|
strcpy (path_progdir, s);
|
||||||
|
@ -71,47 +70,46 @@ id project_i;
|
||||||
strcpy (path_finalmapdir, s);
|
strcpy (path_finalmapdir, s);
|
||||||
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
||||||
|
|
||||||
[basepathinfo_i setStringValue:s];
|
[basepathinfo_i setStringValue: s]; // in Project Inspector
|
||||||
// in Project Inspector
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((s =[projectInfo getStringFor:BSPFULLVIS])) {
|
if ((s = [projectInfo getStringFor: BSPFULLVIS])) {
|
||||||
strcpy (string_fullvis, s);
|
strcpy (string_fullvis, s);
|
||||||
changeString ('@', '\"', string_fullvis);
|
changeString ('@', '\"', string_fullvis);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s =[projectInfo getStringFor:BSPFASTVIS])) {
|
if ((s = [projectInfo getStringFor: BSPFASTVIS])) {
|
||||||
strcpy (string_fastvis, s);
|
strcpy (string_fastvis, s);
|
||||||
changeString ('@', '\"', string_fastvis);
|
changeString ('@', '\"', string_fastvis);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s =[projectInfo getStringFor:BSPNOVIS])) {
|
if ((s = [projectInfo getStringFor: BSPNOVIS])) {
|
||||||
strcpy (string_novis, s);
|
strcpy (string_novis, s);
|
||||||
changeString ('@', '\"', string_novis);
|
changeString ('@', '\"', string_novis);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s =[projectInfo getStringFor:BSPRELIGHT])) {
|
if ((s = [projectInfo getStringFor: BSPRELIGHT])) {
|
||||||
strcpy (string_relight, s);
|
strcpy (string_relight, s);
|
||||||
changeString ('@', '\"', string_relight);
|
changeString ('@', '\"', string_relight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s =[projectInfo getStringFor:BSPLEAKTEST])) {
|
if ((s = [projectInfo getStringFor: BSPLEAKTEST])) {
|
||||||
strcpy (string_leaktest, s);
|
strcpy (string_leaktest, s);
|
||||||
changeString ('@', '\"', string_leaktest);
|
changeString ('@', '\"', string_leaktest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s =[projectInfo getStringFor:BSPENTITIES])) {
|
if ((s = [projectInfo getStringFor: BSPENTITIES])) {
|
||||||
strcpy (string_entities, s);
|
strcpy (string_entities, s);
|
||||||
changeString ('@', '\"', string_entities);
|
changeString ('@', '\"', string_entities);
|
||||||
}
|
}
|
||||||
// Build list of wads
|
// Build list of wads
|
||||||
wadList =[projectInfo parseMultipleFrom:WADSKEY];
|
wadList = [projectInfo parseMultipleFrom: WADSKEY];
|
||||||
|
|
||||||
// Build list of maps & descriptions
|
// Build list of maps & descriptions
|
||||||
mapList =[projectInfo parseMultipleFrom:MAPNAMESKEY];
|
mapList = [projectInfo parseMultipleFrom: MAPNAMESKEY];
|
||||||
descList =[projectInfo parseMultipleFrom:DESCKEY];
|
descList = [projectInfo parseMultipleFrom: DESCKEY];
|
||||||
[self changeChar: '_' to: ' ' in:descList];
|
[self changeChar: '_' to: ' ' in: descList];
|
||||||
|
|
||||||
[self initProjSettings];
|
[self initProjSettings];
|
||||||
|
|
||||||
|
@ -121,14 +119,14 @@ id project_i;
|
||||||
//
|
//
|
||||||
// Init Project Settings fields
|
// Init Project Settings fields
|
||||||
//
|
//
|
||||||
-initProjSettings
|
- (id) initProjSettings
|
||||||
{
|
{
|
||||||
[pis_basepath_i setStringValue: [NSString stringWithCString:path_basepath]];
|
[pis_basepath_i setStringValue: [NSString stringWithCString: path_basepath]];
|
||||||
[pis_fullvis_i setStringValue: [NSString stringWithCString:string_fullvis]];
|
[pis_fullvis_i setStringValue: [NSString stringWithCString: string_fullvis]];
|
||||||
[pis_fastvis_i setStringValue: [NSString stringWithCString:string_fastvis]];
|
[pis_fastvis_i setStringValue: [NSString stringWithCString: string_fastvis]];
|
||||||
[pis_novis_i setStringValue: [NSString stringWithCString:string_novis]];
|
[pis_novis_i setStringValue: [NSString stringWithCString: string_novis]];
|
||||||
[pis_relight_i setStringValue: [NSString stringWithCString:string_relight]];
|
[pis_relight_i setStringValue: [NSString stringWithCString: string_relight]];
|
||||||
[pis_leaktest_i setStringValue: [NSString stringWithCString:string_leaktest]];
|
[pis_leaktest_i setStringValue: [NSString stringWithCString: string_leaktest]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -136,46 +134,46 @@ id project_i;
|
||||||
//
|
//
|
||||||
// Add text to the BSP Output window
|
// Add text to the BSP Output window
|
||||||
//
|
//
|
||||||
-addToOutput:(const char *) string
|
- (id) addToOutput: (const char *)string
|
||||||
{
|
{
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
end =[BSPoutput_i textLength];
|
end = [BSPoutput_i textLength];
|
||||||
[BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0) withString: [NSString stringWithCString:string]];
|
[BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0)
|
||||||
|
withString: [NSString stringWithCString: string]];
|
||||||
|
|
||||||
end =[BSPoutput_i textLength];
|
end = [BSPoutput_i textLength];
|
||||||
[BSPoutput_i setSelectedRange:NSMakeRange (end, 0)];
|
[BSPoutput_i setSelectedRange: NSMakeRange (end, 0)];
|
||||||
// XXX [BSPoutput_i scrollSelToVisible];
|
// XXX [BSPoutput_i scrollSelToVisible];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-clearBspOutput:sender
|
- (id) clearBspOutput: sender
|
||||||
{
|
{
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
end =[BSPoutput_i textLength];
|
end = [BSPoutput_i textLength];
|
||||||
[BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString:@""];
|
[BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString: @""];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-print
|
- (id) print
|
||||||
{
|
{
|
||||||
// XXX [BSPoutput_i printPSCode:self];
|
// XXX [BSPoutput_i printPSCode:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) initProject
|
||||||
-initProject
|
|
||||||
{
|
{
|
||||||
[self parseProjectFile];
|
[self parseProjectFile];
|
||||||
if (projectInfo == NULL)
|
if (projectInfo == NULL)
|
||||||
return self;
|
return self;
|
||||||
[self initVars];
|
[self initVars];
|
||||||
[mapbrowse_i setReusesColumns:YES];
|
[mapbrowse_i setReusesColumns: YES];
|
||||||
[mapbrowse_i loadColumnZero];
|
[mapbrowse_i loadColumnZero];
|
||||||
[pis_wads_i setReusesColumns:YES];
|
[pis_wads_i setReusesColumns: YES];
|
||||||
[pis_wads_i loadColumnZero];
|
[pis_wads_i loadColumnZero];
|
||||||
|
|
||||||
[things_i initEntities];
|
[things_i initEntities];
|
||||||
|
@ -186,15 +184,15 @@ id project_i;
|
||||||
//
|
//
|
||||||
// Change a character to another in a Storage list of strings
|
// Change a character to another in a Storage list of strings
|
||||||
//
|
//
|
||||||
-changeChar:(char) f to:(char) t in:(id) obj
|
- (id) changeChar: (char)f to: (char)t in: (id)obj
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
max =[obj count];
|
max = [obj count];
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
string =[obj elementAt:i];
|
string = [obj elementAt: i];
|
||||||
changeString (f, t, string);
|
changeString (f, t, string);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -204,37 +202,37 @@ id project_i;
|
||||||
// Fill the QuakeEd Maps or wads browser
|
// Fill the QuakeEd Maps or wads browser
|
||||||
// (Delegate method - delegated in Interface Builder)
|
// (Delegate method - delegated in Interface Builder)
|
||||||
//
|
//
|
||||||
-(void) browser: sender createRowsForColumn:(int) column inMatrix: matrix
|
- (void) browser: sender createRowsForColumn: (int)column inMatrix: matrix
|
||||||
{
|
{
|
||||||
id cell, list;
|
id cell, list;
|
||||||
int max;
|
int max;
|
||||||
char *name;
|
char *name;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sender == mapbrowse_i)
|
if (sender == mapbrowse_i) {
|
||||||
list = mapList;
|
list = mapList;
|
||||||
else if (sender == pis_wads_i)
|
} else if (sender == pis_wads_i) {
|
||||||
list = wadList;
|
list = wadList;
|
||||||
else {
|
} else {
|
||||||
list = nil;
|
list = nil;
|
||||||
Sys_Error ("Project: unknown browser to fill");
|
Sys_Error ("Project: unknown browser to fill");
|
||||||
}
|
}
|
||||||
|
|
||||||
max =[list count];
|
max = [list count];
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
name =[list elementAt:i];
|
name = [list elementAt: i];
|
||||||
[matrix addRow];
|
[matrix addRow];
|
||||||
cell =[matrix cellAtRow: i column:0];
|
cell = [matrix cellAtRow: i column: 0];
|
||||||
[cell setStringValue: [NSString stringWithCString:name]];
|
[cell setStringValue: [NSString stringWithCString: name]];
|
||||||
[cell setLeaf:YES];
|
[cell setLeaf: YES];
|
||||||
[cell setLoaded:YES];
|
[cell setLoaded: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clicked on a map name or description!
|
// Clicked on a map name or description!
|
||||||
//
|
//
|
||||||
-clickedOnMap:sender
|
- (id) clickedOnMap: sender
|
||||||
{
|
{
|
||||||
id matrix;
|
id matrix;
|
||||||
int row;
|
int row;
|
||||||
|
@ -242,10 +240,10 @@ id project_i;
|
||||||
id panel;
|
id panel;
|
||||||
NSModalSession session;
|
NSModalSession session;
|
||||||
|
|
||||||
matrix =[sender matrixInColumn:0];
|
matrix = [sender matrixInColumn: 0];
|
||||||
row =[matrix selectedRow];
|
row = [matrix selectedRow];
|
||||||
fname = va ("%s/%s.map", path_mapdirectory,
|
fname = va ("%s/%s.map", path_mapdirectory,
|
||||||
(const char *) [mapList elementAt:row]); //XXX Storage
|
(const char *) [mapList elementAt: row]); // XXX Storage
|
||||||
|
|
||||||
panel = NSGetAlertPanel (@"Loading...",
|
panel = NSGetAlertPanel (@"Loading...",
|
||||||
@"Loading map. Please wait.", NULL, NULL, NULL);
|
@"Loading map. Please wait.", NULL, NULL, NULL);
|
||||||
|
@ -253,7 +251,7 @@ id project_i;
|
||||||
session = [NSApp beginModalSessionForWindow: panel];
|
session = [NSApp beginModalSessionForWindow: panel];
|
||||||
[NSApp runModalSession: session];
|
[NSApp runModalSession: session];
|
||||||
|
|
||||||
[quakeed_i doOpen:fname];
|
[quakeed_i doOpen: fname];
|
||||||
|
|
||||||
[NSApp endModalSession: session];
|
[NSApp endModalSession: session];
|
||||||
[panel close];
|
[panel close];
|
||||||
|
@ -261,8 +259,7 @@ id project_i;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) setTextureWad: (const char *)wf
|
||||||
-setTextureWad:(const char *) wf
|
|
||||||
{
|
{
|
||||||
int i, c;
|
int i, c;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -270,18 +267,18 @@ id project_i;
|
||||||
Sys_Printf ("loading %s\n", wf);
|
Sys_Printf ("loading %s\n", wf);
|
||||||
|
|
||||||
// set the row in the settings inspector wad browser
|
// set the row in the settings inspector wad browser
|
||||||
c =[wadList count];
|
c = [wadList count];
|
||||||
for (i = 0; i < c; i++) {
|
for (i = 0; i < c; i++) {
|
||||||
name = (const char *)[wadList elementAt:i]; // XXX Storage
|
name = (const char *) [wadList elementAt: i]; // XXX Storage
|
||||||
if (!strcmp (name, wf)) {
|
if (!strcmp (name, wf)) {
|
||||||
[[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column:0];
|
[[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column: 0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the texture inspector
|
// update the texture inspector
|
||||||
[texturepalette_i initPaletteFromWadfile:wf];
|
[texturepalette_i initPaletteFromWadfile: wf];
|
||||||
[[map_i objectAtIndex: 0] setKey: "wad" toValue:wf];
|
[[map_i objectAtIndex: 0] setKey: "wad" toValue: wf];
|
||||||
// [inspcontrol_i changeInspectorTo:i_textures];
|
// [inspcontrol_i changeInspectorTo:i_textures];
|
||||||
|
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
|
@ -292,53 +289,54 @@ id project_i;
|
||||||
//
|
//
|
||||||
// Clicked on a wad name
|
// Clicked on a wad name
|
||||||
//
|
//
|
||||||
-clickedOnWad:sender
|
- (id) clickedOnWad: sender
|
||||||
{
|
{
|
||||||
id matrix;
|
id matrix;
|
||||||
int row;
|
int row;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
matrix =[sender matrixInColumn:0];
|
matrix = [sender matrixInColumn: 0];
|
||||||
row =[matrix selectedRow];
|
row = [matrix selectedRow];
|
||||||
|
|
||||||
name = (char *)[wadList elementAt:row]; // XXX Storage
|
name = (char *) [wadList elementAt: row]; // XXX Storage
|
||||||
[self setTextureWad:name];
|
[self setTextureWad: name];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read in the <name>.QE_Project file
|
// Read in the <name>.QE_Project file
|
||||||
//
|
//
|
||||||
-parseProjectFile
|
- (id) parseProjectFile
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
int rtn;
|
int rtn;
|
||||||
|
|
||||||
path =[preferences_i getProjectPath];
|
path = [preferences_i getProjectPath];
|
||||||
if (!path || !path[0] || access (path, 0)) {
|
if (!path || !path[0] || access (path, 0)) {
|
||||||
rtn = NSRunAlertPanel (@"Project Error!",
|
rtn = NSRunAlertPanel (@"Project Error!",
|
||||||
@"A default project has not been found.\n",
|
@"A default project has not been found.\n",
|
||||||
@"Open Project", NULL, NULL);
|
@"Open Project", NULL, NULL);
|
||||||
if ([self openProject] == nil)
|
if ([self openProject] == nil) {
|
||||||
while (1) // can't run without a project
|
while (1)
|
||||||
[NSApp terminate:self];
|
[NSApp terminate: self]; // can't run without a project
|
||||||
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self openProjectFile:path];
|
[self openProjectFile: path];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Loads and parses a project file
|
// Loads and parses a project file
|
||||||
//
|
//
|
||||||
-openProjectFile:(const char *) path
|
- (id) openProjectFile: (const char *)path
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
Sys_Printf ("openProjectFile: %s\n", path);
|
|
||||||
|
Sys_Printf ("openProjectFile: %s\n", path);
|
||||||
strcpy (path_projectinfo, path);
|
strcpy (path_projectinfo, path);
|
||||||
|
|
||||||
projectInfo = NULL;
|
projectInfo = NULL;
|
||||||
|
@ -349,13 +347,13 @@ Sys_Printf ("openProjectFile: %s\n", path);
|
||||||
stat (path, &s);
|
stat (path, &s);
|
||||||
lastModified = s.st_mtime;
|
lastModified = s.st_mtime;
|
||||||
|
|
||||||
projectInfo =[(Dict *)[Dict alloc] initFromFile:fp];
|
projectInfo = [(Dict *)[Dict alloc] initFromFile: fp];
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) currentProjectFile
|
- (const char *) currentProjectFile
|
||||||
{
|
{
|
||||||
return path_projectinfo;
|
return path_projectinfo;
|
||||||
}
|
}
|
||||||
|
@ -363,167 +361,177 @@ Sys_Printf ("openProjectFile: %s\n", path);
|
||||||
//
|
//
|
||||||
// Open a project file
|
// Open a project file
|
||||||
//
|
//
|
||||||
-openProject
|
- (id) openProject
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
id openpanel;
|
id openpanel;
|
||||||
int rtn;
|
int rtn;
|
||||||
NSString *projtypes[] = { @"qpr" };
|
NSString *projtypes[] = {@"qpr"};
|
||||||
NSArray *filenames;
|
NSArray *filenames;
|
||||||
const char *dir;
|
const char *dir;
|
||||||
|
|
||||||
openpanel =[NSOpenPanel new];
|
openpanel = [NSOpenPanel new];
|
||||||
// [openpanel allowMultipleFiles:NO];
|
// [openpanel allowMultipleFiles:NO];
|
||||||
// [openpanel chooseDirectories:NO];
|
// [openpanel chooseDirectories:NO];
|
||||||
rtn =[openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes count:1]];
|
rtn = [openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes
|
||||||
|
count: 1]];
|
||||||
if (rtn == NSOKButton) {
|
if (rtn == NSOKButton) {
|
||||||
filenames =[openpanel filenames];
|
filenames = [openpanel filenames];
|
||||||
dir =[[openpanel directory] cString];
|
dir = [[openpanel directory] cString];
|
||||||
dir = "";
|
dir = "";
|
||||||
path = va ("%s/%s", dir,[[filenames objectAtIndex:0] cString]);
|
path = va ("%s/%s", dir, [[filenames objectAtIndex: 0] cString]);
|
||||||
strcpy (path_projectinfo, path);
|
strcpy (path_projectinfo, path);
|
||||||
[self openProjectFile:path];
|
[self openProjectFile: path];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search for a string in a List of strings
|
// Search for a string in a List of strings
|
||||||
//
|
//
|
||||||
-(int) searchForString:(const char *) str in:(id) obj
|
- (int) searchForString: (const char *)str in: (id)obj
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
max =[obj count];
|
max = [obj count];
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
s = (const char *)[obj elementAt:i]; // XXX Storage?
|
s = (const char *) [obj elementAt: i]; // XXX Storage?
|
||||||
if (!strcmp (s, str))
|
if (!strcmp (s, str))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) getMapDirectory
|
- (const char *) getMapDirectory
|
||||||
{
|
{
|
||||||
return path_mapdirectory;
|
return path_mapdirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) getFinalMapDirectory
|
- (const char *) getFinalMapDirectory
|
||||||
{
|
{
|
||||||
return path_finalmapdir;
|
return path_finalmapdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) getProgDirectory
|
- (const char *) getProgDirectory
|
||||||
{
|
{
|
||||||
return path_progdir;
|
return path_progdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the WAD name for cmd-8
|
// Return the WAD name for cmd-8
|
||||||
//
|
//
|
||||||
-(const char *) getWAD8
|
- (const char *) getWAD8
|
||||||
{
|
{
|
||||||
if (!path_wad8[0])
|
if (!path_wad8[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return path_wad8;
|
return path_wad8;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the WAD name for cmd-9
|
// Return the WAD name for cmd-9
|
||||||
//
|
//
|
||||||
-(const char *) getWAD9
|
- (const char *) getWAD9
|
||||||
{
|
{
|
||||||
if (!path_wad9[0])
|
if (!path_wad9[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return path_wad9;
|
return path_wad9;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the WAD name for cmd-0
|
// Return the WAD name for cmd-0
|
||||||
//
|
//
|
||||||
-(const char *) getWAD0
|
- (const char *) getWAD0
|
||||||
{
|
{
|
||||||
if (!path_wad0[0])
|
if (!path_wad0[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return path_wad0;
|
return path_wad0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the FULLVIS cmd string
|
// Return the FULLVIS cmd string
|
||||||
//
|
//
|
||||||
-(const char *) getFullVisCmd
|
- (const char *) getFullVisCmd
|
||||||
{
|
{
|
||||||
if (!string_fullvis[0])
|
if (!string_fullvis[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return string_fullvis;
|
return string_fullvis;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the FASTVIS cmd string
|
// Return the FASTVIS cmd string
|
||||||
//
|
//
|
||||||
-(const char *) getFastVisCmd
|
- (const char *) getFastVisCmd
|
||||||
{
|
{
|
||||||
if (!string_fastvis[0])
|
if (!string_fastvis[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return string_fastvis;
|
return string_fastvis;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the NOVIS cmd string
|
// Return the NOVIS cmd string
|
||||||
//
|
//
|
||||||
-(const char *) getNoVisCmd
|
- (const char *) getNoVisCmd
|
||||||
{
|
{
|
||||||
if (!string_novis[0])
|
if (!string_novis[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return string_novis;
|
return string_novis;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the RELIGHT cmd string
|
// Return the RELIGHT cmd string
|
||||||
//
|
//
|
||||||
-(const char *) getRelightCmd
|
- (const char *) getRelightCmd
|
||||||
{
|
{
|
||||||
if (!string_relight[0])
|
if (!string_relight[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return string_relight;
|
return string_relight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the LEAKTEST cmd string
|
// Return the LEAKTEST cmd string
|
||||||
//
|
//
|
||||||
-(const char *) getLeaktestCmd
|
- (const char *) getLeaktestCmd
|
||||||
{
|
{
|
||||||
if (!string_leaktest[0])
|
if (!string_leaktest[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return string_leaktest;
|
return string_leaktest;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) getEntitiesCmd
|
- (const char *) getEntitiesCmd
|
||||||
{
|
{
|
||||||
if (!string_entities[0])
|
if (!string_entities[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return string_entities;
|
return string_entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
//====================================================
|
|
||||||
|
// ====================================================
|
||||||
// C Functions
|
// C Functions
|
||||||
//====================================================
|
// ====================================================
|
||||||
//
|
//
|
||||||
// Change a character to a different char in a string
|
// Change a character to a different char in a string
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
changeString (char cf, char ct, char *string)
|
changeString (char cf, char ct, char *string)
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
for (j = 0; j < strlen (string); j++)
|
for (j = 0; j < strlen (string); j++) {
|
||||||
if (string[j] == cf)
|
if (string[j] == cf)
|
||||||
string[j] = ct;
|
string[j] = ct;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ double I_FloatTime (void);
|
||||||
|
|
||||||
void NopSound (void);
|
void NopSound (void);
|
||||||
|
|
||||||
@interface QuakeEd:NSWindow
|
@interface QuakeEd: NSWindow
|
||||||
{
|
{
|
||||||
BOOL dirty;
|
BOOL dirty;
|
||||||
char filename[1024]; // full path with .map extension
|
char filename[1024]; // full path with .map extension
|
||||||
|
@ -23,7 +23,9 @@ void NopSound (void);
|
||||||
NSRect cache_rect[3];
|
NSRect cache_rect[3];
|
||||||
BOOL no_restore[3];
|
BOOL no_restore[3];
|
||||||
|
|
||||||
|
//
|
||||||
// UI objects
|
// UI objects
|
||||||
|
//
|
||||||
id brushcount_i;
|
id brushcount_i;
|
||||||
id entitycount_i;
|
id entitycount_i;
|
||||||
id regionbutton_i;
|
id regionbutton_i;
|
||||||
|
@ -44,65 +46,65 @@ void NopSound (void);
|
||||||
id xy_drawmode_i; // passed over to xyview after init
|
id xy_drawmode_i; // passed over to xyview after init
|
||||||
}
|
}
|
||||||
|
|
||||||
-setDefaultFilename;
|
- (id) setDefaultFilename;
|
||||||
-(const char *) currentFilename;
|
- (const char *) currentFilename;
|
||||||
|
|
||||||
-updateAll; // when a model has been changed
|
- (id) updateAll; // when a model has been changed
|
||||||
-updateCamera; // when the camera has moved
|
- (id) updateCamera; // when the camera has moved
|
||||||
-updateXY;
|
- (id) updateXY;
|
||||||
-updateZ;
|
- (id) updateZ;
|
||||||
|
|
||||||
-updateAll:sender;
|
- (id) updateAll: sender;
|
||||||
|
|
||||||
-(void)cameraNoRestore: (NSRect) rect;
|
- (void) cameraNoRestore: (NSRect)rect;
|
||||||
-(void)xyNoRestore: (NSRect) rect;
|
- (void) xyNoRestore: (NSRect)rect;
|
||||||
-(void)zNoRestore: (NSRect) rect;
|
- (void) zNoRestore: (NSRect)rect;
|
||||||
|
|
||||||
-newinstance; // force next flushwindow to clear all
|
- (id) newinstance; // force next flushwindow to clear all
|
||||||
// instance drawing
|
// instance drawing
|
||||||
-redrawInstance; // erase and redraw all instance now
|
- (id) redrawInstance; // erase and redraw all instance now
|
||||||
|
|
||||||
-appWillTerminate:sender;
|
- (id) appWillTerminate: sender;
|
||||||
|
|
||||||
-openProject:sender;
|
- (id) openProject: sender;
|
||||||
|
|
||||||
-textCommand:sender;
|
- (id) textCommand: sender;
|
||||||
|
|
||||||
-applyRegion:sender;
|
- (id) applyRegion: sender;
|
||||||
|
|
||||||
-(BOOL) dirty;
|
- (BOOL) dirty;
|
||||||
|
|
||||||
-clear:sender;
|
- (id) clear: sender;
|
||||||
-centerCamera:sender;
|
- (id) centerCamera: sender;
|
||||||
-centerZChecker:sender;
|
- (id) centerZChecker: sender;
|
||||||
|
|
||||||
-changeXYLookUp:sender;
|
- (id) changeXYLookUp: sender;
|
||||||
|
|
||||||
-setBrushRegion:sender;
|
- (id) setBrushRegion: sender;
|
||||||
-setXYRegion:sender;
|
- (id) setXYRegion: sender;
|
||||||
|
|
||||||
-open:sender;
|
- (id) open: sender;
|
||||||
-save:sender;
|
- (id) save: sender;
|
||||||
-saveAs:sender;
|
- (id) saveAs: sender;
|
||||||
|
|
||||||
-doOpen:(const char *) fname;
|
- (id) doOpen: (const char *)fname;
|
||||||
|
|
||||||
-saveBSP:(const char *)cmdline dialog:(BOOL)wt;
|
- (id) saveBSP: (const char *)cmdline dialog: (BOOL)wt;
|
||||||
|
|
||||||
-BSP_Full:sender;
|
- (id) BSP_Full: sender;
|
||||||
-BSP_FastVis:sender;
|
- (id) BSP_FastVis: sender;
|
||||||
-BSP_NoVis:sender;
|
- (id) BSP_NoVis: sender;
|
||||||
-BSP_relight:sender;
|
- (id) BSP_relight: sender;
|
||||||
-BSP_stop:sender;
|
- (id) BSP_stop: sender;
|
||||||
-BSP_entities:sender;
|
- (id) BSP_entities: sender;
|
||||||
|
|
||||||
-applicationDefined:(NSEvent *) theEvent;
|
- (id) applicationDefined: (NSEvent *)theEvent;
|
||||||
|
|
||||||
//
|
//
|
||||||
// UI querie for other objects
|
// UI query for other objects
|
||||||
//
|
//
|
||||||
-(BOOL) showCoordinates;
|
- (BOOL) showCoordinates;
|
||||||
-(BOOL) showNames;
|
- (BOOL) showNames;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // QuakeEd_h
|
#endif // QuakeEd_h
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,19 +4,18 @@
|
||||||
|
|
||||||
#include "QuakeEd.h"
|
#include "QuakeEd.h"
|
||||||
|
|
||||||
@interface QuakeEdApp:NSApplication
|
@interface QuakeEdApp: NSApplication
|
||||||
-(void)sendEvent:(NSEvent *) evt;
|
- (void) sendEvent: (NSEvent *)evt;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation QuakeEdApp
|
@implementation QuakeEdApp
|
||||||
|
|
||||||
-(void)sendEvent:(NSEvent *) evt;
|
- (void) sendEvent: (NSEvent *)evt;
|
||||||
{
|
{
|
||||||
if ([evt type] == NSApplicationDefined) {
|
if ([evt type] == NSApplicationDefined)
|
||||||
[quakeed_i applicationDefined: evt];
|
[quakeed_i applicationDefined: evt];
|
||||||
} else {
|
else
|
||||||
[super sendEvent:evt];
|
[super sendEvent: evt];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -41,17 +41,14 @@ typedef struct {
|
||||||
#define SIDE_BACK 1
|
#define SIDE_BACK 1
|
||||||
#define SIDE_ON 2
|
#define SIDE_ON 2
|
||||||
|
|
||||||
|
|
||||||
winding_t *ClipWinding (winding_t * in, plane_t *split);
|
winding_t *ClipWinding (winding_t * in, plane_t *split);
|
||||||
winding_t *CopyWinding (winding_t * w);
|
winding_t *CopyWinding (winding_t * w);
|
||||||
winding_t *NewWinding (int points);
|
winding_t *NewWinding (int points);
|
||||||
|
|
||||||
|
@interface SetBrush: NSObject
|
||||||
@interface SetBrush:NSObject
|
|
||||||
{
|
{
|
||||||
BOOL regioned; // not active
|
BOOL regioned; // not active
|
||||||
BOOL selected;
|
BOOL selected;
|
||||||
|
|
||||||
BOOL invalid; // not a proper polyhedron
|
BOOL invalid; // not a proper polyhedron
|
||||||
|
|
||||||
id parent; // the entity this brush is in
|
id parent; // the entity this brush is in
|
||||||
|
@ -61,42 +58,45 @@ winding_t *NewWinding (int points);
|
||||||
face_t faces[MAX_FACES];
|
face_t faces[MAX_FACES];
|
||||||
}
|
}
|
||||||
|
|
||||||
-initOwner:own mins:(float *)mins maxs:(float *)maxs
|
- (SetBrush *) initOwner: (id)own
|
||||||
texture:(texturedef_t *)tex;
|
mins: (float *)mins
|
||||||
|
maxs: (float *)maxs
|
||||||
|
texture: (texturedef_t *)tex;
|
||||||
|
|
||||||
-initFromScript:(struct script_s *)script owner:own;
|
- (id) initFromScript: (struct script_s *)script
|
||||||
|
owner: (id)own;
|
||||||
|
|
||||||
-setMins:(float *)mins maxs:(float *)maxs;
|
- (id) setMins: (float *)mins maxs: (float *)maxs;
|
||||||
|
|
||||||
-parent;
|
- (id) parent;
|
||||||
-setParent:(id) p;
|
- (id) setParent: (id)p;
|
||||||
|
|
||||||
-setEntityColor:(vec3_t) color;
|
- (id) setEntityColor: (vec3_t)color;
|
||||||
|
|
||||||
-calcWindings;
|
- (id) calcWindings;
|
||||||
|
|
||||||
- (void) writeToFILE:(FILE *)f region:(BOOL)reg;
|
- (void) writeToFILE: (FILE *)f region: (BOOL)reg;
|
||||||
|
|
||||||
-(BOOL) selected;
|
- (BOOL) selected;
|
||||||
-(BOOL) regioned;
|
- (BOOL) regioned;
|
||||||
- (void) setSelected: (BOOL)s;
|
- (void) setSelected: (BOOL)s;
|
||||||
- (void) setRegioned: (BOOL)s;
|
- (void) setRegioned: (BOOL)s;
|
||||||
|
|
||||||
- (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs;
|
- (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs;
|
||||||
|
|
||||||
-(BOOL) containsPoint:(vec3_t) pt;
|
- (BOOL) containsPoint: (vec3_t)pt;
|
||||||
|
|
||||||
- (void) freeWindings;
|
- (void) freeWindings;
|
||||||
-removeIfInvalid;
|
- (id) removeIfInvalid;
|
||||||
|
|
||||||
extern vec3_t region_min, region_max;
|
extern vec3_t region_min, region_max;
|
||||||
|
|
||||||
-newRegion;
|
- (id) newRegion;
|
||||||
|
|
||||||
-(texturedef_t *) texturedef;
|
- (texturedef_t *) texturedef;
|
||||||
-(texturedef_t *) texturedefForFace:(int) f;
|
- (texturedef_t *) texturedefForFace: (int)f;
|
||||||
- (void) setTexturedef:(texturedef_t *) tex;
|
- (void) setTexturedef: (texturedef_t *)tex;
|
||||||
- (void) setTexturedef:(texturedef_t *) tex forFace:(int) f;
|
- (void) setTexturedef: (texturedef_t *)tex forFace: (int)f;
|
||||||
|
|
||||||
- (void) XYDrawSelf;
|
- (void) XYDrawSelf;
|
||||||
- (void) ZDrawSelf;
|
- (void) ZDrawSelf;
|
||||||
|
@ -116,7 +116,7 @@ extern float *controlpoints[MAX_FACES * 3];
|
||||||
- (void) getXYdragface: (vec3_t)dragpoint;
|
- (void) getXYdragface: (vec3_t)dragpoint;
|
||||||
- (void) getXYShearPoints: (vec3_t)dragpoint;
|
- (void) getXYShearPoints: (vec3_t)dragpoint;
|
||||||
|
|
||||||
-addFace:(face_t *) f;
|
- (id) addFace: (face_t *)f;
|
||||||
|
|
||||||
//
|
//
|
||||||
// multiple brush actions
|
// multiple brush actions
|
||||||
|
@ -145,7 +145,7 @@ extern vec3_t sel_org;
|
||||||
|
|
||||||
- (void) flipNormals;
|
- (void) flipNormals;
|
||||||
|
|
||||||
-carve;
|
- (id) carve;
|
||||||
- (void) setCarveVars;
|
- (void) setCarveVars;
|
||||||
|
|
||||||
extern id sb_newowner;
|
extern id sb_newowner;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -31,9 +31,10 @@
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
@interface Storage:NSObject
|
@interface Storage: NSObject
|
||||||
{
|
{
|
||||||
@public void *dataPtr; /* data of the Storage object */
|
@public
|
||||||
|
void *dataPtr; /* data of the Storage object */
|
||||||
const char *description; /* Element description */
|
const char *description; /* Element description */
|
||||||
NSUInteger numElements; /* Actual number of elements */
|
NSUInteger numElements; /* Actual number of elements */
|
||||||
NSUInteger maxElements; /* Total allocated elements */
|
NSUInteger maxElements; /* Total allocated elements */
|
||||||
|
@ -42,36 +43,38 @@
|
||||||
|
|
||||||
/* Creating, freeing, initializing, and emptying */
|
/* Creating, freeing, initializing, and emptying */
|
||||||
|
|
||||||
-init;
|
- (id) init;
|
||||||
-initCount:(NSUInteger) numSlots elementSize:(NSUInteger) sizeInBytes
|
- (id) initCount: (NSUInteger)numSlots
|
||||||
description:(const char *) elemDesc;
|
elementSize: (NSUInteger)sizeInBytes
|
||||||
-(void) dealloc;
|
description: (const char *)elemDesc;
|
||||||
-empty;
|
- (void) dealloc;
|
||||||
-copy;
|
- (id) empty;
|
||||||
|
- (id) copy;
|
||||||
|
|
||||||
/* Manipulating the elements */
|
/* Manipulating the elements */
|
||||||
|
|
||||||
-(BOOL) isEqual:anObject;
|
- (BOOL) isEqual: anObject;
|
||||||
-(const char *) description;
|
- (const char *) description;
|
||||||
-(NSUInteger) count;
|
- (NSUInteger) count;
|
||||||
-(void *) elementAt:(NSUInteger) index;
|
- (void *) elementAt: (NSUInteger)index;
|
||||||
-replaceElementAt:(NSUInteger) index with:(void *) anElement;
|
- (id) replaceElementAt: (NSUInteger)index
|
||||||
|
with: (void *)anElement;
|
||||||
-setNumSlots:(NSUInteger) numSlots;
|
|
||||||
-setAvailableCapacity:(NSUInteger) numSlots;
|
|
||||||
-addElement:(void *) anElement;
|
|
||||||
-removeLastElement;
|
|
||||||
-insertElement:(void *) anElement at:(NSUInteger) index;
|
|
||||||
|
|
||||||
-removeElementAt:(NSUInteger) index;
|
|
||||||
|
|
||||||
|
- (id) setNumSlots: (NSUInteger)numSlots;
|
||||||
|
- (id) setAvailableCapacity: (NSUInteger)numSlots;
|
||||||
|
- (id) addElement: (void *)anElement;
|
||||||
|
- (id) removeLastElement;
|
||||||
|
- (id) insertElement: (void *)anElement
|
||||||
|
at: (NSUInteger)index;
|
||||||
|
|
||||||
|
- (id) removeElementAt: (NSUInteger)index;
|
||||||
|
|
||||||
/* old-style creation */
|
/* old-style creation */
|
||||||
|
|
||||||
+new;
|
+ (id) new;
|
||||||
+newCount:(NSUInteger) count elementSize:(NSUInteger) sizeInBytes
|
+ (id) newCount: (NSUInteger)count
|
||||||
description:(const char *) descriptor;
|
elementSize: (NSUInteger)sizeInBytes
|
||||||
|
description: (const char *)descriptor;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -79,5 +82,4 @@ typedef struct {
|
||||||
@defs (Storage)
|
@defs (Storage)
|
||||||
} NXStorageId;
|
} NXStorageId;
|
||||||
|
|
||||||
|
|
||||||
#endif /* __Storage_h_INCLUDE_GNU */
|
#endif /* __Storage_h_INCLUDE_GNU */
|
||||||
|
|
|
@ -26,10 +26,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
|
#define GNU_STORAGE_NTH(x, N) \
|
||||||
#define GNU_STORAGE_NTH(x,N) \
|
({GNUStorageId* __s = (GNUStorageId*) (x); \
|
||||||
({ GNUStorageId* __s=(GNUStorageId*)(x); \
|
(void*) (((char*) __s->dataPtr) + (__s->elementSize * (N))); })
|
||||||
(void*)(((char*)__s->dataPtr)+(__s->elementSize*(N))); })
|
|
||||||
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
|
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -38,16 +37,17 @@ typedef struct {
|
||||||
|
|
||||||
@implementation Storage
|
@implementation Storage
|
||||||
|
|
||||||
+initialize
|
+ (id) initialize
|
||||||
{
|
{
|
||||||
if (self ==[Storage class])
|
if (self == [Storage class])
|
||||||
[self setVersion:0]; /* beta release */
|
[self setVersion: 0]; /* beta release */
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INITIALIZING, FREEING;
|
// INITIALIZING, FREEING;
|
||||||
|
|
||||||
-initCount: (NSUInteger) numSlots elementSize: (NSUInteger) sizeInBytes description:(const char *)
|
- (id) initCount: (NSUInteger)numSlots elementSize: (NSUInteger)sizeInBytes
|
||||||
|
description: (const char *)
|
||||||
elemDesc;
|
elemDesc;
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
|
@ -60,31 +60,29 @@ typedef struct {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
return[self initCount: 1 elementSize:sizeof (id)
|
return [self initCount: 1 elementSize: sizeof (id)
|
||||||
description:@encode (id)];
|
description: @encode (id)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
-(void) dealloc
|
|
||||||
{
|
{
|
||||||
if (dataPtr)
|
if (dataPtr)
|
||||||
free (dataPtr);
|
free (dataPtr);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) description
|
- (const char *) description
|
||||||
{
|
{
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// COPYING;
|
// COPYING;
|
||||||
|
|
||||||
-copy
|
- (id) copy
|
||||||
{
|
{
|
||||||
Storage *c =[super copy];
|
Storage *c = [super copy];
|
||||||
|
|
||||||
c->dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
c->dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
||||||
memcpy (c->dataPtr, dataPtr, numElements * elementSize);
|
memcpy (c->dataPtr, dataPtr, numElements * elementSize);
|
||||||
|
@ -93,10 +91,10 @@ typedef struct {
|
||||||
|
|
||||||
// COMPARING TWO STORAGES;
|
// COMPARING TWO STORAGES;
|
||||||
|
|
||||||
-(BOOL) isEqual:anObject
|
- (BOOL) isEqual: anObject
|
||||||
{
|
{
|
||||||
if ([anObject isKindOfClass:[Storage class]]
|
if ([anObject isKindOfClass: [Storage class]]
|
||||||
&&[anObject count] ==[self count]
|
&& [anObject count] == [self count]
|
||||||
&& !memcmp (((GNUStorageId *) anObject)->dataPtr,
|
&& !memcmp (((GNUStorageId *) anObject)->dataPtr,
|
||||||
dataPtr, numElements * elementSize))
|
dataPtr, numElements * elementSize))
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -112,7 +110,8 @@ _makeRoomForAnotherIfNecessary (Storage * self)
|
||||||
if (self->numElements == self->maxElements) {
|
if (self->numElements == self->maxElements) {
|
||||||
self->maxElements *= 2;
|
self->maxElements *= 2;
|
||||||
self->dataPtr = (void *)
|
self->dataPtr = (void *)
|
||||||
objc_realloc (self->dataPtr, self->maxElements * self->elementSize);
|
objc_realloc (self->dataPtr,
|
||||||
|
self->maxElements * self->elementSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +121,12 @@ _shrinkIfDesired (Storage * self)
|
||||||
if (self->numElements < (self->maxElements / 2)) {
|
if (self->numElements < (self->maxElements / 2)) {
|
||||||
self->maxElements /= 2;
|
self->maxElements /= 2;
|
||||||
self->dataPtr = (void *)
|
self->dataPtr = (void *)
|
||||||
objc_realloc (self->dataPtr, self->maxElements * self->elementSize);
|
objc_realloc (self->dataPtr,
|
||||||
|
self->maxElements * self->elementSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-setAvailableCapacity:(NSUInteger) numSlots
|
- (id) setAvailableCapacity: (NSUInteger)numSlots
|
||||||
{
|
{
|
||||||
if (numSlots > numElements) {
|
if (numSlots > numElements) {
|
||||||
maxElements = numSlots;
|
maxElements = numSlots;
|
||||||
|
@ -135,7 +135,7 @@ _shrinkIfDesired (Storage * self)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setNumSlots:(NSUInteger) numSlots
|
- (id) setNumSlots: (NSUInteger)numSlots
|
||||||
{
|
{
|
||||||
if (numSlots > numElements) {
|
if (numSlots > numElements) {
|
||||||
maxElements = numSlots;
|
maxElements = numSlots;
|
||||||
|
@ -153,18 +153,18 @@ _shrinkIfDesired (Storage * self)
|
||||||
|
|
||||||
#define CHECK_INDEX(IND) if (IND >= numElements) return 0
|
#define CHECK_INDEX(IND) if (IND >= numElements) return 0
|
||||||
|
|
||||||
-(NSUInteger) count
|
- (NSUInteger) count
|
||||||
{
|
{
|
||||||
return numElements;
|
return numElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void *) elementAt:(NSUInteger) index
|
- (void *) elementAt: (NSUInteger)index
|
||||||
{
|
{
|
||||||
CHECK_INDEX (index);
|
CHECK_INDEX (index);
|
||||||
return STORAGE_NTH (index);
|
return STORAGE_NTH (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
-addElement:(void *) anElement
|
- (id) addElement: (void *)anElement
|
||||||
{
|
{
|
||||||
_makeRoomForAnotherIfNecessary (self);
|
_makeRoomForAnotherIfNecessary (self);
|
||||||
memcpy (STORAGE_NTH (numElements), anElement, elementSize);
|
memcpy (STORAGE_NTH (numElements), anElement, elementSize);
|
||||||
|
@ -172,8 +172,8 @@ _shrinkIfDesired (Storage * self)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-insertElement:(void *)
|
- (id) insertElement: (void *)
|
||||||
anElement at:(NSUInteger) index
|
anElement at: (NSUInteger)index
|
||||||
{
|
{
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
|
|
||||||
|
@ -182,6 +182,7 @@ anElement at:(NSUInteger) index
|
||||||
#ifndef STABLE_MEMCPY
|
#ifndef STABLE_MEMCPY
|
||||||
for (i = numElements; i >= index; i--)
|
for (i = numElements; i >= index; i--)
|
||||||
memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize);
|
memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
memcpy (STORAGE_NTH (index + 1),
|
memcpy (STORAGE_NTH (index + 1),
|
||||||
STORAGE_NTH (index), elementSize * (numElements - index));
|
STORAGE_NTH (index), elementSize * (numElements - index));
|
||||||
|
@ -191,7 +192,7 @@ anElement at:(NSUInteger) index
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-removeElementAt:(NSUInteger) index
|
- (id) removeElementAt: (NSUInteger)index
|
||||||
{
|
{
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
|
|
||||||
|
@ -200,6 +201,7 @@ anElement at:(NSUInteger) index
|
||||||
#ifndef STABLE_MEMCPY
|
#ifndef STABLE_MEMCPY
|
||||||
for (i = index; i < numElements; i++)
|
for (i = index; i < numElements; i++)
|
||||||
memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize);
|
memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
memcpy (STORAGE_NTH (index),
|
memcpy (STORAGE_NTH (index),
|
||||||
STORAGE_NTH (index + 1), elementSize * (numElements - index - 1));
|
STORAGE_NTH (index + 1), elementSize * (numElements - index - 1));
|
||||||
|
@ -208,7 +210,7 @@ anElement at:(NSUInteger) index
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-removeLastElement
|
- (id) removeLastElement
|
||||||
{
|
{
|
||||||
if (numElements) {
|
if (numElements) {
|
||||||
numElements--;
|
numElements--;
|
||||||
|
@ -217,8 +219,8 @@ anElement at:(NSUInteger) index
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-replaceElementAt:(NSUInteger)
|
- (id) replaceElementAt: (NSUInteger)
|
||||||
index with:(void *) newElement
|
index with: (void *)newElement
|
||||||
{
|
{
|
||||||
CHECK_INDEX (index);
|
CHECK_INDEX (index);
|
||||||
memcpy (STORAGE_NTH (index), newElement, elementSize);
|
memcpy (STORAGE_NTH (index), newElement, elementSize);
|
||||||
|
@ -227,7 +229,7 @@ index with:(void *) newElement
|
||||||
|
|
||||||
/* Emptying the Storage */
|
/* Emptying the Storage */
|
||||||
|
|
||||||
-empty
|
- (id) empty
|
||||||
{
|
{
|
||||||
numElements = 0;
|
numElements = 0;
|
||||||
maxElements = 1;
|
maxElements = 1;
|
||||||
|
@ -235,16 +237,17 @@ index with:(void *) newElement
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
+new
|
+ (id) new
|
||||||
{
|
{
|
||||||
return[[self alloc] init];
|
return [[self alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
+newCount:(NSUInteger)
|
+ (id) newCount: (NSUInteger)
|
||||||
count elementSize:(NSUInteger) sizeInBytes
|
count elementSize: (NSUInteger)sizeInBytes
|
||||||
description:(const char *) descriptor
|
description: (const char *)descriptor
|
||||||
{
|
{
|
||||||
return[[self alloc] initCount: count elementSize: sizeInBytes description:descriptor];
|
return [[self alloc] initCount: count elementSize: sizeInBytes description:
|
||||||
|
descriptor];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -10,7 +10,6 @@ typedef union {
|
||||||
unsigned p;
|
unsigned p;
|
||||||
} pixel32_t;
|
} pixel32_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char texture[16];
|
char texture[16];
|
||||||
float rotate;
|
float rotate;
|
||||||
|
@ -18,7 +17,6 @@ typedef struct {
|
||||||
float scale[2];
|
float scale[2];
|
||||||
} texturedef_t;
|
} texturedef_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[16];
|
char name[16];
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ typedef struct {
|
||||||
|
|
||||||
extern id texturepalette_i;
|
extern id texturepalette_i;
|
||||||
|
|
||||||
@interface TexturePalette:NSObject
|
@interface TexturePalette: NSObject
|
||||||
{
|
{
|
||||||
char currentwad[1024];
|
char currentwad[1024];
|
||||||
id textureList_i;
|
id textureList_i;
|
||||||
|
@ -68,47 +66,48 @@ extern id texturepalette_i;
|
||||||
int selectedTexture;
|
int selectedTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) currentWad;
|
- (const char *) currentWad;
|
||||||
-initPaletteFromWadfile:(const char *) wf;
|
- (id) initPaletteFromWadfile: (const char *)wf;
|
||||||
-computeTextureViewSize;
|
- (id) computeTextureViewSize;
|
||||||
-alphabetize;
|
- (id) alphabetize;
|
||||||
-getList;
|
- (id) getList;
|
||||||
-(int) getSelectedTexture;
|
- (int) getSelectedTexture;
|
||||||
-setSelectedTexture:(int) which;
|
- (id) setSelectedTexture: (int)which;
|
||||||
-(int) getSelectedTexIndex;
|
- (int) getSelectedTexIndex;
|
||||||
|
|
||||||
// Called externally
|
// Called externally
|
||||||
-(const char *) getSelTextureName;
|
- (const char *) getSelTextureName;
|
||||||
-setTextureByName:(const char *) name;
|
- (id) setTextureByName: (const char *)name;
|
||||||
|
|
||||||
// New methods to replace the 2 above ones
|
// New methods to replace the 2 above ones
|
||||||
-setTextureDef:(texturedef_t *) td;
|
- (id) setTextureDef: (texturedef_t *)td;
|
||||||
-getTextureDef:(texturedef_t *) td;
|
- (id) getTextureDef: (texturedef_t *)td;
|
||||||
|
|
||||||
// Action methods
|
// Action methods
|
||||||
-searchForTexture:sender;
|
- (id) searchForTexture: sender;
|
||||||
|
|
||||||
-clearTexinfo:sender;
|
- (id) clearTexinfo: sender;
|
||||||
|
|
||||||
-incXShift:sender;
|
- (id) incXShift: sender;
|
||||||
-decXShift:sender;
|
- (id) decXShift: sender;
|
||||||
|
|
||||||
-incYShift:sender;
|
- (id) incYShift: sender;
|
||||||
-decYShift:sender;
|
- (id) decYShift: sender;
|
||||||
|
|
||||||
-incRotate:sender;
|
- (id) incRotate: sender;
|
||||||
-decRotate:sender;
|
- (id) decRotate: sender;
|
||||||
|
|
||||||
-incXScale:sender;
|
- (id) incXScale: sender;
|
||||||
-decXScale:sender;
|
- (id) decXScale: sender;
|
||||||
|
|
||||||
-incYScale:sender;
|
- (id) incYScale: sender;
|
||||||
-decYScale:sender;
|
- (id) decYScale: sender;
|
||||||
|
|
||||||
-texturedefChanged:sender;
|
- (id) texturedefChanged: sender;
|
||||||
-onlyShowMapTextures:sender;
|
- (id) onlyShowMapTextures: sender;
|
||||||
-(int) searchForTextureInPalette:(const char *) texture;
|
- (int) searchForTextureInPalette: (const char *)texture;
|
||||||
-setDisplayFlag:(int) index to:(int) value;
|
- (id) setDisplayFlag: (int)index
|
||||||
|
to: (int)value;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // TexturePalette_h
|
#endif // TexturePalette_h
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
id texturepalette_i;
|
id texturepalette_i;
|
||||||
|
|
||||||
|
|
||||||
int tex_count;
|
int tex_count;
|
||||||
qtexture_t qtextures[MAX_TEXTURES];
|
qtexture_t qtextures[MAX_TEXTURES];
|
||||||
|
|
||||||
|
@ -65,8 +64,7 @@ unsigned badtex_d[] = {
|
||||||
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
|
||||||
};
|
};
|
||||||
|
|
||||||
qtexture_t badtex =
|
qtexture_t badtex = {"notexture", 16, 16, NULL, badtex_d, {{0, 0, 255, 255}}};
|
||||||
{ "notexture", 16, 16, NULL, badtex_d, {{0, 0, 255, 255}} };
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CleanupName (const char *in, char *out)
|
CleanupName (const char *in, char *out)
|
||||||
|
@ -112,7 +110,6 @@ TEX_InitPalette (wad_t *wad, lumpinfo_t *pallump)
|
||||||
free (opal);
|
free (opal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
TEX_ImageFromMiptex
|
TEX_ImageFromMiptex
|
||||||
|
@ -136,10 +133,19 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
|
||||||
width = LittleLong (qtex->width);
|
width = LittleLong (qtex->width);
|
||||||
height = LittleLong (qtex->height);
|
height = LittleLong (qtex->height);
|
||||||
|
|
||||||
bm =[[NSBitmapImageRep alloc]
|
bm = [[NSBitmapImageRep alloc]
|
||||||
initWithBitmapDataPlanes: NULL pixelsWide: width pixelsHigh: height bitsPerSample: 8 samplesPerPixel: 3 hasAlpha: NO isPlanar: NO colorSpaceName: NSCalibratedRGBColorSpace bytesPerRow: width * 4 bitsPerPixel:32];
|
initWithBitmapDataPlanes: NULL
|
||||||
|
pixelsWide: width
|
||||||
|
pixelsHigh: height
|
||||||
|
bitsPerSample: 8
|
||||||
|
samplesPerPixel: 3
|
||||||
|
hasAlpha: NO
|
||||||
|
isPlanar: NO
|
||||||
|
colorSpaceName: NSCalibratedRGBColorSpace
|
||||||
|
bytesPerRow: width * 4
|
||||||
|
bitsPerPixel: 32];
|
||||||
|
|
||||||
dest = (unsigned *)[bm bitmapData];
|
dest = (unsigned *) [bm bitmapData];
|
||||||
count = width * height;
|
count = width * height;
|
||||||
source = (byte *) qtex + LittleLong (qtex->offsets[0]);
|
source = (byte *) qtex + LittleLong (qtex->offsets[0]);
|
||||||
|
|
||||||
|
@ -155,9 +161,9 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
dest[i] = tex_palette[source[i]];
|
dest[i] = tex_palette[source[i]];
|
||||||
tr += ((pixel32_t *) & dest[i])->chan[0];
|
tr += ((pixel32_t *) &dest[i])->chan[0];
|
||||||
tg += ((pixel32_t *) & dest[i])->chan[1];
|
tg += ((pixel32_t *) &dest[i])->chan[1];
|
||||||
tb += ((pixel32_t *) & dest[i])->chan[2];
|
tb += ((pixel32_t *) &dest[i])->chan[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
q->flatcolor.chan[0] = tr / count;
|
q->flatcolor.chan[0] = tr / count;
|
||||||
|
@ -167,7 +173,7 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
|
||||||
free (qtex);
|
free (qtex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
|
@ -191,6 +197,7 @@ TEX_InitFromWad (const char *path)
|
||||||
// free any textures
|
// free any textures
|
||||||
for (i = 0; i < tex_count; i++)
|
for (i = 0; i < tex_count; i++)
|
||||||
[qtextures[i].rep release];
|
[qtextures[i].rep release];
|
||||||
|
|
||||||
tex_count = 0;
|
tex_count = 0;
|
||||||
|
|
||||||
// try to use the cached wadfile
|
// try to use the cached wadfile
|
||||||
|
@ -199,17 +206,17 @@ TEX_InitFromWad (const char *path)
|
||||||
wad = wad_open (newpath);
|
wad = wad_open (newpath);
|
||||||
if (!wad) {
|
if (!wad) {
|
||||||
NSRunAlertPanel (@"Wad Error!",
|
NSRunAlertPanel (@"Wad Error!",
|
||||||
[NSString stringWithFormat:@"Failed to open '%s'",
|
[NSString stringWithFormat: @"Failed to open '%s'",
|
||||||
newpath],
|
newpath],
|
||||||
@"OK", nil, nil);
|
@"OK", nil,
|
||||||
|
nil);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lumpinfo = wad->lumps;
|
lumpinfo = wad->lumps;
|
||||||
|
|
||||||
if (strcmp (lumpinfo->name, "PALETTE")) {
|
if (strcmp (lumpinfo->name, "PALETTE"))
|
||||||
Sys_Error ("TEX_InitFromWad: %s doesn't have palette as 0", path);
|
Sys_Error ("TEX_InitFromWad: %s doesn't have palette as 0", path);
|
||||||
}
|
|
||||||
|
|
||||||
TEX_InitPalette (wad, lumpinfo);
|
TEX_InitPalette (wad, lumpinfo);
|
||||||
|
|
||||||
|
@ -217,7 +224,7 @@ TEX_InitFromWad (const char *path)
|
||||||
for (i = 1; i < wad->numlumps; i++, lumpinfo++) {
|
for (i = 1; i < wad->numlumps; i++, lumpinfo++) {
|
||||||
if (lumpinfo->type != TYP_MIPTEX)
|
if (lumpinfo->type != TYP_MIPTEX)
|
||||||
Sys_Error ("TEX_InitFromWad: %s is not a miptex!", lumpinfo->name);
|
Sys_Error ("TEX_InitFromWad: %s is not a miptex!", lumpinfo->name);
|
||||||
CleanupName (lumpinfo->name,qtextures[tex_count].name);
|
CleanupName (lumpinfo->name, qtextures[tex_count].name);
|
||||||
TEX_ImageFromMiptex (wad, lumpinfo);
|
TEX_ImageFromMiptex (wad, lumpinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,12 +258,10 @@ TEX_ForName (const char *name)
|
||||||
return &badtex;
|
return &badtex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
@implementation TexturePalette
|
@implementation TexturePalette
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
texturepalette_i = self;
|
texturepalette_i = self;
|
||||||
|
@ -264,25 +269,24 @@ TEX_ForName (const char *name)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) display
|
- (void) display
|
||||||
{
|
{
|
||||||
[[textureView_i superview] display];
|
[[textureView_i superview] display];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (const char *) currentWad
|
||||||
-(const char *) currentWad
|
|
||||||
{
|
{
|
||||||
return currentwad;
|
return currentwad;
|
||||||
}
|
}
|
||||||
|
|
||||||
-initPaletteFromWadfile:(const char *) wf
|
- (id) initPaletteFromWadfile: (const char *)wf
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
texpal_t t;
|
texpal_t t;
|
||||||
qtexture_t *q;
|
qtexture_t *q;
|
||||||
|
|
||||||
strcpy (currentwad, wf);
|
strcpy (currentwad, wf);
|
||||||
[map_i makeGlobalPerform:@selector (flushTextures)];
|
[map_i makeGlobalPerform: @selector (flushTextures)];
|
||||||
selectedTexture = -1;
|
selectedTexture = -1;
|
||||||
|
|
||||||
// Init textures WAD
|
// Init textures WAD
|
||||||
|
@ -290,46 +294,44 @@ TEX_ForName (const char *name)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
// Create STORAGE
|
// Create STORAGE
|
||||||
if (textureList_i)
|
if (textureList_i) {
|
||||||
[textureList_i empty];
|
[textureList_i empty];
|
||||||
else
|
} else {
|
||||||
textureList_i = [[Storage alloc] initCount: 0
|
textureList_i = [[Storage alloc] initCount: 0
|
||||||
elementSize: sizeof (texpal_t)
|
elementSize: sizeof (texpal_t)
|
||||||
description: NULL];
|
description: NULL];
|
||||||
|
}
|
||||||
// Init STORAGE
|
// Init STORAGE
|
||||||
|
|
||||||
for (i = 0, q = qtextures; i < tex_count; i++, q++) {
|
for (i = 0, q = qtextures; i < tex_count; i++, q++) {
|
||||||
t.image = q->rep;
|
t.image = q->rep;
|
||||||
t.r.size.width =[t.image pixelsWide];
|
t.r.size.width = [t.image pixelsWide];
|
||||||
if (t.r.size.width < 64)
|
if (t.r.size.width < 64)
|
||||||
t.r.size.width = 64;
|
t.r.size.width = 64;
|
||||||
t.r.size.height =[t.image pixelsHigh] + TEX_SPACING;
|
t.r.size.height = [t.image pixelsHigh] + TEX_SPACING;
|
||||||
t.name = q->name;
|
t.name = q->name;
|
||||||
t.index = i;
|
t.index = i;
|
||||||
t.display = 1;
|
t.display = 1;
|
||||||
[textureList_i addElement:&t];
|
[textureList_i addElement: &t];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate size of TextureView
|
// Calculate size of TextureView
|
||||||
[self alphabetize];
|
[self alphabetize];
|
||||||
[self computeTextureViewSize];
|
[self computeTextureViewSize];
|
||||||
[textureView_i setParent:self];
|
[textureView_i setParent: self];
|
||||||
[self setSelectedTexture:0];
|
[self setSelectedTexture: 0];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return texture STORAGE list
|
// Return texture STORAGE list
|
||||||
-getList
|
- (id) getList
|
||||||
{
|
{
|
||||||
return textureList_i;
|
return textureList_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alphabetize texture list - reverse order!
|
// Alphabetize texture list - reverse order!
|
||||||
-alphabetize
|
- (id) alphabetize
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
|
@ -339,18 +341,18 @@ TEX_ForName (const char *name)
|
||||||
texpal_t t2;
|
texpal_t t2;
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
max =[textureList_i count];
|
max = [textureList_i count];
|
||||||
found = 1;
|
found = 1;
|
||||||
while (found) {
|
while (found) {
|
||||||
found = 0;
|
found = 0;
|
||||||
for (i = 0; i < max - 1; i++) {
|
for (i = 0; i < max - 1; i++) {
|
||||||
t1p =[textureList_i elementAt:i];
|
t1p = [textureList_i elementAt: i];
|
||||||
t2p =[textureList_i elementAt:i + 1];
|
t2p = [textureList_i elementAt: i + 1];
|
||||||
if (strcmp (t1p->name, t2p->name) < 0) {
|
if (strcmp (t1p->name, t2p->name) < 0) {
|
||||||
t1 = *t1p;
|
t1 = *t1p;
|
||||||
t2 = *t2p;
|
t2 = *t2p;
|
||||||
[textureList_i replaceElementAt: i with:&t2];
|
[textureList_i replaceElementAt: i with: &t2];
|
||||||
[textureList_i replaceElementAt: i + 1 with:&t1];
|
[textureList_i replaceElementAt: i + 1 with: &t1];
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,7 +360,7 @@ TEX_ForName (const char *name)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-computeTextureViewSize
|
- (id) computeTextureViewSize
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
|
@ -371,17 +373,17 @@ TEX_ForName (const char *name)
|
||||||
int maxheight;
|
int maxheight;
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
|
|
||||||
max =[textureList_i count];
|
max = [textureList_i count];
|
||||||
y = 0;
|
y = 0;
|
||||||
maxheight = 0;
|
maxheight = 0;
|
||||||
x = TEX_INDENT;
|
x = TEX_INDENT;
|
||||||
|
|
||||||
view =[textureView_i superview];
|
view = [textureView_i superview];
|
||||||
b =[view bounds];
|
b = [view bounds];
|
||||||
maxwidth = b.size.width;
|
maxwidth = b.size.width;
|
||||||
|
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
t =[textureList_i elementAt:i];
|
t = [textureList_i elementAt: i];
|
||||||
if (x + t->r.size.width + TEX_INDENT > maxwidth) {
|
if (x + t->r.size.width + TEX_INDENT > maxwidth) {
|
||||||
x = TEX_INDENT;
|
x = TEX_INDENT;
|
||||||
y += maxheight;
|
y += maxheight;
|
||||||
|
@ -398,42 +400,43 @@ TEX_ForName (const char *name)
|
||||||
|
|
||||||
viewWidth = maxwidth;
|
viewWidth = maxwidth;
|
||||||
viewHeight = y + TEX_SPACING;
|
viewHeight = y + TEX_SPACING;
|
||||||
[textureView_i setFrameSize:NSMakeSize (viewWidth, viewHeight)];
|
[textureView_i setFrameSize: NSMakeSize (viewWidth, viewHeight)];
|
||||||
pt.x = pt.y = 0;
|
pt.x = pt.y = 0;
|
||||||
[textureView_i scrollPoint:pt];
|
[textureView_i scrollPoint: pt];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-windowResized
|
- (id) windowResized
|
||||||
{
|
{
|
||||||
[self computeTextureViewSize];
|
[self computeTextureViewSize];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-texturedefChanged:sender
|
- (id) texturedefChanged: sender
|
||||||
{
|
{
|
||||||
if ([map_i numSelected]) {
|
if ([map_i numSelected]) {
|
||||||
if ([[map_i currentEntity] modifiable]) {
|
if ([[map_i currentEntity] modifiable]) {
|
||||||
[map_i makeSelectedPerform:@selector
|
[map_i makeSelectedPerform: @selector
|
||||||
(takeCurrentTexture)];
|
(takeCurrentTexture)];
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
} else
|
} else {
|
||||||
Sys_Printf ("can't modify spawned entities\n");
|
Sys_Printf ("can't modify spawned entities\n");
|
||||||
}
|
}
|
||||||
[quakeed_i makeFirstResponder:quakeed_i];
|
}
|
||||||
|
[quakeed_i makeFirstResponder: quakeed_i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-clearTexinfo:sender
|
- (id) clearTexinfo: sender
|
||||||
{
|
{
|
||||||
[field_Xshift_i setFloatValue:0];
|
[field_Xshift_i setFloatValue: 0];
|
||||||
[field_Yshift_i setFloatValue:0];
|
[field_Yshift_i setFloatValue: 0];
|
||||||
[field_Xscale_i setFloatValue:1];
|
[field_Xscale_i setFloatValue: 1];
|
||||||
[field_Yscale_i setFloatValue:1];
|
[field_Yscale_i setFloatValue: 1];
|
||||||
[field_Rotate_i setFloatValue:0];
|
[field_Rotate_i setFloatValue: 0];
|
||||||
|
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -441,32 +444,32 @@ TEX_ForName (const char *name)
|
||||||
//
|
//
|
||||||
// Set the selected texture
|
// Set the selected texture
|
||||||
//
|
//
|
||||||
-setSelectedTexture:(int) which
|
- (id) setSelectedTexture: (int)which
|
||||||
{
|
{
|
||||||
texpal_t *t;
|
texpal_t *t;
|
||||||
NSRect r;
|
NSRect r;
|
||||||
|
|
||||||
// wipe the fields
|
// wipe the fields
|
||||||
[self clearTexinfo:self];
|
[self clearTexinfo: self];
|
||||||
|
|
||||||
if (which != selectedTexture) {
|
if (which != selectedTexture) {
|
||||||
[textureView_i deselect];
|
[textureView_i deselect];
|
||||||
selectedTexture = which;
|
selectedTexture = which;
|
||||||
t =[textureList_i elementAt:which];
|
t = [textureList_i elementAt: which];
|
||||||
r = t->r;
|
r = t->r;
|
||||||
r.size.width += TEX_INDENT * 2;
|
r.size.width += TEX_INDENT * 2;
|
||||||
r.size.height += TEX_INDENT * 2;
|
r.size.height += TEX_INDENT * 2;
|
||||||
r.origin.x -= TEX_INDENT;
|
r.origin.x -= TEX_INDENT;
|
||||||
r.origin.y -= TEX_INDENT;
|
r.origin.y -= TEX_INDENT;
|
||||||
[textureView_i scrollRectToVisible:r];
|
[textureView_i scrollRectToVisible: r];
|
||||||
[textureView_i display];
|
[textureView_i display];
|
||||||
[sizeField_i setStringValue:
|
[sizeField_i setStringValue:
|
||||||
[NSString stringWithFormat:@"%d x %d",
|
[NSString stringWithFormat: @"%d x %d",
|
||||||
(int) t->r.size.width,
|
(int) t->r.size.width,
|
||||||
(int) t->r.size.height - TEX_SPACING]];
|
(int) t->r.size.height - TEX_SPACING]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +477,7 @@ TEX_ForName (const char *name)
|
||||||
//
|
//
|
||||||
// Return the selected texture index
|
// Return the selected texture index
|
||||||
//
|
//
|
||||||
-(int) getSelectedTexture
|
- (int) getSelectedTexture
|
||||||
{
|
{
|
||||||
return selectedTexture;
|
return selectedTexture;
|
||||||
}
|
}
|
||||||
|
@ -483,46 +486,46 @@ TEX_ForName (const char *name)
|
||||||
// Return the original tex_ index of the selected texture
|
// Return the original tex_ index of the selected texture
|
||||||
// so the texture info can be indexed from tex_images, etc.
|
// so the texture info can be indexed from tex_images, etc.
|
||||||
//
|
//
|
||||||
-(int) getSelectedTexIndex
|
- (int) getSelectedTexIndex
|
||||||
{
|
{
|
||||||
texpal_t *t;
|
texpal_t *t;
|
||||||
|
|
||||||
if (selectedTexture == -1)
|
if (selectedTexture == -1)
|
||||||
return -1;
|
return -1;
|
||||||
t =[textureList_i elementAt:selectedTexture];
|
t = [textureList_i elementAt: selectedTexture];
|
||||||
return t->index;
|
return t->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the name of the selected texture
|
// Return the name of the selected texture
|
||||||
//
|
//
|
||||||
-(const char *) getSelTextureName
|
- (const char *) getSelTextureName
|
||||||
{
|
{
|
||||||
texpal_t *t;
|
texpal_t *t;
|
||||||
|
|
||||||
if (selectedTexture == -1)
|
if (selectedTexture == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
t =[textureList_i elementAt:selectedTexture];
|
t = [textureList_i elementAt: selectedTexture];
|
||||||
return t->name;
|
return t->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set selected texture by texture name
|
// Set selected texture by texture name
|
||||||
//
|
//
|
||||||
-setTextureByName:(const char *) name
|
- (id) setTextureByName: (const char *)name
|
||||||
{
|
{
|
||||||
texpal_t *t;
|
texpal_t *t;
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
char *nm = strdup (name);
|
char *nm = strdup (name);
|
||||||
|
|
||||||
max =[textureList_i count];
|
max = [textureList_i count];
|
||||||
CleanupName(nm,nm);
|
CleanupName (nm, nm);
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
t =[textureList_i elementAt:i];
|
t = [textureList_i elementAt: i];
|
||||||
if (!strcmp (t->name, nm)) {
|
if (!strcmp (t->name, nm)) {
|
||||||
free (nm);
|
free (nm);
|
||||||
[self setSelectedTexture:i];
|
[self setSelectedTexture: i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,17 +533,16 @@ TEX_ForName (const char *name)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===================================================
|
// ===================================================
|
||||||
//
|
//
|
||||||
// Action methods
|
// Action methods
|
||||||
//
|
//
|
||||||
//===================================================
|
// ===================================================
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search for texture named in searchField
|
// Search for texture named in searchField
|
||||||
//
|
//
|
||||||
-searchForTexture:sender
|
- (id) searchForTexture: sender
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
|
@ -560,43 +562,43 @@ TEX_ForName (const char *name)
|
||||||
len = strlen (name);
|
len = strlen (name);
|
||||||
|
|
||||||
for (i = selectedTexture - 1; i >= 0; i--) {
|
for (i = selectedTexture - 1; i >= 0; i--) {
|
||||||
t =[textureList_i elementAt:i];
|
t = [textureList_i elementAt: i];
|
||||||
if (!strncmp (t->name, name, len)) {
|
if (!strncmp (t->name, name, len)) {
|
||||||
[self setTextureByName:t->name];
|
[self setTextureByName: t->name];
|
||||||
[sender selectText:sender];
|
[sender selectText: sender];
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = max - 1; i >= selectedTexture; i--) {
|
for (i = max - 1; i >= selectedTexture; i--) {
|
||||||
t =[textureList_i elementAt:i];
|
t = [textureList_i elementAt: i];
|
||||||
if (!strncmp (t->name, name, len)) {
|
if (!strncmp (t->name, name, len)) {
|
||||||
[self setTextureByName:t->name];
|
[self setTextureByName: t->name];
|
||||||
[sender selectText:sender];
|
[sender selectText: sender];
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set texture def from outside TexturePalette
|
// Set texture def from outside TexturePalette
|
||||||
//
|
//
|
||||||
-setTextureDef:(texturedef_t *) td
|
- (id) setTextureDef: (texturedef_t *)td
|
||||||
{
|
{
|
||||||
[self setTextureByName:td->texture];
|
[self setTextureByName: td->texture];
|
||||||
|
|
||||||
[field_Xshift_i setFloatValue:td->shift[0]];
|
[field_Xshift_i setFloatValue: td->shift[0]];
|
||||||
[field_Yshift_i setFloatValue:td->shift[1]];
|
[field_Yshift_i setFloatValue: td->shift[1]];
|
||||||
[field_Xscale_i setFloatValue:td->scale[0]];
|
[field_Xscale_i setFloatValue: td->scale[0]];
|
||||||
[field_Yscale_i setFloatValue:td->scale[1]];
|
[field_Yscale_i setFloatValue: td->scale[1]];
|
||||||
[field_Rotate_i setFloatValue:td->rotate];
|
[field_Rotate_i setFloatValue: td->rotate];
|
||||||
|
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +606,7 @@ TEX_ForName (const char *name)
|
||||||
//
|
//
|
||||||
// Return the current texture def to passed *
|
// Return the current texture def to passed *
|
||||||
//
|
//
|
||||||
-getTextureDef:(texturedef_t *) td
|
- (id) getTextureDef: (texturedef_t *)td
|
||||||
{
|
{
|
||||||
if (selectedTexture == -1) {
|
if (selectedTexture == -1) {
|
||||||
memset (td, 0, sizeof (*td));
|
memset (td, 0, sizeof (*td));
|
||||||
|
@ -612,32 +614,32 @@ TEX_ForName (const char *name)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy (td->texture,[self getSelTextureName], 16);
|
strncpy (td->texture, [self getSelTextureName], 16);
|
||||||
|
|
||||||
td->shift[0] =[field_Xshift_i floatValue];
|
td->shift[0] = [field_Xshift_i floatValue];
|
||||||
td->shift[1] =[field_Yshift_i floatValue];
|
td->shift[1] = [field_Yshift_i floatValue];
|
||||||
td->scale[0] =[field_Xscale_i floatValue];
|
td->scale[0] = [field_Xscale_i floatValue];
|
||||||
td->scale[1] =[field_Yscale_i floatValue];
|
td->scale[1] = [field_Yscale_i floatValue];
|
||||||
td->rotate =[field_Rotate_i floatValue];
|
td->rotate = [field_Rotate_i floatValue];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Change value in a field
|
// Change value in a field
|
||||||
//
|
//
|
||||||
-changeField:(id)
|
- (id) changeField: (id)
|
||||||
field by:(int) amount
|
field by: (int)amount
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
val =[field intValue];
|
val = [field intValue];
|
||||||
val += amount;
|
val += amount;
|
||||||
[field setIntValue:val];
|
[field setIntValue: val];
|
||||||
|
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -645,91 +647,89 @@ field by:(int) amount
|
||||||
//
|
//
|
||||||
// Inc/Dec the XShift field
|
// Inc/Dec the XShift field
|
||||||
//
|
//
|
||||||
-incXShift:sender
|
- (id) incXShift: sender
|
||||||
{
|
{
|
||||||
[self changeField: field_Xshift_i by:8];
|
[self changeField: field_Xshift_i by: 8];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-decXShift:sender
|
- (id) decXShift: sender
|
||||||
{
|
{
|
||||||
[self changeField: field_Xshift_i by:-8];
|
[self changeField: field_Xshift_i by: -8];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inc/Dec the YShift field
|
// Inc/Dec the YShift field
|
||||||
//
|
//
|
||||||
-incYShift:sender
|
- (id) incYShift: sender
|
||||||
{
|
{
|
||||||
[self changeField: field_Yshift_i by:8];
|
[self changeField: field_Yshift_i by: 8];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-decYShift:sender
|
- (id) decYShift: sender
|
||||||
{
|
{
|
||||||
[self changeField: field_Yshift_i by:-8];
|
[self changeField: field_Yshift_i by: -8];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inc/Dec the Rotate field
|
// Inc/Dec the Rotate field
|
||||||
//
|
//
|
||||||
-incRotate:sender
|
- (id) incRotate: sender
|
||||||
{
|
{
|
||||||
[self changeField: field_Rotate_i by:90];
|
[self changeField: field_Rotate_i by: 90];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-decRotate:sender
|
- (id) decRotate: sender
|
||||||
{
|
{
|
||||||
[self changeField: field_Rotate_i by:-90];
|
[self changeField: field_Rotate_i by: -90];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inc/Dec the Xscale field
|
// Inc/Dec the Xscale field
|
||||||
//
|
//
|
||||||
-incXScale:sender
|
- (id) incXScale: sender
|
||||||
{
|
{
|
||||||
[field_Xscale_i setIntValue:1];
|
[field_Xscale_i setIntValue: 1];
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-decXScale:sender
|
- (id) decXScale: sender
|
||||||
{
|
{
|
||||||
[field_Xscale_i setIntValue:-1];
|
[field_Xscale_i setIntValue: -1];
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inc/Dec the Yscale field
|
// Inc/Dec the Yscale field
|
||||||
//
|
//
|
||||||
-incYScale:sender
|
- (id) incYScale: sender
|
||||||
{
|
{
|
||||||
[field_Yscale_i setIntValue:1];
|
[field_Yscale_i setIntValue: 1];
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-decYScale:sender
|
- (id) decYScale: sender
|
||||||
{
|
{
|
||||||
[field_Yscale_i setIntValue:-1];
|
[field_Yscale_i setIntValue: -1];
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
//============================================================================
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search for texture in entire palette
|
// Search for texture in entire palette
|
||||||
// Return index of texturedef, or -1 if unsuccessful
|
// Return index of texturedef, or -1 if unsuccessful
|
||||||
//
|
//
|
||||||
-(int) searchForTextureInPalette:(const char *) texture
|
- (int) searchForTextureInPalette: (const char *)texture
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
|
@ -738,10 +738,10 @@ field by:(int) amount
|
||||||
if (selectedTexture == -1)
|
if (selectedTexture == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
max =[textureList_i count];
|
max = [textureList_i count];
|
||||||
|
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
t =[textureList_i elementAt:i];
|
t = [textureList_i elementAt: i];
|
||||||
if (!strcmp (t->name, texture))
|
if (!strcmp (t->name, texture))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -751,7 +751,7 @@ field by:(int) amount
|
||||||
//
|
//
|
||||||
// Scan thru map & display only textures that are in map
|
// Scan thru map & display only textures that are in map
|
||||||
//
|
//
|
||||||
-onlyShowMapTextures:sender
|
- (id) onlyShowMapTextures: sender
|
||||||
{
|
{
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
|
@ -764,29 +764,29 @@ field by:(int) amount
|
||||||
|
|
||||||
// Turn 'em off
|
// Turn 'em off
|
||||||
if ([sender intValue]) {
|
if ([sender intValue]) {
|
||||||
max =[textureList_i count];
|
max = [textureList_i count];
|
||||||
for (i = 0; i < max; i++)
|
for (i = 0; i < max; i++)
|
||||||
[self setDisplayFlag: i to:0];
|
[self setDisplayFlag: i to: 0];
|
||||||
|
|
||||||
brushes =[map_i objectAtIndex:0];
|
brushes = [map_i objectAtIndex: 0];
|
||||||
max =[brushes count];
|
max = [brushes count];
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
b = (SetBrush *)[brushes objectAtIndex:i];
|
b = (SetBrush *) [brushes objectAtIndex: i];
|
||||||
numfaces =[b getNumBrushFaces];
|
numfaces = [b getNumBrushFaces];
|
||||||
for (j = 0; j < numfaces; j++) {
|
for (j = 0; j < numfaces; j++) {
|
||||||
f =[b getBrushFace:j];
|
f = [b getBrushFace: j];
|
||||||
index =[self searchForTextureInPalette:f->texture.
|
index = [self searchForTextureInPalette: f->texture.
|
||||||
texture];
|
texture];
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
[self setDisplayFlag: index to:1];
|
[self setDisplayFlag: index to: 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Turn 'em on
|
// Turn 'em on
|
||||||
else {
|
else {
|
||||||
max =[textureList_i count];
|
max = [textureList_i count];
|
||||||
for (i = 0; i < max; i++)
|
for (i = 0; i < max; i++)
|
||||||
[self setDisplayFlag: i to:1];
|
[self setDisplayFlag: i to: 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
[textureView_i display];
|
[textureView_i display];
|
||||||
|
@ -794,12 +794,12 @@ field by:(int) amount
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setDisplayFlag:(int)
|
- (id) setDisplayFlag: (int)
|
||||||
index to:(int) value
|
index to: (int)value
|
||||||
{
|
{
|
||||||
texpal_t *tp;
|
texpal_t *tp;
|
||||||
|
|
||||||
tp =[textureList_i elementAt:index];
|
tp = [textureList_i elementAt: index];
|
||||||
tp->display = value;
|
tp->display = value;
|
||||||
return self;
|
return self;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
@interface TextureView:NSView
|
@interface TextureView: NSView
|
||||||
{
|
{
|
||||||
id parent_i;
|
id parent_i;
|
||||||
int deselectIndex;
|
int deselectIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setParent:(id) from;
|
- (id) setParent: (id)from;
|
||||||
-deselect;
|
- (id) deselect;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // TextureView_h
|
#endif // TextureView_h
|
||||||
|
|
|
@ -14,24 +14,24 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
|
|
||||||
@implementation TextureView
|
@implementation TextureView
|
||||||
|
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
deselectIndex = -1;
|
deselectIndex = -1;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setParent:(id) from
|
- (id) setParent: (id)from
|
||||||
{
|
{
|
||||||
parent_i = from;
|
parent_i = from;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) acceptsFirstMouse
|
- (BOOL) acceptsFirstMouse
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
-drawRect: (NSRect) rects
|
- (id) drawRect: (NSRect)rects
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
|
@ -44,8 +44,8 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
int selected;
|
int selected;
|
||||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
selected =[parent_i getSelectedTexture];
|
selected = [parent_i getSelectedTexture];
|
||||||
list_i =[parent_i getList];
|
list_i = [parent_i getList];
|
||||||
[[NSFont systemFontOfSize: FONTSIZE] set];
|
[[NSFont systemFontOfSize: FONTSIZE] set];
|
||||||
|
|
||||||
[[NSColor lightGrayColor] set];
|
[[NSColor lightGrayColor] set];
|
||||||
|
@ -53,9 +53,8 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
|
|
||||||
if (!list_i) // WADfile didn't init
|
if (!list_i) // WADfile didn't init
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
if (deselectIndex != -1) {
|
if (deselectIndex != -1) {
|
||||||
t =[list_i elementAt:deselectIndex];
|
t = [list_i elementAt: deselectIndex];
|
||||||
r = t->r;
|
r = t->r;
|
||||||
r.origin.x -= TEX_INDENT;
|
r.origin.x -= TEX_INDENT;
|
||||||
r.origin.y -= TEX_INDENT;
|
r.origin.y -= TEX_INDENT;
|
||||||
|
@ -75,11 +74,11 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
deselectIndex = -1;
|
deselectIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
max =[list_i count];
|
max = [list_i count];
|
||||||
[[NSColor blackColor] set];
|
[[NSColor blackColor] set];
|
||||||
|
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
t =[list_i elementAt:i];
|
t = [list_i elementAt: i];
|
||||||
r = t->r;
|
r = t->r;
|
||||||
r.origin.x -= TEX_INDENT / 2;
|
r.origin.x -= TEX_INDENT / 2;
|
||||||
r.size.width += TEX_INDENT;
|
r.size.width += TEX_INDENT;
|
||||||
|
@ -89,7 +88,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
[[NSColor whiteColor] set];
|
[[NSColor whiteColor] set];
|
||||||
NSRectFill (r);
|
NSRectFill (r);
|
||||||
[[NSColor redColor] set];
|
[[NSColor redColor] set];
|
||||||
NSFrameRect(r);
|
NSFrameRect (r);
|
||||||
[[NSColor blackColor] set];
|
[[NSColor blackColor] set];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,13 +104,13 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-deselect
|
- (id) deselect
|
||||||
{
|
{
|
||||||
deselectIndex =[parent_i getSelectedTexture];
|
deselectIndex = [parent_i getSelectedTexture];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-mouseDown:(NSEvent *) theEvent
|
- (id) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint loc;
|
NSPoint loc;
|
||||||
int i;
|
int i;
|
||||||
|
@ -123,17 +122,17 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
NSRect r;
|
NSRect r;
|
||||||
|
|
||||||
// oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
// oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
||||||
loc =[theEvent locationInWindow];
|
loc = [theEvent locationInWindow];
|
||||||
[self convertPoint: loc fromView:NULL];
|
[self convertPoint: loc fromView: NULL];
|
||||||
|
|
||||||
list =[parent_i getList];
|
list = [parent_i getList];
|
||||||
max =[list count];
|
max = [list count];
|
||||||
for (i = 0; i < max; i++) {
|
for (i = 0; i < max; i++) {
|
||||||
t =[list elementAt:i];
|
t = [list elementAt: i];
|
||||||
r = t->r;
|
r = t->r;
|
||||||
if (NSPointInRect (loc, r) == YES) {
|
if (NSPointInRect (loc, r) == YES) {
|
||||||
[self deselect];
|
[self deselect];
|
||||||
[parent_i setSelectedTexture:i];
|
[parent_i setSelectedTexture: i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ extern id things_i;
|
||||||
|
|
||||||
#define ENTITYNAMEKEY "spawn"
|
#define ENTITYNAMEKEY "spawn"
|
||||||
|
|
||||||
@interface Things:NSObject
|
@interface Things: NSObject
|
||||||
{
|
{
|
||||||
id entity_browser_i; // browser
|
id entity_browser_i; // browser
|
||||||
id entity_comment_i; // scrolling text window
|
id entity_comment_i; // scrolling text window
|
||||||
|
@ -23,25 +23,24 @@ extern id things_i;
|
||||||
id flags_i;
|
id flags_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
-initEntities;
|
- (id) initEntities;
|
||||||
|
|
||||||
-newCurrentEntity;
|
- (id) newCurrentEntity;
|
||||||
-setSelectedKey:(epair_t *) ep;
|
- (id) setSelectedKey: (epair_t *)ep;
|
||||||
|
|
||||||
-clearInputs;
|
- (id) clearInputs;
|
||||||
-(const char *) spawnName;
|
- (const char *) spawnName;
|
||||||
|
|
||||||
// UI targets
|
// UI targets
|
||||||
-reloadEntityClasses:sender;
|
- (id) reloadEntityClasses: sender;
|
||||||
-selectEntity:sender;
|
- (id) selectEntity: sender;
|
||||||
-doubleClickEntity:sender;
|
- (id) doubleClickEntity: sender;
|
||||||
|
|
||||||
// Action methods
|
// Action methods
|
||||||
-addPair:sender;
|
- (id) addPair: sender;
|
||||||
-delPair:sender;
|
- (id) delPair: sender;
|
||||||
-setAngle:sender;
|
- (id) setAngle: sender;
|
||||||
-setFlags:sender;
|
- (id) setFlags: sender;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // Things_h
|
#endif // Things_h
|
||||||
|
|
|
@ -12,7 +12,7 @@ id things_i;
|
||||||
|
|
||||||
@implementation Things
|
@implementation Things
|
||||||
|
|
||||||
-init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ id things_i;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)awakeFromNib
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
//FIXME this should not be needed (bug in gnustep?)
|
// FIXME this should not be needed (bug in gnustep?)
|
||||||
[flags_i selectAll: self];
|
[flags_i selectAll: self];
|
||||||
[flags_i deselectAllCells];
|
[flags_i deselectAllCells];
|
||||||
}
|
}
|
||||||
|
@ -32,114 +32,111 @@ id things_i;
|
||||||
//
|
//
|
||||||
// Load the TEXT object with the entity comment
|
// Load the TEXT object with the entity comment
|
||||||
//
|
//
|
||||||
-loadEntityComment:(id) obj
|
- (id) loadEntityComment: (id)obj
|
||||||
{
|
{
|
||||||
[entity_comment_i selectAll:self];
|
[entity_comment_i selectAll: self];
|
||||||
[entity_comment_i replaceCharactersInRange: [entity_comment_i selectedRange] withString: [NSString stringWithCString:[obj
|
[entity_comment_i
|
||||||
comments]]];
|
replaceCharactersInRange: [entity_comment_i selectedRange]
|
||||||
|
withString: [NSString stringWithCString: [obj comments]]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) initEntities
|
||||||
-initEntities
|
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
path =[project_i getProgDirectory];
|
path = [project_i getProgDirectory];
|
||||||
|
|
||||||
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
[prog_path_i setStringValue: [NSString stringWithCString: path]];
|
||||||
|
|
||||||
[[EntityClassList alloc] initForSourceDirectory:path];
|
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||||
|
|
||||||
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
|
||||||
[entity_browser_i loadColumnZero];
|
[entity_browser_i loadColumnZero];
|
||||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
|
||||||
|
|
||||||
[entity_browser_i setDoubleAction: @selector (doubleClickEntity:)];
|
[entity_browser_i setDoubleAction: @selector (doubleClickEntity:)];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-selectEntity:sender
|
- (id) selectEntity: sender
|
||||||
{
|
{
|
||||||
id matr;
|
id matr;
|
||||||
|
|
||||||
matr =[sender matrixInColumn:0];
|
matr = [sender matrixInColumn: 0];
|
||||||
lastSelected =[matr selectedRow];
|
lastSelected = [matr selectedRow];
|
||||||
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
|
||||||
[quakeed_i makeFirstResponder:quakeed_i];
|
[quakeed_i makeFirstResponder: quakeed_i];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-doubleClickEntity:sender
|
- (id) doubleClickEntity: sender
|
||||||
{
|
{
|
||||||
[map_i makeEntity:sender];
|
[map_i makeEntity: sender];
|
||||||
[quakeed_i makeFirstResponder:quakeed_i];
|
[quakeed_i makeFirstResponder: quakeed_i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(const char *) spawnName
|
- (const char *) spawnName
|
||||||
{
|
{
|
||||||
return[[entity_classes_i objectAtIndex:lastSelected] classname];
|
return [[entity_classes_i objectAtIndex: lastSelected] classname];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Flush entity classes & reload them!
|
// Flush entity classes & reload them!
|
||||||
//
|
//
|
||||||
-reloadEntityClasses:sender
|
- (id) reloadEntityClasses: sender
|
||||||
{
|
{
|
||||||
EntityClass *ent;
|
EntityClass *ent;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
path = [[prog_path_i stringValue] cString];
|
path = [[prog_path_i stringValue] cString];
|
||||||
if (!path || !path[0]) {
|
if (!path || !path[0]) {
|
||||||
path =[project_i getProgDirectory];
|
path = [project_i getProgDirectory];
|
||||||
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
[prog_path_i setStringValue: [NSString stringWithCString: path]];
|
||||||
}
|
}
|
||||||
// Free all entity info in memory...
|
// Free all entity info in memory...
|
||||||
[entity_classes_i removeAllObjects];
|
[entity_classes_i removeAllObjects];
|
||||||
[entity_classes_i release];
|
[entity_classes_i release];
|
||||||
|
|
||||||
// Now, RELOAD!
|
// Now, RELOAD!
|
||||||
[[EntityClassList alloc] initForSourceDirectory:path];
|
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||||
|
|
||||||
lastSelected = 0;
|
lastSelected = 0;
|
||||||
ent =[entity_classes_i objectAtIndex:lastSelected];
|
ent = [entity_classes_i objectAtIndex: lastSelected];
|
||||||
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
|
||||||
|
|
||||||
[entity_browser_i loadColumnZero];
|
[entity_browser_i loadColumnZero];
|
||||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
|
||||||
|
|
||||||
[self newCurrentEntity]; // in case flags changed
|
[self newCurrentEntity]; // in case flags changed
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) selectClass: (const char *)class
|
||||||
-selectClass:(const char *) class
|
|
||||||
{
|
{
|
||||||
id classent;
|
id classent;
|
||||||
|
|
||||||
classent =[entity_classes_i classForName:class];
|
classent = [entity_classes_i classForName: class];
|
||||||
if (!classent)
|
if (!classent)
|
||||||
return self;
|
return self;
|
||||||
lastSelected =[entity_classes_i indexOfObject:classent];
|
lastSelected = [entity_classes_i indexOfObject: classent];
|
||||||
|
|
||||||
if (lastSelected < 0)
|
if (lastSelected < 0)
|
||||||
lastSelected = 0;
|
lastSelected = 0;
|
||||||
|
[self loadEntityComment: classent];
|
||||||
[self loadEntityComment:classent];
|
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
|
||||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
[[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected
|
||||||
[[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected column:0];
|
column: 0];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) newCurrentEntity
|
||||||
-newCurrentEntity
|
|
||||||
{
|
{
|
||||||
id ent, classent, cell;
|
id ent, classent, cell;
|
||||||
const char *classname;
|
const char *classname;
|
||||||
|
@ -147,28 +144,29 @@ id things_i;
|
||||||
const char *flagname;
|
const char *flagname;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
ent =[map_i currentEntity];
|
ent = [map_i currentEntity];
|
||||||
classname =[ent valueForQKey:"classname"];
|
classname = [ent valueForQKey: "classname"];
|
||||||
if (ent !=[map_i objectAtIndex:0])
|
if (ent != [map_i objectAtIndex: 0])
|
||||||
[self selectClass:classname]; // don't reset for world
|
[self selectClass: classname]; // don't reset for world
|
||||||
classent =[entity_classes_i classForName:classname];
|
classent = [entity_classes_i classForName: classname];
|
||||||
flagname =[ent valueForQKey:"spawnflags"];
|
flagname = [ent valueForQKey: "spawnflags"];
|
||||||
if (!flagname)
|
if (!flagname)
|
||||||
flags = 0;
|
flags = 0;
|
||||||
else
|
else
|
||||||
flags = atoi (flagname);
|
flags = atoi (flagname);
|
||||||
|
|
||||||
//[flags_i setAutodisplay:NO];
|
// [flags_i setAutodisplay:NO];
|
||||||
for (r = 0; r < 4; r++)
|
for (r = 0; r < 4; r++) {
|
||||||
for (c = 0; c < 3; c++) {
|
for (c = 0; c < 3; c++) {
|
||||||
cell =[flags_i cellAtRow: r column:c];
|
cell = [flags_i cellAtRow: r column: c];
|
||||||
if (c < 2) {
|
if (c < 2) {
|
||||||
flagname =[classent flagName:c * 4 + r];
|
flagname = [classent flagName: c * 4 + r];
|
||||||
[cell setTitle: [NSString stringWithCString:flagname]];
|
[cell setTitle: [NSString stringWithCString: flagname]];
|
||||||
}
|
}
|
||||||
[cell setIntValue:(flags & (1 << ((c * 4) + r))) > 0];
|
[cell setIntValue: (flags & (1 << ((c * 4) + r))) > 0];
|
||||||
}
|
}
|
||||||
//[flags_i setAutodisplay:YES];
|
}
|
||||||
|
// [flags_i setAutodisplay:YES];
|
||||||
[flags_i display];
|
[flags_i display];
|
||||||
|
|
||||||
// [keyInput_i setStringValue: ""];
|
// [keyInput_i setStringValue: ""];
|
||||||
|
@ -177,27 +175,27 @@ id things_i;
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
|
||||||
[quakeed_i makeFirstResponder:quakeed_i];
|
[quakeed_i makeFirstResponder: quakeed_i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clicked in the Keypair view - set as selected
|
// Clicked in the Keypair view - set as selected
|
||||||
//
|
//
|
||||||
-setSelectedKey:(epair_t *) ep;
|
- (id) setSelectedKey: (epair_t *)ep;
|
||||||
{
|
{
|
||||||
[keyInput_i setStringValue: [NSString stringWithCString:ep->key]];
|
[keyInput_i setStringValue: [NSString stringWithCString: ep->key]];
|
||||||
[valueInput_i setStringValue: [NSString stringWithCString:ep->value]];
|
[valueInput_i setStringValue: [NSString stringWithCString: ep->value]];
|
||||||
[valueInput_i selectText:self];
|
[valueInput_i selectText: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-clearInputs
|
- (id) clearInputs
|
||||||
{
|
{
|
||||||
// [keyInput_i setStringValue: ""];
|
// [keyInput_i setStringValue: ""];
|
||||||
// [valueInput_i setStringValue: ""];
|
// [valueInput_i setStringValue: ""];
|
||||||
|
|
||||||
[quakeed_i makeFirstResponder:quakeed_i];
|
[quakeed_i makeFirstResponder: quakeed_i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,14 +203,14 @@ id things_i;
|
||||||
// Action methods
|
// Action methods
|
||||||
//
|
//
|
||||||
|
|
||||||
-addPair:sender
|
- (id) addPair: sender
|
||||||
{
|
{
|
||||||
const char *key, *value;
|
const char *key, *value;
|
||||||
|
|
||||||
key = [[keyInput_i stringValue] cString];
|
key = [[keyInput_i stringValue] cString];
|
||||||
value = [[valueInput_i stringValue] cString];
|
value = [[valueInput_i stringValue] cString];
|
||||||
|
|
||||||
[[map_i currentEntity] setKey: key toValue:value];
|
[[map_i currentEntity] setKey: key toValue: value];
|
||||||
|
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
@ -223,11 +221,11 @@ id things_i;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-delPair:sender
|
- (id) delPair: sender
|
||||||
{
|
{
|
||||||
[quakeed_i makeFirstResponder:quakeed_i];
|
[quakeed_i makeFirstResponder: quakeed_i];
|
||||||
|
|
||||||
[[map_i currentEntity] removeKeyPair:[[keyInput_i stringValue] cString]];
|
[[map_i currentEntity] removeKeyPair: [[keyInput_i stringValue] cString]];
|
||||||
|
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
@ -239,23 +237,22 @@ id things_i;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the key/value fields to "angle <button value>"
|
// Set the key/value fields to "angle <button value>"
|
||||||
//
|
//
|
||||||
-setAngle:sender
|
- (id) setAngle: sender
|
||||||
{
|
{
|
||||||
NSString *value;
|
NSString *value;
|
||||||
|
|
||||||
value = [[sender selectedCell] title];
|
value = [[sender selectedCell] title];
|
||||||
if (![value compare:@"Up"])
|
if (![value compare: @"Up"])
|
||||||
value = @"-1";
|
value = @"-1";
|
||||||
else if (![value compare:@"Dn"])
|
else if (![value compare: @"Dn"])
|
||||||
value = @"-2";
|
value = @"-2";
|
||||||
|
|
||||||
[keyInput_i setStringValue:@"angle"];
|
[keyInput_i setStringValue: @"angle"];
|
||||||
[valueInput_i setStringValue: value];
|
[valueInput_i setStringValue: value];
|
||||||
[self addPair:NULL];
|
[self addPair: NULL];
|
||||||
|
|
||||||
[self clearInputs];
|
[self clearInputs];
|
||||||
|
|
||||||
|
@ -264,7 +261,7 @@ id things_i;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setFlags:sender
|
- (id) setFlags: sender
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
int r, c, i;
|
int r, c, i;
|
||||||
|
@ -273,17 +270,18 @@ id things_i;
|
||||||
[self clearInputs];
|
[self clearInputs];
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
for (r = 0; r < 4; r++)
|
for (r = 0; r < 4; r++) {
|
||||||
for (c = 0; c < 3; c++) {
|
for (c = 0; c < 3; c++) {
|
||||||
cell =[flags_i cellAtRow: r column:c];
|
cell = [flags_i cellAtRow: r column: c];
|
||||||
i = ([cell intValue] > 0);
|
i = ([cell intValue] > 0);
|
||||||
flags |= (i << ((c * 4) + r));
|
flags |= (i << ((c * 4) + r));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!flags)
|
if (!flags)
|
||||||
[[map_i currentEntity] removeKeyPair:"spawnflags"];
|
[[map_i currentEntity] removeKeyPair: "spawnflags"];
|
||||||
else
|
else
|
||||||
[[map_i currentEntity] setKey: "spawnflags" toValue:va ("%i", flags)];
|
[[map_i currentEntity] setKey: "spawnflags" toValue: va ("%i", flags)];
|
||||||
|
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
@ -291,28 +289,29 @@ id things_i;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fill the Entity browser
|
// Fill the Entity browser
|
||||||
// (Delegate method - delegated in Interface Builder)
|
// (Delegate method - delegated in Interface Builder)
|
||||||
//
|
//
|
||||||
-(void) browser: sender createRowsForColumn:(int) column inMatrix: matrix
|
- (void) browser: sender
|
||||||
|
createRowsForColumn: (int)column
|
||||||
|
inMatrix: matrix
|
||||||
{
|
{
|
||||||
id cell;
|
id cell;
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
id object;
|
id object;
|
||||||
|
|
||||||
max =[entity_classes_i count];
|
max = [entity_classes_i count];
|
||||||
i = 0;
|
i = 0;
|
||||||
while (max--) {
|
while (max--) {
|
||||||
object =[entity_classes_i objectAtIndex:i];
|
object = [entity_classes_i objectAtIndex: i];
|
||||||
[matrix addRow];
|
[matrix addRow];
|
||||||
cell =[matrix cellAtRow: i++ column:0];
|
cell = [matrix cellAtRow: i++ column: 0];
|
||||||
[cell setStringValue: [NSString stringWithCString:[object
|
[cell setStringValue: [NSString
|
||||||
classname]]];
|
stringWithCString: [object classname]]];
|
||||||
[cell setLeaf:YES];
|
[cell setLeaf: YES];
|
||||||
[cell setLoaded:YES];
|
[cell setLoaded: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ extern id xyview_i;
|
||||||
#define MINSCALE 0.125
|
#define MINSCALE 0.125
|
||||||
#define MAXSCALE 2.0
|
#define MAXSCALE 2.0
|
||||||
|
|
||||||
|
|
||||||
extern vec3_t xy_viewnormal; // v_forward for xy view
|
extern vec3_t xy_viewnormal; // v_forward for xy view
|
||||||
extern float xy_viewdist; // clip behind this plane
|
extern float xy_viewdist; // clip behind this plane
|
||||||
|
|
||||||
|
@ -27,51 +26,57 @@ void linecolor (float r, float g, float b);
|
||||||
void XYmoveto (vec3_t pt);
|
void XYmoveto (vec3_t pt);
|
||||||
void XYlineto (vec3_t pt);
|
void XYlineto (vec3_t pt);
|
||||||
|
|
||||||
|
@interface XYView: NSView
|
||||||
|
|
||||||
@interface XYView:NSView
|
|
||||||
{
|
{
|
||||||
NSRect realbounds, newrect, combinedrect;
|
NSRect realbounds, newrect, combinedrect;
|
||||||
NSPoint midpoint;
|
NSPoint midpoint;
|
||||||
int gridsize;
|
int gridsize;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
|
//
|
||||||
// for textured view
|
// for textured view
|
||||||
|
//
|
||||||
int xywidth, xyheight;
|
int xywidth, xyheight;
|
||||||
float *xyzbuffer;
|
float *xyzbuffer;
|
||||||
unsigned *xypicbuffer;
|
unsigned *xypicbuffer;
|
||||||
|
|
||||||
drawmode_t drawmode;
|
drawmode_t drawmode;
|
||||||
|
|
||||||
|
//
|
||||||
// UI links
|
// UI links
|
||||||
|
//
|
||||||
id mode_radio_i;
|
id mode_radio_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float) currentScale;
|
- (float) currentScale;
|
||||||
|
|
||||||
-setModeRadio:m;
|
- (id) setModeRadio: m;
|
||||||
|
|
||||||
-drawMode:sender;
|
- (id) drawMode: sender;
|
||||||
-setDrawMode:(drawmode_t) mode;
|
- (id) setDrawMode: (drawmode_t)mode;
|
||||||
|
|
||||||
-newSuperBounds;
|
- (id) newSuperBounds;
|
||||||
-newRealBounds:(NSRect) nb;
|
- (id) newRealBounds: (NSRect)nb;
|
||||||
|
|
||||||
-addToScrollRange: (float) x:(float) y;
|
- (id) addToScrollRange: (float)x
|
||||||
-setOrigin:(NSPoint) pt scale:(float) sc;
|
: (float)y;
|
||||||
|
|
||||||
-centerOn:(vec3_t) org;
|
- (id) setOrigin: (NSPoint)pt scale: (float)sc;
|
||||||
|
|
||||||
-drawMode:sender;
|
- (id) centerOn: (vec3_t)org;
|
||||||
|
|
||||||
-superviewChanged;
|
- (id) drawMode: sender;
|
||||||
|
|
||||||
-(int) gridsize;
|
- (id) superviewChanged;
|
||||||
-(float) snapToGrid:(float) f;
|
|
||||||
|
- (int) gridsize;
|
||||||
|
- (float) snapToGrid: (float)f;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSView(XYView)
|
@interface NSView (XYView)
|
||||||
-(void) setFrame:(NSRect) frame bounds:(NSRect) bounds scale:(NSSize) scale;
|
- (void) setFrame: (NSRect)frame
|
||||||
|
bounds: (NSRect)bounds
|
||||||
|
scale: (NSSize)scale;
|
||||||
@end
|
@end
|
||||||
#endif // XYView_h
|
#endif // XYView_h
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,14 +3,15 @@
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
@interface ZScrollView:NSScrollView
|
@interface ZScrollView: NSScrollView
|
||||||
{
|
{
|
||||||
id button1;
|
id button1;
|
||||||
}
|
}
|
||||||
|
|
||||||
-initWithFrame:(NSRect) frameRect button1:b1;
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
|
button1: b1;
|
||||||
|
|
||||||
-tile;
|
- (id) tile;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // ZScrollView_h
|
#endif // ZScrollView_h
|
||||||
|
|
|
@ -8,21 +8,23 @@ initWithFrame: button:
|
||||||
Initizes a scroll view with a button at it's lower right corner
|
Initizes a scroll view with a button at it's lower right corner
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
- initWithFrame:(NSRect) frameRect button1:b1
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
|
button1: b1
|
||||||
{
|
{
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame: frameRect];
|
||||||
|
|
||||||
[self addSubview:b1];
|
[self addSubview: b1];
|
||||||
|
|
||||||
button1 = b1;
|
button1 = b1;
|
||||||
|
|
||||||
[self setHasHorizontalScroller:YES];
|
[self setHasHorizontalScroller: YES];
|
||||||
[self setHasVerticalScroller:YES];
|
[self setHasVerticalScroller: YES];
|
||||||
|
|
||||||
[self setBorderType:NSBezelBorder];
|
[self setBorderType: NSBezelBorder];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
tile
|
tile
|
||||||
|
@ -30,30 +32,28 @@ tile
|
||||||
Adjust the size for the pop up scale menu
|
Adjust the size for the pop up scale menu
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
-tile
|
- (id) tile
|
||||||
{
|
{
|
||||||
NSRect scrollerframe;
|
NSRect scrollerframe;
|
||||||
|
|
||||||
[super tile];
|
[super tile];
|
||||||
scrollerframe =[_horizScroller frame];
|
scrollerframe = [_horizScroller frame];
|
||||||
[button1 setFrame:scrollerframe];
|
[button1 setFrame: scrollerframe];
|
||||||
|
|
||||||
scrollerframe.size.width = 0;
|
scrollerframe.size.width = 0;
|
||||||
[_horizScroller setFrame:scrollerframe];
|
[_horizScroller setFrame: scrollerframe];
|
||||||
[_horizScroller setHidden:YES];
|
[_horizScroller setHidden: YES];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) acceptsFirstResponder
|
||||||
|
|
||||||
-(BOOL) acceptsFirstResponder
|
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#if 0
|
||||||
- superviewSizeChanged:(const NSSize *)oldSize
|
- (id) superviewSizeChanged: (const NSSize *)oldSize
|
||||||
{
|
{
|
||||||
[super superviewSizeChanged: oldSize];
|
[super superviewSizeChanged: oldSize];
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ Adjust the size for the pop up scale menu
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern id zview_i;
|
||||||
extern float zplane;
|
extern float zplane;
|
||||||
extern float zplanedir;
|
extern float zplanedir;
|
||||||
|
|
||||||
@interface ZView:NSView
|
@interface ZView: NSView
|
||||||
{
|
{
|
||||||
float minheight, maxheight;
|
float minheight, maxheight;
|
||||||
float oldminheight, oldmaxheight;
|
float oldminheight, oldmaxheight;
|
||||||
|
@ -26,24 +26,25 @@ extern float zplanedir;
|
||||||
NSBezierPath *checker;
|
NSBezierPath *checker;
|
||||||
}
|
}
|
||||||
|
|
||||||
-clearBounds;
|
- (id) clearBounds;
|
||||||
-getBounds: (float *) top:(float *) bottom;
|
- (id) getBounds: (float *)top
|
||||||
|
: (float *)bottom;
|
||||||
|
|
||||||
-getPoint:(NSPoint *) pt;
|
- (id) getPoint: (NSPoint *)pt;
|
||||||
-setPoint:(NSPoint *) pt;
|
- (id) setPoint: (NSPoint *)pt;
|
||||||
|
|
||||||
-addToHeightRange:(float) height;
|
- (id) addToHeightRange: (float)height;
|
||||||
|
|
||||||
-newRealBounds;
|
- (id) newRealBounds;
|
||||||
-newSuperBounds;
|
- (id) newSuperBounds;
|
||||||
|
|
||||||
-XYDrawSelf;
|
- (void) XYDrawSelf;
|
||||||
|
|
||||||
-(BOOL) XYmouseDown:(NSPoint *) pt;
|
- (BOOL) XYmouseDown: (NSPoint *)pt;
|
||||||
|
|
||||||
-setXYOrigin:(NSPoint *) pt;
|
- (id) setXYOrigin: (NSPoint *)pt;
|
||||||
|
|
||||||
-setOrigin:(NSPoint) pt scale:(float) sc;
|
- (id) setOrigin: (NSPoint)pt scale: (float)sc;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif // ZView_h
|
#endif // ZView_h
|
||||||
|
|
|
@ -22,7 +22,7 @@ extern NSBezierPath *path;
|
||||||
initWithFrame:
|
initWithFrame:
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
- (id) initWithFrame:(NSRect) frameRect
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
NSBezierPath *path;
|
NSBezierPath *path;
|
||||||
|
@ -37,7 +37,7 @@ initWithFrame:
|
||||||
origin[0] = 0.333;
|
origin[0] = 0.333;
|
||||||
origin[1] = 0.333;
|
origin[1] = 0.333;
|
||||||
|
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame: frameRect];
|
||||||
[self allocateGState];
|
[self allocateGState];
|
||||||
[self clearBounds];
|
[self clearBounds];
|
||||||
|
|
||||||
|
@ -47,26 +47,27 @@ initWithFrame:
|
||||||
//
|
//
|
||||||
// initialize the pop up menus
|
// initialize the pop up menus
|
||||||
//
|
//
|
||||||
zscalebutton_i =[[NSPopUpButton alloc] init];
|
zscalebutton_i = [[NSPopUpButton alloc] init];
|
||||||
[zscalebutton_i setTarget:self];
|
[zscalebutton_i setTarget: self];
|
||||||
[zscalebutton_i setAction: @selector (scaleMenuTarget:)];
|
[zscalebutton_i setAction: @selector (scaleMenuTarget:)];
|
||||||
|
|
||||||
[zscalebutton_i addItemWithTitle:@"12.5%"];
|
[zscalebutton_i addItemWithTitle: @"12.5%"];
|
||||||
[zscalebutton_i addItemWithTitle:@"25%"];
|
[zscalebutton_i addItemWithTitle: @"25%"];
|
||||||
[zscalebutton_i addItemWithTitle:@"50%"];
|
[zscalebutton_i addItemWithTitle: @"50%"];
|
||||||
[zscalebutton_i addItemWithTitle:@"75%"];
|
[zscalebutton_i addItemWithTitle: @"75%"];
|
||||||
[zscalebutton_i addItemWithTitle:@"100%"];
|
[zscalebutton_i addItemWithTitle: @"100%"];
|
||||||
[zscalebutton_i addItemWithTitle:@"200%"];
|
[zscalebutton_i addItemWithTitle: @"200%"];
|
||||||
[zscalebutton_i addItemWithTitle:@"300%"];
|
[zscalebutton_i addItemWithTitle: @"300%"];
|
||||||
[zscalebutton_i selectItemAtIndex:4];
|
[zscalebutton_i selectItemAtIndex: 4];
|
||||||
|
|
||||||
// initialize the scroll view
|
// initialize the scroll view
|
||||||
zscrollview_i =[[ZScrollView alloc] initWithFrame: frameRect
|
zscrollview_i = [[ZScrollView alloc]
|
||||||
|
initWithFrame: frameRect
|
||||||
button1: zscalebutton_i];
|
button1: zscalebutton_i];
|
||||||
[zscrollview_i setAutoresizingMask:NSViewWidthSizable |
|
[zscrollview_i setAutoresizingMask: NSViewWidthSizable |
|
||||||
NSViewHeightSizable];
|
NSViewHeightSizable];
|
||||||
|
|
||||||
[zscrollview_i setDocumentView:self];
|
[zscrollview_i setDocumentView: self];
|
||||||
|
|
||||||
[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
|
[_super_view setBoundsOrigin: NSMakePoint (0, 0)];
|
||||||
|
|
||||||
|
@ -78,19 +79,19 @@ initWithFrame:
|
||||||
|
|
||||||
[self newRealBounds];
|
[self newRealBounds];
|
||||||
|
|
||||||
[self setOrigin: pt scale:1];
|
[self setOrigin: pt scale: 1];
|
||||||
|
|
||||||
return zscrollview_i;
|
return zscrollview_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setXYOrigin:(NSPoint *) pt
|
- (id) setXYOrigin: (NSPoint *)pt
|
||||||
{
|
{
|
||||||
origin[0] = pt->x + 0.333;
|
origin[0] = pt->x + 0.333;
|
||||||
origin[1] = pt->y + 0.333;
|
origin[1] = pt->y + 0.333;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(float) currentScale
|
- (float) currentScale
|
||||||
{
|
{
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,7 @@ initWithFrame:
|
||||||
setOrigin:scale:
|
setOrigin:scale:
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-setOrigin:(NSPoint) pt scale:(float) sc
|
- (id) setOrigin: (NSPoint)pt scale: (float)sc
|
||||||
{
|
{
|
||||||
NSRect sframe;
|
NSRect sframe;
|
||||||
NSRect bounds;
|
NSRect bounds;
|
||||||
|
@ -109,7 +110,7 @@ setOrigin:scale:
|
||||||
// calculate the area visible in the cliprect
|
// calculate the area visible in the cliprect
|
||||||
scale = sc;
|
scale = sc;
|
||||||
|
|
||||||
bounds =[_super_view bounds];
|
bounds = [_super_view bounds];
|
||||||
bounds.origin = pt;
|
bounds.origin = pt;
|
||||||
bounds.size.width /= 1;
|
bounds.size.width /= 1;
|
||||||
bounds.size.height /= scale;
|
bounds.size.height /= scale;
|
||||||
|
@ -118,7 +119,7 @@ setOrigin:scale:
|
||||||
// union with the realbounds
|
// union with the realbounds
|
||||||
bounds = NSUnionRect (size, bounds);
|
bounds = NSUnionRect (size, bounds);
|
||||||
// redisplay everything
|
// redisplay everything
|
||||||
bounds.origin = NSMakePoint (-bounds.size.width/2, bounds.origin.y);
|
bounds.origin = NSMakePoint (-bounds.size.width / 2, bounds.origin.y);
|
||||||
sframe = bounds;
|
sframe = bounds;
|
||||||
sframe.origin.x *= 1;
|
sframe.origin.x *= 1;
|
||||||
sframe.origin.y *= scale;
|
sframe.origin.y *= scale;
|
||||||
|
@ -127,7 +128,7 @@ setOrigin:scale:
|
||||||
|
|
||||||
// size this view
|
// size this view
|
||||||
[quakeed_i disableFlushWindow];
|
[quakeed_i disableFlushWindow];
|
||||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
[self setFrame: sframe bounds: bounds scale: NSMakeSize (1, scale)];
|
||||||
|
|
||||||
// scroll and scale the clip view
|
// scroll and scale the clip view
|
||||||
pt.x *= 1;
|
pt.x *= 1;
|
||||||
|
@ -140,7 +141,6 @@ setOrigin:scale:
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
scaleMenuTarget:
|
scaleMenuTarget:
|
||||||
|
@ -148,22 +148,21 @@ scaleMenuTarget:
|
||||||
Called when the scaler popup on the window is used
|
Called when the scaler popup on the window is used
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
-scaleMenuTarget:sender
|
- (id) scaleMenuTarget: sender
|
||||||
{
|
{
|
||||||
char const *item;
|
char const *item;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
NSPoint mid, org, orig;
|
NSPoint mid, org, orig;
|
||||||
float nscale;
|
float nscale;
|
||||||
|
|
||||||
item =[[sender titleOfSelectedItem] cString];
|
item = [[sender titleOfSelectedItem] cString];
|
||||||
sscanf (item, "%f", &nscale);
|
sscanf (item, "%f", &nscale);
|
||||||
nscale /= 100;
|
nscale /= 100;
|
||||||
|
|
||||||
if (nscale == scale)
|
if (nscale == scale)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
// keep the center of the view constant
|
||||||
// keep the center of the view constant
|
rect = [_super_view bounds];
|
||||||
rect =[_super_view bounds];
|
|
||||||
mid.x = rect.size.width / 2;
|
mid.x = rect.size.width / 2;
|
||||||
mid.y = rect.size.height / 2;
|
mid.y = rect.size.height / 2;
|
||||||
|
|
||||||
|
@ -173,13 +172,12 @@ Called when the scaler popup on the window is used
|
||||||
orig.x = org.x - mid.x / 1;
|
orig.x = org.x - mid.x / 1;
|
||||||
orig.y = org.y - mid.y / nscale;
|
orig.y = org.y - mid.y / nscale;
|
||||||
|
|
||||||
[self setOrigin: orig scale:nscale];
|
[self setOrigin: orig scale: nscale];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) clearBounds
|
||||||
-clearBounds
|
|
||||||
{
|
{
|
||||||
topbound = 999999;
|
topbound = 999999;
|
||||||
bottombound = -999999;
|
bottombound = -999999;
|
||||||
|
@ -187,20 +185,19 @@ Called when the scaler popup on the window is used
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-getBounds: (float *) top:(float *) bottom;
|
- (id) getBounds: (float *)top: (float *)bottom;
|
||||||
{
|
{
|
||||||
*top = topbound;
|
*top = topbound;
|
||||||
*bottom = bottombound;
|
*bottom = bottombound;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
addToHeightRange:
|
addToHeightRange:
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
-addToHeightRange:(float) height
|
- (id) addToHeightRange: (float)height
|
||||||
{
|
{
|
||||||
if (height < minheight)
|
if (height < minheight)
|
||||||
minheight = height;
|
minheight = height;
|
||||||
|
@ -209,7 +206,6 @@ addToHeightRange:
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
newSuperBounds
|
newSuperBounds
|
||||||
|
@ -217,7 +213,7 @@ newSuperBounds
|
||||||
When _super_view is resized
|
When _super_view is resized
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
-newSuperBounds
|
- (id) newSuperBounds
|
||||||
{
|
{
|
||||||
oldminheight++;
|
oldminheight++;
|
||||||
[self newRealBounds];
|
[self newRealBounds];
|
||||||
|
@ -225,7 +221,6 @@ When _super_view is resized
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
newRealBounds
|
newRealBounds
|
||||||
|
@ -234,7 +229,7 @@ Should only change the scroll bars, not cause any redraws.
|
||||||
If realbounds has shrunk, nothing will change.
|
If realbounds has shrunk, nothing will change.
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-newRealBounds
|
- (id) newRealBounds
|
||||||
{
|
{
|
||||||
NSRect bounds;
|
NSRect bounds;
|
||||||
NSRect sframe;
|
NSRect sframe;
|
||||||
|
@ -244,7 +239,6 @@ If realbounds has shrunk, nothing will change.
|
||||||
|
|
||||||
if (minheight == oldminheight && maxheight == oldmaxheight)
|
if (minheight == oldminheight && maxheight == oldmaxheight)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
oldminheight = minheight;
|
oldminheight = minheight;
|
||||||
oldmaxheight = maxheight;
|
oldmaxheight = maxheight;
|
||||||
|
|
||||||
|
@ -252,7 +246,7 @@ If realbounds has shrunk, nothing will change.
|
||||||
maxheight += 16;
|
maxheight += 16;
|
||||||
|
|
||||||
// calculate the area visible in the cliprect
|
// calculate the area visible in the cliprect
|
||||||
bounds =[cv bounds];
|
bounds = [cv bounds];
|
||||||
bounds.size.width /= 1;
|
bounds.size.width /= 1;
|
||||||
bounds.size.height /= scale;
|
bounds.size.height /= scale;
|
||||||
|
|
||||||
|
@ -266,7 +260,7 @@ If realbounds has shrunk, nothing will change.
|
||||||
|
|
||||||
// size this view
|
// size this view
|
||||||
[quakeed_i disableFlushWindow];
|
[quakeed_i disableFlushWindow];
|
||||||
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)];
|
[self setFrame: sframe bounds: bounds scale: NSMakeSize (1, scale)];
|
||||||
|
|
||||||
[[_super_view superview] reflectScrolledClipView: cv];
|
[[_super_view superview] reflectScrolledClipView: cv];
|
||||||
|
|
||||||
|
@ -276,8 +270,6 @@ If realbounds has shrunk, nothing will change.
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
drawGrid
|
drawGrid
|
||||||
|
@ -289,7 +281,7 @@ Rect is in global world (unscaled) coordinates
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
|
|
||||||
-drawGrid:(NSRect) rect
|
- (id) drawGrid: (NSRect)rect
|
||||||
{
|
{
|
||||||
int y, stopy;
|
int y, stopy;
|
||||||
float top, bottom;
|
float top, bottom;
|
||||||
|
@ -298,20 +290,21 @@ Rect is in global world (unscaled) coordinates
|
||||||
BOOL showcoords;
|
BOOL showcoords;
|
||||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
showcoords =[quakeed_i showCoordinates];
|
showcoords = [quakeed_i showCoordinates];
|
||||||
|
|
||||||
gridsize =[xyview_i gridsize];
|
gridsize = [xyview_i gridsize];
|
||||||
|
|
||||||
left = _bounds.origin.x;
|
left = _bounds.origin.x;
|
||||||
right = 24;
|
right = 24;
|
||||||
bottom = rect.origin.y - 1;
|
bottom = rect.origin.y - 1;
|
||||||
top = rect.origin.y + rect.size.height + 2;
|
top = rect.origin.y + rect.size.height + 2;
|
||||||
|
|
||||||
//
|
//
|
||||||
// grid
|
// grid
|
||||||
//
|
//
|
||||||
// can't just divide by grid size because of negetive coordinate
|
|
||||||
// truncating direction
|
// can't just divide by grid size because of negetive coordinate
|
||||||
//
|
// truncating direction
|
||||||
if (gridsize >= 4 / scale) {
|
if (gridsize >= 4 / scale) {
|
||||||
y = floor (bottom / gridsize);
|
y = floor (bottom / gridsize);
|
||||||
stopy = floor (top / gridsize);
|
stopy = floor (top / gridsize);
|
||||||
|
@ -320,19 +313,23 @@ Rect is in global world (unscaled) coordinates
|
||||||
stopy *= gridsize;
|
stopy *= gridsize;
|
||||||
if (y < bottom)
|
if (y < bottom)
|
||||||
y += gridsize;
|
y += gridsize;
|
||||||
|
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
|
|
||||||
for (; y <= stopy; y += gridsize)
|
for ( ; y <= stopy; y += gridsize) {
|
||||||
if (y & 31) {
|
if (y & 31) {
|
||||||
[path moveToPoint:NSMakePoint (left, y)];
|
[path moveToPoint: NSMakePoint (left, y)];
|
||||||
[path lineToPoint:NSMakePoint (right, y)];
|
[path lineToPoint: NSMakePoint (right, y)];
|
||||||
}
|
}
|
||||||
// endUserPath (upath, dps_ustroke);
|
}
|
||||||
[[NSColor colorWithCalibratedRed: 0.8 green: 0.8 blue: 1.0 alpha: 1.0]
|
|
||||||
set]; // thin grid color
|
// endUserPath (upath, dps_ustroke);
|
||||||
|
[[NSColor colorWithCalibratedRed: 0.8
|
||||||
|
green: 0.8
|
||||||
|
blue: 1.0
|
||||||
|
alpha: 1.0] set]; // thin grid color
|
||||||
[path stroke];
|
[path stroke];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// half tiles
|
// half tiles
|
||||||
//
|
//
|
||||||
|
@ -345,12 +342,11 @@ Rect is in global world (unscaled) coordinates
|
||||||
stopy *= 32;
|
stopy *= 32;
|
||||||
if (stopy >= top)
|
if (stopy >= top)
|
||||||
stopy -= 32;
|
stopy -= 32;
|
||||||
|
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
|
|
||||||
for (; y <= stopy; y += 64) {
|
for ( ; y <= stopy; y += 64) {
|
||||||
[path moveToPoint:NSMakePoint (left, y)];
|
[path moveToPoint: NSMakePoint (left, y)];
|
||||||
[path lineToPoint:NSMakePoint (right, y)];
|
[path lineToPoint: NSMakePoint (right, y)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// endUserPath (upath, dps_ustroke);
|
// endUserPath (upath, dps_ustroke);
|
||||||
|
@ -370,36 +366,32 @@ Rect is in global world (unscaled) coordinates
|
||||||
y += 64;
|
y += 64;
|
||||||
if (stopy >= top)
|
if (stopy >= top)
|
||||||
stopy -= 64;
|
stopy -= 64;
|
||||||
|
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0]
|
|
||||||
set]; // for text
|
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0] set]; // for text
|
||||||
[[NSFont systemFontOfSize: 10] set];
|
[[NSFont systemFontOfSize: 10] set];
|
||||||
|
|
||||||
for (; y <= stopy; y += 64) {
|
for ( ; y <= stopy; y += 64) {
|
||||||
if (showcoords) {
|
if (showcoords) {
|
||||||
NSString *s = [NSString stringWithFormat: @"%i", y];
|
NSString *s = [NSString stringWithFormat: @"%i", y];
|
||||||
[s drawAtPoint: NSMakePoint (left, y) withAttributes: attribs];
|
[s drawAtPoint: NSMakePoint (left, y) withAttributes: attribs];
|
||||||
}
|
}
|
||||||
[path moveToPoint:NSMakePoint (left + 24, y)];
|
[path moveToPoint: NSMakePoint (left + 24, y)];
|
||||||
[path lineToPoint:NSMakePoint (right, y)];
|
[path lineToPoint: NSMakePoint (right, y)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// divider
|
// divider
|
||||||
[path moveToPoint:NSMakePoint (0, _bounds.origin.y)];
|
[path moveToPoint: NSMakePoint (0, _bounds.origin.y)];
|
||||||
[path lineToPoint:NSMakePoint (0,
|
[path lineToPoint: NSMakePoint (0, _bounds.origin.y + _bounds.size.height)];
|
||||||
_bounds.origin.y + _bounds.size.height)];
|
|
||||||
|
|
||||||
// endUserPath (upath, dps_ustroke);
|
// endUserPath (upath, dps_ustroke);
|
||||||
[[NSColor colorWithCalibratedWhite: 10.0 / 16.0 alpha: 1.0]
|
[[NSColor colorWithCalibratedWhite: 10.0 / 16.0 alpha: 1.0] set];
|
||||||
set];
|
|
||||||
[path stroke];
|
[path stroke];
|
||||||
|
|
||||||
//
|
//
|
||||||
// origin
|
// origin
|
||||||
//
|
//
|
||||||
[[NSColor colorWithCalibratedWhite: 4.0 / 16.0 alpha: 1.0]
|
[[NSColor colorWithCalibratedWhite: 4.0 / 16.0 alpha: 1.0] set];
|
||||||
set];
|
|
||||||
[path removeAllPoints];
|
[path removeAllPoints];
|
||||||
[path setLineWidth: 5];
|
[path setLineWidth: 5];
|
||||||
[path moveToPoint: NSMakePoint (right, 0)];
|
[path moveToPoint: NSMakePoint (right, 0)];
|
||||||
|
@ -410,11 +402,9 @@ Rect is in global world (unscaled) coordinates
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) drawZplane
|
||||||
-drawZplane
|
|
||||||
{
|
{
|
||||||
[[NSColor colorWithCalibratedRed: 0.2 green: 0.2 blue: 0.0 alpha: 1.0]
|
[[NSColor colorWithCalibratedRed: 0.2 green: 0.2 blue: 0.0 alpha: 1.0] set];
|
||||||
set];
|
|
||||||
[path appendBezierPathWithArcWithCenter: NSMakePoint (0, zplane)
|
[path appendBezierPathWithArcWithCenter: NSMakePoint (0, zplane)
|
||||||
radius: 4
|
radius: 4
|
||||||
startAngle: 0
|
startAngle: 0
|
||||||
|
@ -429,15 +419,15 @@ drawSelf
|
||||||
===============================================================================
|
===============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
- (void) drawRect: (NSRect) rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
//NSRect visRect;
|
// NSRect visRect;
|
||||||
//Sys_Printf("ZView:drawRect\n");
|
// Sys_Printf("ZView:drawRect\n");
|
||||||
minheight = 999999;
|
minheight = 999999;
|
||||||
maxheight = -999999;
|
maxheight = -999999;
|
||||||
|
|
||||||
// allways draw the entire bar
|
// allways draw the entire bar
|
||||||
//visRect =[self visibleRect];
|
// visRect =[self visibleRect];
|
||||||
rect = [self visibleRect];
|
rect = [self visibleRect];
|
||||||
|
|
||||||
[quakeed_i zNoRestore: rect];
|
[quakeed_i zNoRestore: rect];
|
||||||
|
@ -446,13 +436,13 @@ drawSelf
|
||||||
NSEraseRect (rect);
|
NSEraseRect (rect);
|
||||||
|
|
||||||
// draw grid
|
// draw grid
|
||||||
[self drawGrid:rect];
|
[self drawGrid: rect];
|
||||||
|
|
||||||
// draw zplane
|
// draw zplane
|
||||||
// [self drawZplane]; FIXME zplane doesn't do anything yet
|
// [self drawZplane]; FIXME zplane doesn't do anything yet
|
||||||
|
|
||||||
// draw all entities
|
// draw all entities
|
||||||
[map_i makeUnselectedPerform:@selector (ZDrawSelf)];
|
[map_i makeUnselectedPerform: @selector (ZDrawSelf)];
|
||||||
|
|
||||||
// possibly resize the view
|
// possibly resize the view
|
||||||
[self newRealBounds];
|
[self newRealBounds];
|
||||||
|
@ -479,27 +469,25 @@ XYDrawSelf
|
||||||
[path release];
|
[path release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
getPoint: (NSPoint *)pt
|
getPoint: (NSPoint *)pt
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
-getPoint:(NSPoint *) pt
|
- (id) getPoint: (NSPoint *)pt
|
||||||
{
|
{
|
||||||
pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases
|
pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases
|
||||||
pt->y = origin[1] + 0.333;
|
pt->y = origin[1] + 0.333;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-setPoint:(NSPoint *) pt
|
- (id) setPoint: (NSPoint *)pt
|
||||||
{
|
{
|
||||||
origin[0] = pt->x;
|
origin[0] = pt->x;
|
||||||
origin[1] = pt->y;
|
origin[1] = pt->y;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
|
@ -508,7 +496,6 @@ MOUSE CLICKING
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
dragLoop:
|
dragLoop:
|
||||||
|
@ -516,17 +503,19 @@ dragLoop:
|
||||||
*/
|
*/
|
||||||
static NSPoint oldreletive;
|
static NSPoint oldreletive;
|
||||||
|
|
||||||
-dragFrom: (NSEvent *) startevent useGrid: (BOOL) ug callback:(void (*)(float dy)) callback
|
- (id) dragFrom: (NSEvent *)startevent
|
||||||
|
useGrid: (BOOL)ug
|
||||||
|
callback: (void (*)(float dy))callback
|
||||||
{
|
{
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
NSPoint startpt, newpt;
|
NSPoint startpt, newpt;
|
||||||
NSPoint reletive, delta;
|
NSPoint reletive, delta;
|
||||||
int gridsize;
|
int gridsize;
|
||||||
|
|
||||||
gridsize =[xyview_i gridsize];
|
gridsize = [xyview_i gridsize];
|
||||||
|
|
||||||
startpt =[startevent locationInWindow];
|
startpt = [startevent locationInWindow];
|
||||||
startpt =[self convertPoint: startpt fromView:NULL];
|
startpt = [self convertPoint: startpt fromView: NULL];
|
||||||
|
|
||||||
oldreletive.x = oldreletive.y = 0;
|
oldreletive.x = oldreletive.y = 0;
|
||||||
reletive.x = 0;
|
reletive.x = 0;
|
||||||
|
@ -535,26 +524,23 @@ static NSPoint oldreletive;
|
||||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||||
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
||||||
| NSApplicationDefinedMask;
|
| NSApplicationDefinedMask;
|
||||||
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate
|
event = [NSApp nextEventMatchingMask: eventMask untilDate: [NSDate
|
||||||
distantFuture]
|
distantFuture]
|
||||||
inMode: NSEventTrackingRunLoopMode dequeue:YES];
|
inMode: NSEventTrackingRunLoopMode dequeue:
|
||||||
|
YES];
|
||||||
|
|
||||||
if ([event type] == NSLeftMouseUp ||[event type] == NSRightMouseUp)
|
if ([event type] == NSLeftMouseUp || [event type] == NSRightMouseUp)
|
||||||
break;
|
break;
|
||||||
|
newpt = [event locationInWindow];
|
||||||
newpt =[event locationInWindow];
|
newpt = [self convertPoint: newpt fromView: NULL];
|
||||||
newpt =[self convertPoint: newpt fromView:NULL];
|
|
||||||
|
|
||||||
reletive.y = newpt.y - startpt.y;
|
reletive.y = newpt.y - startpt.y;
|
||||||
|
|
||||||
if (ug) { // we want truncate towards 0 behavior
|
if (ug) // we want truncate-towards-0 behavior here
|
||||||
// here
|
|
||||||
reletive.y = gridsize * (int) (reletive.y / gridsize);
|
reletive.y = gridsize * (int) (reletive.y / gridsize);
|
||||||
}
|
|
||||||
|
|
||||||
if (reletive.y == oldreletive.y)
|
if (reletive.y == oldreletive.y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
delta.y = reletive.y - oldreletive.y;
|
delta.y = reletive.y - oldreletive.y;
|
||||||
oldreletive = reletive;
|
oldreletive = reletive;
|
||||||
callback (delta.y);
|
callback (delta.y);
|
||||||
|
@ -563,8 +549,7 @@ static NSPoint oldreletive;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ZDragCallback (float dy)
|
ZDragCallback (float dy)
|
||||||
|
@ -573,21 +558,20 @@ ZDragCallback (float dy)
|
||||||
sb_translate[1] = 0;
|
sb_translate[1] = 0;
|
||||||
sb_translate[2] = dy;
|
sb_translate[2] = dy;
|
||||||
|
|
||||||
[map_i makeSelectedPerform:@selector (translate)];
|
[map_i makeSelectedPerform: @selector (translate)];
|
||||||
|
|
||||||
[quakeed_i redrawInstance];
|
[quakeed_i redrawInstance];
|
||||||
}
|
}
|
||||||
|
|
||||||
-selectionDragFrom:(NSEvent *) theEvent
|
- (id) selectionDragFrom: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
Sys_Printf ("dragging selection\n");
|
Sys_Printf ("dragging selection\n");
|
||||||
[self dragFrom: theEvent useGrid: YES callback:ZDragCallback];
|
[self dragFrom: theEvent useGrid: YES callback: ZDragCallback];
|
||||||
[quakeed_i updateCamera];
|
[quakeed_i updateCamera];
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
void
|
void
|
||||||
ZScrollCallback (float dy)
|
ZScrollCallback (float dy)
|
||||||
|
@ -596,26 +580,26 @@ ZScrollCallback (float dy)
|
||||||
NSPoint neworg;
|
NSPoint neworg;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
basebounds =[[zview_i superview] bounds];
|
basebounds = [[zview_i superview] bounds];
|
||||||
basebounds =[zview_i convertRect: basebounds fromView:[zview_i
|
basebounds = [zview_i convertRect: basebounds fromView: [zview_i
|
||||||
superview]];
|
superview]];
|
||||||
|
|
||||||
neworg.y = basebounds.origin.y - dy;
|
neworg.y = basebounds.origin.y - dy;
|
||||||
|
|
||||||
scale =[zview_i currentScale];
|
scale = [zview_i currentScale];
|
||||||
|
|
||||||
oldreletive.y -= dy;
|
oldreletive.y -= dy;
|
||||||
[zview_i setOrigin: neworg scale:scale];
|
[zview_i setOrigin: neworg scale: scale];
|
||||||
}
|
}
|
||||||
|
|
||||||
-scrollDragFrom:(NSEvent *) theEvent
|
- (id) scrollDragFrom: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
Sys_Printf ("scrolling view\n");
|
Sys_Printf ("scrolling view\n");
|
||||||
[self dragFrom: theEvent useGrid: YES callback:ZScrollCallback];
|
[self dragFrom: theEvent useGrid: YES callback: ZScrollCallback];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
void
|
void
|
||||||
ZControlCallback (float dy)
|
ZControlCallback (float dy)
|
||||||
|
@ -629,31 +613,29 @@ ZControlCallback (float dy)
|
||||||
[quakeed_i redrawInstance];
|
[quakeed_i redrawInstance];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) planeDragFrom:(NSEvent *) theEvent
|
- (BOOL) planeDragFrom: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
vec3_t dragpoint;
|
vec3_t dragpoint;
|
||||||
|
|
||||||
if ([map_i numSelected] != 1)
|
if ([map_i numSelected] != 1)
|
||||||
return NO;
|
return NO;
|
||||||
|
pt = [theEvent locationInWindow];
|
||||||
pt =[theEvent locationInWindow];
|
pt = [self convertPoint: pt fromView: NULL];
|
||||||
pt =[self convertPoint: pt fromView:NULL];
|
|
||||||
|
|
||||||
dragpoint[0] = origin[0];
|
dragpoint[0] = origin[0];
|
||||||
dragpoint[1] = origin[1];
|
dragpoint[1] = origin[1];
|
||||||
dragpoint[2] = pt.y;
|
dragpoint[2] = pt.y;
|
||||||
|
|
||||||
[[map_i selectedBrush] getZdragface:dragpoint];
|
[[map_i selectedBrush] getZdragface: dragpoint];
|
||||||
if (!numcontrolpoints)
|
if (!numcontrolpoints)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
Sys_Printf ("dragging brush plane\n");
|
Sys_Printf ("dragging brush plane\n");
|
||||||
|
|
||||||
pt =[theEvent locationInWindow];
|
pt = [theEvent locationInWindow];
|
||||||
pt =[self convertPoint: pt fromView:NULL];
|
pt = [self convertPoint: pt fromView: NULL];
|
||||||
|
|
||||||
[self dragFrom: theEvent useGrid: YES callback:ZControlCallback];
|
[self dragFrom: theEvent useGrid: YES callback: ZControlCallback];
|
||||||
|
|
||||||
[[map_i selectedBrush] removeIfInvalid];
|
[[map_i selectedBrush] removeIfInvalid];
|
||||||
|
|
||||||
|
@ -661,22 +643,21 @@ ZControlCallback (float dy)
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
//============================================================================
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===================
|
===================
|
||||||
mouseDown
|
mouseDown
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-(void) mouseDown:(NSEvent *) theEvent
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
int flags;
|
int flags;
|
||||||
vec3_t p1;
|
vec3_t p1;
|
||||||
|
|
||||||
pt =[theEvent locationInWindow];
|
pt = [theEvent locationInWindow];
|
||||||
pt =[self convertPoint: pt fromView:NULL];
|
pt = [self convertPoint: pt fromView: NULL];
|
||||||
|
|
||||||
p1[0] = origin[0];
|
p1[0] = origin[0];
|
||||||
p1[1] = origin[1];
|
p1[1] = origin[1];
|
||||||
|
@ -690,23 +671,23 @@ mouseDown
|
||||||
// shift click to select / deselect a brush from the world
|
// shift click to select / deselect a brush from the world
|
||||||
//
|
//
|
||||||
if (flags == NSShiftKeyMask) {
|
if (flags == NSShiftKeyMask) {
|
||||||
[map_i selectRay: p1: p1:NO];
|
[map_i selectRay: p1: p1: NO];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// alt click = set entire brush texture
|
// alt click = set entire brush texture
|
||||||
//
|
//
|
||||||
if (flags == NSAlternateKeyMask) {
|
if (flags == NSAlternateKeyMask) {
|
||||||
[map_i setTextureRay: p1: p1:YES];
|
[map_i setTextureRay: p1: p1: YES];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// control click = position view
|
// control click = position view
|
||||||
//
|
//
|
||||||
if (flags == NSControlKeyMask) {
|
if (flags == NSControlKeyMask) {
|
||||||
[cameraview_i setZOrigin:pt.y];
|
[cameraview_i setZOrigin: pt.y];
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
[cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]];
|
[cameraview_i ZmouseDown: &pt flags: [theEvent modifierFlags]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -714,18 +695,16 @@ mouseDown
|
||||||
//
|
//
|
||||||
if (flags == 0) {
|
if (flags == 0) {
|
||||||
// check eye
|
// check eye
|
||||||
if ([cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]])
|
if ([cameraview_i ZmouseDown: &pt flags: [theEvent modifierFlags]])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ([map_i numSelected]) {
|
if ([map_i numSelected]) {
|
||||||
if (pt.x > 0) {
|
if (pt.x > 0) {
|
||||||
if ([self planeDragFrom:theEvent])
|
if ([self planeDragFrom: theEvent])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[self selectionDragFrom:theEvent];
|
[self selectionDragFrom: theEvent];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys_Printf ("bad flags for click %x %g %g\n", flags, pt.x, pt.y);
|
Sys_Printf ("bad flags for click %x %g %g\n", flags, pt.x, pt.y);
|
||||||
|
@ -738,31 +717,27 @@ mouseDown
|
||||||
rightMouseDown
|
rightMouseDown
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
-(void) rightMouseDown:(NSEvent *) theEvent
|
- (void) rightMouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
pt =[theEvent locationInWindow];
|
pt = [theEvent locationInWindow];
|
||||||
pt =[self convertPoint: pt fromView:NULL];
|
pt = [self convertPoint: pt fromView: NULL];
|
||||||
|
|
||||||
flags =
|
flags =
|
||||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
||||||
NSAlternateKeyMask | NSCommandKeyMask);
|
NSAlternateKeyMask | NSCommandKeyMask);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// click = scroll view
|
// click = scroll view
|
||||||
//
|
//
|
||||||
if (flags == 0) {
|
if (flags == 0)
|
||||||
[self scrollDragFrom:theEvent];
|
[self scrollDragFrom: theEvent];
|
||||||
}
|
|
||||||
|
|
||||||
Sys_Printf ("bad flags for click\n");
|
Sys_Printf ("bad flags for click\n");
|
||||||
NopSound ();
|
NopSound ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|
||||||
|
@ -776,7 +751,9 @@ rightMouseDown
|
||||||
modalMoveLoop
|
modalMoveLoop
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
-modalMoveLoop: (NSPoint *) basept: (vec3_t) movemod:converter
|
- (id) modalMoveLoop: (NSPoint *)basept
|
||||||
|
: (vec3_t)movemod
|
||||||
|
: converter
|
||||||
{
|
{
|
||||||
vec3_t originbase;
|
vec3_t originbase;
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
|
@ -792,8 +769,8 @@ modalMoveLoop
|
||||||
|
|
||||||
while ([event type] != NSLeftMouseUp) {
|
while ([event type] != NSLeftMouseUp) {
|
||||||
// calculate new point
|
// calculate new point
|
||||||
newpt =[event locationInWindow];
|
newpt = [event locationInWindow];
|
||||||
newpt =[converter convertPoint: newpt fromView:NULL];
|
newpt = [converter convertPoint: newpt fromView: NULL];
|
||||||
|
|
||||||
delta[0] = newpt.x - basept->x;
|
delta[0] = newpt.x - basept->x;
|
||||||
delta[1] = newpt.y - basept->y;
|
delta[1] = newpt.y - basept->y;
|
||||||
|
@ -802,7 +779,6 @@ modalMoveLoop
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
origin[i] = originbase[i] + movemod[i] * delta[i];
|
origin[i] = originbase[i] + movemod[i] * delta[i];
|
||||||
|
|
||||||
|
|
||||||
drawentry:
|
drawentry:
|
||||||
// instance draw new frame
|
// instance draw new frame
|
||||||
[quakeed_i newinstance];
|
[quakeed_i newinstance];
|
||||||
|
@ -810,9 +786,10 @@ modalMoveLoop
|
||||||
|
|
||||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
||||||
|
|
||||||
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate
|
event = [NSApp nextEventMatchingMask: eventMask untilDate: [NSDate
|
||||||
distantFuture]
|
distantFuture]
|
||||||
inMode: NSEventTrackingRunLoopMode dequeue:YES];
|
inMode: NSEventTrackingRunLoopMode dequeue:
|
||||||
|
YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the brush back into the window buffer
|
// draw the brush back into the window buffer
|
||||||
|
@ -826,18 +803,17 @@ modalMoveLoop
|
||||||
XYmouseDown
|
XYmouseDown
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
-(BOOL) XYmouseDown:(NSPoint *) pt
|
- (BOOL) XYmouseDown: (NSPoint *)pt
|
||||||
{
|
{
|
||||||
vec3_t movemod;
|
vec3_t movemod;
|
||||||
|
|
||||||
if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16)
|
if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
movemod[0] = 1;
|
movemod[0] = 1;
|
||||||
movemod[1] = 1;
|
movemod[1] = 1;
|
||||||
movemod[2] = 0;
|
movemod[2] = 0;
|
||||||
|
|
||||||
[self modalMoveLoop: pt: movemod:xyview_i];
|
[self modalMoveLoop: pt: movemod: xyview_i];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char token[MAXTOKEN];
|
char token[MAXTOKEN];
|
||||||
boolean unget;
|
boolean unget;
|
||||||
char *script_p;
|
char *script_p;
|
||||||
|
@ -25,30 +22,34 @@ GetToken (boolean crossline)
|
||||||
//
|
//
|
||||||
// skip space
|
// skip space
|
||||||
//
|
//
|
||||||
skipspace:
|
skipspace:
|
||||||
while (*script_p <= 32) {
|
while (*script_p <= 32) {
|
||||||
if (!*script_p) {
|
if (!*script_p) {
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete", scriptline);
|
Error ("Line %i is incomplete", scriptline);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (*script_p++ == '\n') {
|
if (*script_p++ == '\n') {
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete", scriptline);
|
Error ("Line %i is incomplete", scriptline);
|
||||||
|
|
||||||
scriptline++;
|
scriptline++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (script_p[0] == '/' && script_p[1] == '/') // comment field
|
if (script_p[0] == '/' && script_p[1] == '/') { // comment field
|
||||||
{
|
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete\n", scriptline);
|
Error ("Line %i is incomplete\n", scriptline);
|
||||||
while (*script_p++ != '\n')
|
|
||||||
|
while (*script_p++ != '\n') {
|
||||||
if (!*script_p) {
|
if (!*script_p) {
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete", scriptline);
|
Error ("Line %i is incomplete", scriptline);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goto skipspace;
|
goto skipspace;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -61,17 +62,19 @@ GetToken (boolean crossline)
|
||||||
while (*script_p != '"') {
|
while (*script_p != '"') {
|
||||||
if (!*script_p)
|
if (!*script_p)
|
||||||
Error ("EOF inside quoted token");
|
Error ("EOF inside quoted token");
|
||||||
|
|
||||||
*token_p++ = *script_p++;
|
*token_p++ = *script_p++;
|
||||||
if (token_p == &token[MAXTOKEN])
|
if (token_p == &token[MAXTOKEN])
|
||||||
Error ("Token too large on line %i", scriptline);
|
Error ("Token too large on line %i", scriptline);
|
||||||
}
|
}
|
||||||
script_p++;
|
script_p++;
|
||||||
} else
|
} else {
|
||||||
while (*script_p > 32) {
|
while (*script_p > 32) {
|
||||||
*token_p++ = *script_p++;
|
*token_p++ = *script_p++;
|
||||||
if (token_p == &token[MAXTOKEN])
|
if (token_p == &token[MAXTOKEN])
|
||||||
Error ("Token too large on line %i", scriptline);
|
Error ("Token too large on line %i", scriptline);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*token_p = 0;
|
*token_p = 0;
|
||||||
|
|
||||||
|
@ -84,10 +87,6 @@ UngetToken ()
|
||||||
unget = true;
|
unget = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
qprintf (char *fmt, ...) // prints text to cmd_out_i
|
qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||||
{
|
{
|
||||||
|
@ -98,13 +97,12 @@ qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||||
vsprintf (string, fmt, argptr);
|
vsprintf (string, fmt, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
[g_cmd_out_i setStringValue: [NSString stringWithCString:string]];
|
[g_cmd_out_i setStringValue: [NSString stringWithCString: string]];
|
||||||
// NSPing ();
|
// NSPing ();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
Error
|
Error
|
||||||
|
@ -120,7 +118,8 @@ Error (char *error, ...)
|
||||||
static char string[1024];
|
static char string[1024];
|
||||||
|
|
||||||
if (in_error)
|
if (in_error)
|
||||||
[NSApp terminate:NULL];
|
[NSApp terminate: NULL];
|
||||||
|
|
||||||
in_error = YES;
|
in_error = YES;
|
||||||
|
|
||||||
va_start (argptr, error);
|
va_start (argptr, error);
|
||||||
|
@ -129,15 +128,12 @@ Error (char *error, ...)
|
||||||
|
|
||||||
strcat (string, "\nmap saved to " FN_CRASHSAVE);
|
strcat (string, "\nmap saved to " FN_CRASHSAVE);
|
||||||
|
|
||||||
[map_i writeMapFile: FN_CRASHSAVE useRegion:NO];
|
[map_i writeMapFile: FN_CRASHSAVE useRegion: NO];
|
||||||
NSRunAlertPanel (@"Error",[NSString stringWithCString:string], NULL, NULL,
|
NSRunAlertPanel (@"Error", [NSString stringWithCString: string],
|
||||||
NULL);
|
NULL, NULL, NULL);
|
||||||
|
[NSApp terminate: NULL];
|
||||||
[NSApp terminate:NULL];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CleanupName (char *in, char *out)
|
CleanupName (char *in, char *out)
|
||||||
{
|
{
|
||||||
|
@ -150,11 +146,10 @@ CleanupName (char *in, char *out)
|
||||||
out[i] = toupper (in[i]);
|
out[i] = toupper (in[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < 16; i++)
|
for ( ; i < 16; i++)
|
||||||
out[i] = 0;
|
out[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintRect (NSRect * r)
|
PrintRect (NSRect * r)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +158,6 @@ PrintRect (NSRect * r)
|
||||||
r->origin.x + r->size.width, r->origin.y + r->size.height);
|
r->origin.x + r->size.width, r->origin.y + r->size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
FileTime
|
FileTime
|
||||||
|
@ -207,7 +201,6 @@ I_FileOpenRead (char *path, int *handle)
|
||||||
int h;
|
int h;
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
|
|
||||||
|
|
||||||
h = open (path, O_RDONLY, 0666);
|
h = open (path, O_RDONLY, 0666);
|
||||||
*handle = h;
|
*handle = h;
|
||||||
if (h == -1)
|
if (h == -1)
|
||||||
|
@ -254,18 +247,18 @@ Sys_UpdateFile (char *path, char *netpath)
|
||||||
if (ntime <= ltime)
|
if (ntime <= ltime)
|
||||||
return; // up to date
|
return; // up to date
|
||||||
|
|
||||||
// copy the file
|
// copy the file
|
||||||
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
|
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
|
||||||
|
|
||||||
size = I_FileOpenRead (netpath, &in);
|
size = I_FileOpenRead (netpath, &in);
|
||||||
buf = malloc (size);
|
buf = malloc (size);
|
||||||
if (read (in, buf, size) != size)
|
if (read (in, buf, size) != size)
|
||||||
Error ("UpdateFile: couldn't read all of %s", netpath);
|
Error ("UpdateFile: couldn't read all of %s", netpath);
|
||||||
|
|
||||||
close (in);
|
close (in);
|
||||||
|
|
||||||
CreatePath (path);
|
CreatePath (path);
|
||||||
out = I_FileOpenWrite (path);
|
out = I_FileOpenWrite (path);
|
||||||
write (out, buf, size);
|
write (out, buf, size);
|
||||||
close (out);
|
close (out);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "TextureView.h"
|
#include "TextureView.h"
|
||||||
#include "Clipper.h"
|
#include "Clipper.h"
|
||||||
|
|
||||||
|
|
||||||
void PrintRect (NSRect * r);
|
void PrintRect (NSRect * r);
|
||||||
int FileTime (char *path);
|
int FileTime (char *path);
|
||||||
void Sys_UpdateFile (char *path, char *netpath);
|
void Sys_UpdateFile (char *path, char *netpath);
|
||||||
|
@ -46,11 +45,11 @@ void Error (char *error, ...);
|
||||||
#define MAXTOKEN 128
|
#define MAXTOKEN 128
|
||||||
extern char token[MAXTOKEN];
|
extern char token[MAXTOKEN];
|
||||||
extern int scriptline;
|
extern int scriptline;
|
||||||
|
|
||||||
void StartTokenParsing (char *data);
|
void StartTokenParsing (char *data);
|
||||||
boolean GetToken (boolean crossline); // returns false at eof
|
boolean GetToken (boolean crossline); // returns false at eof
|
||||||
void UngetToken ();
|
void UngetToken ();
|
||||||
|
|
||||||
|
|
||||||
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
|
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
|
||||||
#define FN_TEMPSAVE "/qcache/temp.map"
|
#define FN_TEMPSAVE "/qcache/temp.map"
|
||||||
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "SetBrush.h"
|
#include "SetBrush.h"
|
||||||
|
|
||||||
typedef enum { dr_wire, dr_flat, dr_texture } drawmode_t;
|
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
|
||||||
|
|
||||||
extern int r_width, r_height;
|
extern int r_width, r_height;
|
||||||
extern unsigned *r_picbuffer;
|
extern unsigned *r_picbuffer;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
extern vec3_t xy_viewnormal;
|
extern vec3_t xy_viewnormal;
|
||||||
|
|
||||||
//define NOLIGHT
|
// define NOLIGHT
|
||||||
|
|
||||||
vec3_t r_origin, r_matrix[3];
|
vec3_t r_origin, r_matrix[3];
|
||||||
|
|
||||||
|
@ -42,13 +41,11 @@ REN_ClearBuffers (void)
|
||||||
memset (r_picbuffer, 0, size);
|
memset (r_picbuffer, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
REN_SetTexture
|
REN_SetTexture
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
REN_SetTexture (face_t * face)
|
REN_SetTexture (face_t * face)
|
||||||
{
|
{
|
||||||
|
@ -142,7 +139,6 @@ REN_DrawSpan (int y)
|
||||||
|
|
||||||
if (x2 > r_width)
|
if (x2 > r_width)
|
||||||
x2 = r_width;
|
x2 = r_width;
|
||||||
|
|
||||||
ofs = y * r_width + x1;
|
ofs = y * r_width + x1;
|
||||||
|
|
||||||
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
||||||
|
@ -155,14 +151,14 @@ REN_DrawSpan (int y)
|
||||||
if (t_widthshift) {
|
if (t_widthshift) {
|
||||||
tx = (int) ((ufrac * scale)) & t_widthmask;
|
tx = (int) ((ufrac * scale)) & t_widthmask;
|
||||||
ty = (int) ((vfrac * scale)) & t_heightmask;
|
ty = (int) ((vfrac * scale)) & t_heightmask;
|
||||||
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
in = (pixel32_t *) &t_data[(ty << t_widthshift) + tx];
|
||||||
} else {
|
} else {
|
||||||
tx = (int) ((ufrac * scale) + t_widthadd) % t_width;
|
tx = (int) ((ufrac * scale) + t_widthadd) % t_width;
|
||||||
ty = (int) ((vfrac * scale) + t_heightadd) % t_height;
|
ty = (int) ((vfrac * scale) + t_heightadd) % t_height;
|
||||||
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
in = (pixel32_t *) &t_data[ty * t_width + tx];
|
||||||
}
|
}
|
||||||
|
|
||||||
out = (pixel32_t *) & r_picbuffer[ofs];
|
out = (pixel32_t *) &r_picbuffer[ofs];
|
||||||
#ifdef NOLIGHT
|
#ifdef NOLIGHT
|
||||||
*out = *in;
|
*out = *in;
|
||||||
#else
|
#else
|
||||||
|
@ -177,7 +173,6 @@ REN_DrawSpan (int y)
|
||||||
zfrac += zstep;
|
zfrac += zstep;
|
||||||
ofs++;
|
ofs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -228,7 +223,6 @@ REN_DrawFlatSpan (int y)
|
||||||
zfrac += zstep;
|
zfrac += zstep;
|
||||||
ofs++;
|
ofs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -283,6 +277,7 @@ REN_RasterizeFace (winding_t * w)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
leftside[i] = w->points[leftv][i];
|
leftside[i] = w->points[leftv][i];
|
||||||
|
|
||||||
leftv--;
|
leftv--;
|
||||||
if (leftv == -1)
|
if (leftv == -1)
|
||||||
leftv = numvertex - 1;
|
leftv = numvertex - 1;
|
||||||
|
@ -295,6 +290,7 @@ REN_RasterizeFace (winding_t * w)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
rightside[i] = w->points[rightv][i];
|
rightside[i] = w->points[rightv][i];
|
||||||
|
|
||||||
rightv++;
|
rightv++;
|
||||||
if (rightv == numvertex)
|
if (rightv == numvertex)
|
||||||
rightv = 0;
|
rightv = 0;
|
||||||
|
@ -318,7 +314,7 @@ REN_RasterizeFace (winding_t * w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
|
@ -359,7 +355,6 @@ REN_DrawSpanLinear (int y)
|
||||||
ustep = (rightside[3] - ufrac) * scale;
|
ustep = (rightside[3] - ufrac) * scale;
|
||||||
vstep = (rightside[4] - vfrac) * scale;
|
vstep = (rightside[4] - vfrac) * scale;
|
||||||
|
|
||||||
|
|
||||||
if (x1 < 0) {
|
if (x1 < 0) {
|
||||||
ufrac -= x1 * ustep;
|
ufrac -= x1 * ustep;
|
||||||
vfrac -= x1 * vstep;
|
vfrac -= x1 * vstep;
|
||||||
|
@ -379,14 +374,14 @@ REN_DrawSpanLinear (int y)
|
||||||
if (t_widthshift) {
|
if (t_widthshift) {
|
||||||
tx = (int) ufrac & t_widthmask;
|
tx = (int) ufrac & t_widthmask;
|
||||||
ty = (int) vfrac & t_heightmask;
|
ty = (int) vfrac & t_heightmask;
|
||||||
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
in = (pixel32_t *) &t_data[(ty << t_widthshift) + tx];
|
||||||
} else {
|
} else {
|
||||||
tx = (int) (ufrac + t_widthadd) % t_width;
|
tx = (int) (ufrac + t_widthadd) % t_width;
|
||||||
ty = (int) (vfrac + t_heightadd) % t_height;
|
ty = (int) (vfrac + t_heightadd) % t_height;
|
||||||
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
in = (pixel32_t *) &t_data[ty * t_width + tx];
|
||||||
}
|
}
|
||||||
|
|
||||||
out = (pixel32_t *) & r_picbuffer[ofs];
|
out = (pixel32_t *) &r_picbuffer[ofs];
|
||||||
*out = *in;
|
*out = *in;
|
||||||
}
|
}
|
||||||
ufrac += ustep;
|
ufrac += ustep;
|
||||||
|
@ -394,7 +389,6 @@ REN_DrawSpanLinear (int y)
|
||||||
zfrac += zstep;
|
zfrac += zstep;
|
||||||
ofs++;
|
ofs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -446,6 +440,7 @@ REN_RasterizeFaceLinear (winding_t * w)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
leftside[i] = w->points[leftv][i];
|
leftside[i] = w->points[leftv][i];
|
||||||
|
|
||||||
leftv--;
|
leftv--;
|
||||||
if (leftv == -1)
|
if (leftv == -1)
|
||||||
leftv = numvertex - 1;
|
leftv = numvertex - 1;
|
||||||
|
@ -458,6 +453,7 @@ REN_RasterizeFaceLinear (winding_t * w)
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
rightside[i] = w->points[rightv][i];
|
rightside[i] = w->points[rightv][i];
|
||||||
|
|
||||||
rightv++;
|
rightv++;
|
||||||
if (rightv == numvertex)
|
if (rightv == numvertex)
|
||||||
rightv = 0;
|
rightv = 0;
|
||||||
|
@ -478,7 +474,7 @@ REN_RasterizeFaceLinear (winding_t * w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
|
@ -494,39 +490,37 @@ REN_BeginCamera (void)
|
||||||
r_width_2 = (float) r_width / 2;
|
r_width_2 = (float) r_width / 2;
|
||||||
r_height_3 = (float) r_height / 3;
|
r_height_3 = (float) r_height / 3;
|
||||||
|
|
||||||
|
// clip to right side
|
||||||
// clip to right side
|
|
||||||
rfrustum[0].normal[0] = -1;
|
rfrustum[0].normal[0] = -1;
|
||||||
rfrustum[0].normal[1] = 0;
|
rfrustum[0].normal[1] = 0;
|
||||||
rfrustum[0].normal[2] = 1;
|
rfrustum[0].normal[2] = 1;
|
||||||
rfrustum[0].dist = 0;
|
rfrustum[0].dist = 0;
|
||||||
|
|
||||||
// clip to left side
|
// clip to left side
|
||||||
rfrustum[1].normal[0] = 1;
|
rfrustum[1].normal[0] = 1;
|
||||||
rfrustum[1].normal[1] = 0;
|
rfrustum[1].normal[1] = 0;
|
||||||
rfrustum[1].normal[2] = 1;
|
rfrustum[1].normal[2] = 1;
|
||||||
rfrustum[1].dist = 0;
|
rfrustum[1].dist = 0;
|
||||||
|
|
||||||
// clip to top side
|
// clip to top side
|
||||||
rfrustum[2].normal[0] = 0;
|
rfrustum[2].normal[0] = 0;
|
||||||
rfrustum[2].normal[1] = -1;
|
rfrustum[2].normal[1] = -1;
|
||||||
rfrustum[2].normal[2] = r_height_3 / r_width_2;
|
rfrustum[2].normal[2] = r_height_3 / r_width_2;
|
||||||
rfrustum[2].dist = 0;
|
rfrustum[2].dist = 0;
|
||||||
|
|
||||||
// clip to bottom side
|
// clip to bottom side
|
||||||
rfrustum[3].normal[0] = 0;
|
rfrustum[3].normal[0] = 0;
|
||||||
rfrustum[3].normal[1] = 1;
|
rfrustum[3].normal[1] = 1;
|
||||||
rfrustum[3].normal[2] = 2 * r_height_3 / r_width_2;
|
rfrustum[3].normal[2] = 2 * r_height_3 / r_width_2;
|
||||||
rfrustum[3].dist = 0;
|
rfrustum[3].dist = 0;
|
||||||
|
|
||||||
// near Z
|
// near Z
|
||||||
rfrustum[4].normal[0] = 0;
|
rfrustum[4].normal[0] = 0;
|
||||||
rfrustum[4].normal[1] = 0;
|
rfrustum[4].normal[1] = 0;
|
||||||
rfrustum[4].normal[2] = 1;
|
rfrustum[4].normal[2] = 1;
|
||||||
rfrustum[4].dist = 1;
|
rfrustum[4].dist = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
REN_BeginXY (void)
|
REN_BeginXY (void)
|
||||||
{
|
{
|
||||||
|
@ -614,7 +608,6 @@ REN_DrawCameraFace (face_t * idpol)
|
||||||
w->points[i][2] = scale;
|
w->points[i][2] = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// draw it
|
// draw it
|
||||||
//
|
//
|
||||||
|
@ -624,7 +617,6 @@ REN_DrawCameraFace (face_t * idpol)
|
||||||
free (w);
|
free (w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=====================
|
=====================
|
||||||
REN_DrawXYFace
|
REN_DrawXYFace
|
||||||
|
@ -640,8 +632,8 @@ REN_DrawXYFace (face_t * idpol)
|
||||||
|
|
||||||
if (!idpol->w)
|
if (!idpol->w)
|
||||||
return; // overconstrained plane
|
return; // overconstrained plane
|
||||||
w = idpol->w;
|
|
||||||
|
|
||||||
|
w = idpol->w;
|
||||||
r_face = idpol;
|
r_face = idpol;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -709,7 +701,6 @@ REN_DrawXYFace (face_t * idpol)
|
||||||
|
|
||||||
REN_SetTexture (idpol);
|
REN_SetTexture (idpol);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// draw it
|
// draw it
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue