mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
Merge Forge branch back into trunk.
This commit is contained in:
commit
1db9a4b5e8
87 changed files with 7664 additions and 9037 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
|||
*.la
|
||||
*.lo
|
||||
*.obj
|
||||
*.a
|
||||
*.o
|
||||
*~
|
||||
autom4te.cache/
|
||||
|
@ -12,6 +13,7 @@ autom4te.cache/
|
|||
ChangeLog
|
||||
Makefile
|
||||
Makefile.in
|
||||
core
|
||||
|
||||
# /
|
||||
/aclocal.m4
|
||||
|
@ -108,6 +110,7 @@ Makefile.in
|
|||
# /libs/
|
||||
|
||||
# /libs/audio/
|
||||
/libs/audio/testsound
|
||||
|
||||
# /libs/audio/cd/
|
||||
|
||||
|
@ -185,7 +188,6 @@ Makefile.in
|
|||
/nq/include/stamp-h
|
||||
|
||||
# /nq/source/
|
||||
/nq/source/*.a
|
||||
/nq/source/*.d
|
||||
/nq/source/fbset_modes_l.c
|
||||
/nq/source/fbset_modes_y.c
|
||||
|
@ -212,7 +214,6 @@ Makefile.in
|
|||
/qtv/include/config.h
|
||||
|
||||
# /qtv/source/
|
||||
/qtv/source/*.a
|
||||
/qtv/source/*.d
|
||||
/qtv/source/*.i
|
||||
/qtv/source/*.s
|
||||
|
@ -227,7 +228,6 @@ Makefile.in
|
|||
/qw/include/config.h
|
||||
|
||||
# /qw/source/
|
||||
/qw/source/*.a
|
||||
/qw/source/*.d
|
||||
/qw/source/*.i
|
||||
/qw/source/*.s
|
||||
|
@ -316,6 +316,7 @@ Makefile.in
|
|||
/tools/Forge/Bundles/MapEdit/shared_profile_obj
|
||||
/tools/Forge/Bundles/MapEdit/obj
|
||||
/tools/Forge/Bundles/MapEdit/*.forgeb
|
||||
/tools/Forge/Bundles/MapEdit/*.app
|
||||
|
||||
# /tools/bsp2img/
|
||||
/tools/bsp2img/bsp2img
|
||||
|
|
|
@ -88,6 +88,11 @@ qboolean Script_GetToken (script_t *script, qboolean crossline);
|
|||
*/
|
||||
void Script_UngetToken (script_t *script);
|
||||
|
||||
/** Return a pointer to the current token.
|
||||
\param script The script_t object being parsed
|
||||
*/
|
||||
const char *Script_Token (script_t *token);
|
||||
|
||||
//@}
|
||||
|
||||
#endif//__QF_script_h
|
||||
|
|
|
@ -56,20 +56,20 @@
|
|||
#define TYP_MIPTEX 68
|
||||
|
||||
typedef struct qpic_s {
|
||||
int width, height;
|
||||
int32_t width, height;
|
||||
byte data[]; // variably sized
|
||||
} qpic_t;
|
||||
|
||||
typedef struct wadinfo_s {
|
||||
char id[4]; // should be WAD2 or 2DAW
|
||||
int numlumps;
|
||||
int infotableofs;
|
||||
int32_t numlumps;
|
||||
int32_t infotableofs;
|
||||
} wadinfo_t;
|
||||
|
||||
typedef struct lumpinfo_s {
|
||||
int filepos;
|
||||
int disksize;
|
||||
int size; // uncompressed
|
||||
int32_t filepos;
|
||||
int32_t disksize;
|
||||
int32_t size; // uncompressed
|
||||
byte type;
|
||||
byte compression;
|
||||
byte pad1, pad2;
|
||||
|
|
|
@ -157,9 +157,16 @@ Script_GetToken (script_t *script, qboolean crossline)
|
|||
dstring_copysubstr (script->token, token_p, script->p - token_p);
|
||||
script->p++;
|
||||
} else {
|
||||
const char *single = "{}()':";
|
||||
|
||||
token_p = script->p;
|
||||
while (*script->p && !isspace ((unsigned char) *script->p))
|
||||
if (strchr (single, *script->p)) {
|
||||
script->p++;
|
||||
} else {
|
||||
while (*script->p && !isspace ((unsigned char) *script->p)
|
||||
&& !strchr (single, *script->p))
|
||||
script->p++;
|
||||
}
|
||||
dstring_copysubstr (script->token, token_p, script->p - token_p);
|
||||
}
|
||||
|
||||
|
@ -171,3 +178,9 @@ Script_UngetToken (script_t *script)
|
|||
{
|
||||
script->unget = true;
|
||||
}
|
||||
|
||||
VISIBLE const char *
|
||||
Script_Token (script_t *script)
|
||||
{
|
||||
return script->token->str;
|
||||
}
|
||||
|
|
|
@ -61,19 +61,20 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
static uintptr_t
|
||||
wad_get_hash (void *l, void *unused)
|
||||
{
|
||||
char name[16];
|
||||
char name[17];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
name[i] = tolower (((lumpinfo_t *) l)->name[i]);
|
||||
name[16] = 0;
|
||||
return Hash_String (name);
|
||||
}
|
||||
|
||||
static int
|
||||
wad_compare (void *la, void *lb, void *unused)
|
||||
{
|
||||
return strcasecmp (((lumpinfo_t *) la)->name,
|
||||
((lumpinfo_t *) lb)->name) == 0;
|
||||
return strncasecmp (((lumpinfo_t *) la)->name,
|
||||
((lumpinfo_t *) lb)->name, 16) == 0;
|
||||
}
|
||||
|
||||
VISIBLE wad_t *
|
||||
|
|
|
@ -38,6 +38,7 @@ static const char rcsid[] =
|
|||
#include <Foundation/NSPathUtilities.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
||||
#include <AppKit/NSButton.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
#ifndef Brush_h
|
||||
#define Brush_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "SetBrush.h"
|
||||
#include "EditWindow.h"
|
||||
|
||||
extern id brush_i;
|
||||
|
||||
extern BOOL brushdraw; // YES when drawing cutbrushes and ents
|
||||
|
||||
@interface Brush : SetBrush
|
||||
{
|
||||
id cutbrushes_i;
|
||||
id cutentities_i;
|
||||
boolean updatemask[MAXBRUSHVERTEX];
|
||||
BOOL dontdraw; // for modal instance loops
|
||||
BOOL deleted; // when not visible at all
|
||||
}
|
||||
|
||||
- init;
|
||||
|
||||
- initFromSetBrush: br;
|
||||
|
||||
- deselect;
|
||||
- (BOOL)isSelected;
|
||||
|
||||
- (BOOL)XYmouseDown: (NSPoint *)pt; // return YES if brush handled
|
||||
- (BOOL)ZmouseDown: (NSPoint *)pt; // return YES if brush handled
|
||||
|
||||
- _keyDown:(NSEvent *)theEvent;
|
||||
|
||||
- (NSPoint)centerPoint; // for camera flyby mode
|
||||
|
||||
- InstanceSize;
|
||||
- XYDrawSelf;
|
||||
- ZDrawSelf;
|
||||
- CameraDrawSelf;
|
||||
|
||||
- flipHorizontal: sender;
|
||||
- flipVertical: sender;
|
||||
- rotate90: sender;
|
||||
|
||||
- makeTall: sender;
|
||||
- makeShort: sender;
|
||||
- makeWide: sender;
|
||||
- makeNarrow: sender;
|
||||
|
||||
- placeEntity: sender;
|
||||
|
||||
- cut: sender;
|
||||
- copy: sender;
|
||||
|
||||
- addBrush;
|
||||
|
||||
@end
|
||||
|
||||
#define Brush_h
|
|
@ -1,61 +1,76 @@
|
|||
#ifndef CameraView_h
|
||||
#define CameraView_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "mathlib.h"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
#include "SetBrush.h"
|
||||
|
||||
extern id cameraview_i;
|
||||
#include "render.h"
|
||||
|
||||
extern byte renderlist[1024*1024*4];
|
||||
extern id cameraview_i;
|
||||
|
||||
void CameraMoveto(vec3_t p);
|
||||
void CameraLineto(vec3_t p);
|
||||
extern byte renderlist[1024 * 1024 * 4];
|
||||
|
||||
extern BOOL timedrawing;
|
||||
void CameraMoveto (vec3_t p);
|
||||
void CameraLineto (vec3_t p);
|
||||
|
||||
@interface CameraView : NSView
|
||||
extern BOOL timedrawing;
|
||||
|
||||
@interface CameraView: NSView
|
||||
{
|
||||
float xa, ya, za;
|
||||
float move;
|
||||
|
||||
float *zbuffer;
|
||||
unsigned *imagebuffer;
|
||||
|
||||
BOOL angleChange; // JR 6.8.95
|
||||
|
||||
vec3_t origin;
|
||||
vec3_t matrix[3];
|
||||
|
||||
NSPoint dragspot;
|
||||
|
||||
drawmode_t drawmode;
|
||||
|
||||
float xa, ya, za;
|
||||
float move;
|
||||
|
||||
float *zbuffer;
|
||||
unsigned *imagebuffer;
|
||||
|
||||
BOOL angleChange; // JR 6.8.95
|
||||
|
||||
vec3_t origin;
|
||||
vec3_t matrix[3];
|
||||
|
||||
NSPoint dragspot;
|
||||
|
||||
drawmode_t drawmode;
|
||||
|
||||
NSBezierPath *xycamera;
|
||||
NSBezierPath *xycamera_aim;
|
||||
NSBezierPath *zcamera;
|
||||
|
||||
// UI links
|
||||
id mode_radio_i;
|
||||
|
||||
id mode_radio_i;
|
||||
}
|
||||
|
||||
- setXYOrigin: (NSPoint *)pt;
|
||||
- setZOrigin: (float)pt;
|
||||
- (id) setXYOrigin: (NSPoint *)pt;
|
||||
- (id) setZOrigin: (float)pt;
|
||||
|
||||
- setOrigin: (vec3_t)org angle: (float)angle;
|
||||
- getOrigin: (vec3_t)org;
|
||||
- (id) setOrigin: (vec3_t)org
|
||||
angle: (float)angle;
|
||||
|
||||
- (float)yawAngle;
|
||||
- (id) getOrigin: (vec3_t)org;
|
||||
|
||||
- matrixFromAngles;
|
||||
- _keyDown: (NSEvent *)theEvent;
|
||||
- (float) yawAngle;
|
||||
|
||||
- drawMode: sender;
|
||||
- setDrawMode: (drawmode_t)mode;
|
||||
- (id) matrixFromAngles;
|
||||
- (id) _keyDown: (NSEvent *)theEvent;
|
||||
|
||||
- homeView: sender;
|
||||
- (id) drawMode: sender;
|
||||
- (id) setDrawMode: (drawmode_t)mode;
|
||||
|
||||
- XYDrawSelf; // for drawing viewpoint in XY view
|
||||
- ZDrawSelf; // for drawing viewpoint in XY view
|
||||
- (BOOL)XYmouseDown: (NSPoint *)pt flags:(int)flags; // return YES if brush handled
|
||||
- (BOOL)ZmouseDown: (NSPoint *)pt flags:(int)flags; // return YES if brush handled
|
||||
- (id) homeView: sender;
|
||||
|
||||
- upFloor:sender;
|
||||
- downFloor: sender;
|
||||
- (void) XYDrawSelf; // for drawing viewpoint in XY view
|
||||
- (void) ZDrawSelf; // for drawing viewpoint in XY view
|
||||
- (BOOL) XYmouseDown: (NSPoint *)pt // return YES if brush handled
|
||||
flags: (int)flags;
|
||||
|
||||
- (BOOL) ZmouseDown: (NSPoint *)pt // return YES if brush handled
|
||||
flags: (int)flags;
|
||||
|
||||
- (id) upFloor: sender;
|
||||
- (id) downFloor: sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif // CameraView_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,32 @@
|
|||
#ifndef Clipper_h
|
||||
#define Clipper_h
|
||||
|
||||
extern id clipper_i;
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface Clipper : Object
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
#include "SetBrush.h"
|
||||
|
||||
extern id clipper_i;
|
||||
|
||||
@interface Clipper: NSObject
|
||||
{
|
||||
int num;
|
||||
vec3_t pos[3];
|
||||
plane_t plane;
|
||||
int num;
|
||||
vec3_t pos[3];
|
||||
plane_t plane;
|
||||
}
|
||||
|
||||
- (BOOL)hide;
|
||||
- XYClick: (NSPoint)pt;
|
||||
- (BOOL)XYDrag: (NSPoint *)pt;
|
||||
- ZClick: (NSPoint)pt;
|
||||
- carve;
|
||||
- flipNormal;
|
||||
- (BOOL)getFace: (face_t *)pl;
|
||||
- (BOOL) hide;
|
||||
- (id) XYClick: (NSPoint)pt;
|
||||
- (BOOL) XYDrag: (NSPoint *)pt;
|
||||
- (id) ZClick: (NSPoint)pt;
|
||||
- (id) carve;
|
||||
- (void) flipNormal;
|
||||
- (BOOL) getFace: (face_t *)pl;
|
||||
|
||||
- cameraDrawSelf;
|
||||
- XYDrawSelf;
|
||||
- ZDrawSelf;
|
||||
- (void) cameraDrawSelf;
|
||||
- (void) XYDrawSelf;
|
||||
- (void) ZDrawSelf;
|
||||
|
||||
@end
|
||||
|
||||
#endif // Clipper_h
|
||||
|
|
|
@ -1,81 +1,77 @@
|
|||
#include "QF/sys.h"
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "Clipper.h"
|
||||
#include "Map.h"
|
||||
#include "XYView.h"
|
||||
#include "ZView.h"
|
||||
#include "CameraView.h"
|
||||
#include "QuakeEd.h"
|
||||
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/DPSOperators.h>
|
||||
|
||||
id clipper_i;
|
||||
id clipper_i;
|
||||
extern NSBezierPath *path;
|
||||
|
||||
@implementation Clipper
|
||||
|
||||
- init
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
clipper_i = self;
|
||||
return self;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)hide
|
||||
- (BOOL) hide
|
||||
{
|
||||
int oldnum;
|
||||
|
||||
int oldnum;
|
||||
|
||||
oldnum = num;
|
||||
num = 0;
|
||||
return (oldnum > 0);
|
||||
}
|
||||
|
||||
- flipNormal
|
||||
- (void) flipNormal
|
||||
{
|
||||
vec3_t temp;
|
||||
|
||||
if (num == 2)
|
||||
{
|
||||
vec3_t temp;
|
||||
|
||||
if (num == 2) {
|
||||
VectorCopy (pos[0], temp);
|
||||
VectorCopy (pos[1], pos[0]);
|
||||
VectorCopy (temp, pos[1]);
|
||||
}
|
||||
else if (num == 3)
|
||||
{
|
||||
} else if (num == 3) {
|
||||
VectorCopy (pos[0], temp);
|
||||
VectorCopy (pos[2], pos[0]);
|
||||
VectorCopy (temp, pos[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qprintf ("no clipplane");
|
||||
} else {
|
||||
Sys_Printf ("no clipplane\n");
|
||||
NSBeep ();
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)getFace: (face_t *)f
|
||||
- (BOOL) getFace: (face_t *)f
|
||||
{
|
||||
vec3_t v1, v2, norm;
|
||||
int i;
|
||||
|
||||
vec3_t v1, v2, norm;
|
||||
int i;
|
||||
|
||||
VectorCopy (vec3_origin, plane.normal);
|
||||
plane.dist = 0;
|
||||
if (num < 2)
|
||||
return NO;
|
||||
if (num == 2)
|
||||
{
|
||||
if (num == 2) {
|
||||
VectorCopy (pos[0], pos[2]);
|
||||
pos[2][2] += 16;
|
||||
}
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
VectorCopy (pos[i], f->planepts[i]);
|
||||
|
||||
|
||||
VectorSubtract (pos[2], pos[0], v1);
|
||||
VectorSubtract (pos[1], pos[0], v2);
|
||||
|
||||
|
||||
CrossProduct (v1, v2, norm);
|
||||
VectorNormalize (norm);
|
||||
|
||||
if ( !norm[0] && !norm[1] && !norm[2] )
|
||||
|
||||
if (!norm[0] && !norm[1] && !norm[2])
|
||||
return NO;
|
||||
|
||||
|
||||
[texturepalette_i getTextureDef: &f->texture];
|
||||
|
||||
return YES;
|
||||
|
@ -86,20 +82,18 @@ id clipper_i;
|
|||
XYClick
|
||||
================
|
||||
*/
|
||||
- XYClick: (NSPoint)pt
|
||||
- (id) XYClick: (NSPoint)pt
|
||||
{
|
||||
int i;
|
||||
vec3_t new;
|
||||
|
||||
int i;
|
||||
vec3_t new;
|
||||
|
||||
new[0] = [xyview_i snapToGrid: pt.x];
|
||||
new[1] = [xyview_i snapToGrid: pt.y];
|
||||
new[2] = [map_i currentMinZ];
|
||||
|
||||
// see if a point is allready there
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
if (new[0] == pos[i][0] && new[1] == pos[i][1])
|
||||
{
|
||||
// see if a point is allready there
|
||||
for (i = 0; i < num; i++) {
|
||||
if (new[0] == pos[i][0] && new[1] == pos[i][1]) {
|
||||
if (pos[i][2] == [map_i currentMinZ])
|
||||
pos[i][2] = [map_i currentMaxZ];
|
||||
else
|
||||
|
@ -108,16 +102,15 @@ XYClick
|
|||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (num == 3)
|
||||
num = 0;
|
||||
|
||||
|
||||
VectorCopy (new, pos[num]);
|
||||
num++;
|
||||
|
||||
[quakeed_i updateAll];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -126,45 +119,40 @@ XYClick
|
|||
XYDrag
|
||||
================
|
||||
*/
|
||||
- (BOOL)XYDrag: (NSPoint *)pt
|
||||
- (BOOL) XYDrag: (NSPoint *)pt
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
if (fabs(pt->x - pos[i][0] > 10) || fabs(pt->y - pos[i][1] > 10) )
|
||||
continue;
|
||||
// drag this point
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (fabs (pt->x - pos[i][0] > 10) || fabs (pt->y - pos[i][1] > 10))
|
||||
continue; // drag this point
|
||||
}
|
||||
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- ZClick: (NSPoint)pt
|
||||
- (id) ZClick: (NSPoint)pt
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// =============================================================================
|
||||
|
||||
- carve
|
||||
- (id) carve
|
||||
{
|
||||
[map_i makeSelectedPerform: @selector(carveByClipper)];
|
||||
[map_i makeSelectedPerform: @selector (carveByClipper)];
|
||||
num = 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- cameraDrawSelf
|
||||
- (void) cameraDrawSelf
|
||||
{
|
||||
vec3_t mid;
|
||||
int i;
|
||||
|
||||
linecolor (1,0.5,0);
|
||||
vec3_t mid;
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
linecolor (1, 0.5, 0);
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
VectorCopy (pos[i], mid);
|
||||
mid[0] -= 8;
|
||||
mid[1] -= 8;
|
||||
|
@ -172,7 +160,7 @@ XYDrag
|
|||
mid[0] += 16;
|
||||
mid[1] += 16;
|
||||
CameraLineto (mid);
|
||||
|
||||
|
||||
VectorCopy (pos[i], mid);
|
||||
mid[0] -= 8;
|
||||
mid[1] += 8;
|
||||
|
@ -181,50 +169,54 @@ XYDrag
|
|||
mid[1] -= 16;
|
||||
CameraLineto (mid);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- XYDrawSelf
|
||||
- (void) XYDrawSelf
|
||||
{
|
||||
int i;
|
||||
char text[8];
|
||||
|
||||
PSsetrgbcolor (1,0.5,0);
|
||||
//XXX PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]);
|
||||
PSrotate(0);
|
||||
int i;
|
||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
PSmoveto (pos[i][0]-4, pos[i][1]-4);
|
||||
sprintf (text, "%i", i);
|
||||
PSshow (text);
|
||||
PSstroke ();
|
||||
PSarc ( pos[i][0], pos[i][1], 10, 0, 360);
|
||||
PSstroke ();
|
||||
[[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
|
||||
set];
|
||||
|
||||
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
|
||||
|
||||
[path removeAllPoints];
|
||||
for (i = 0; i < num; i++) {
|
||||
NSString *s = [NSString stringWithFormat: @"%i", i];
|
||||
[s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)
|
||||
withAttributes: attribs];
|
||||
// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
|
||||
[path
|
||||
appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0], pos[i][1])
|
||||
radius: 10
|
||||
startAngle: 0
|
||||
endAngle: 360];
|
||||
}
|
||||
return self;
|
||||
[path stroke];
|
||||
}
|
||||
|
||||
- ZDrawSelf
|
||||
- (void) ZDrawSelf
|
||||
{
|
||||
int i;
|
||||
char text[8];
|
||||
|
||||
PSsetrgbcolor (1,0.5,0);
|
||||
//XXX PSselectfont("Helvetica-Medium",10/[zview_i currentScale]);
|
||||
PSrotate(0);
|
||||
int i;
|
||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
PSmoveto (-28+i*8 - 4, pos[i][2]-4);
|
||||
sprintf (text, "%i", i);
|
||||
PSshow (text);
|
||||
PSstroke ();
|
||||
PSarc ( -28+i*8, pos[i][2], 10, 0, 360);
|
||||
PSstroke ();
|
||||
[[NSColor colorWithCalibratedRed: 1. green: 0.5 blue: 0. alpha: 1.] set];
|
||||
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
|
||||
|
||||
[path removeAllPoints];
|
||||
for (i = 0; i < num; i++) {
|
||||
NSString *s = [NSString stringWithFormat: @"%i", i];
|
||||
[s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4)
|
||||
withAttributes: attribs];
|
||||
// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
|
||||
[path
|
||||
appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8, pos[i][2])
|
||||
radius: 10
|
||||
startAngle: 0
|
||||
endAngle: 360];
|
||||
}
|
||||
return self;
|
||||
[path stroke];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,47 +1,40 @@
|
|||
#ifndef Dict_h
|
||||
#define Dict_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *key;
|
||||
char *value;
|
||||
} dict_t;
|
||||
#include "Storage.h"
|
||||
|
||||
@interface Dict:Storage
|
||||
struct script_s;
|
||||
|
||||
@interface Dict: NSObject
|
||||
{
|
||||
struct plitem_s *plist;
|
||||
}
|
||||
|
||||
- initFromFile:(FILE *)fp;
|
||||
- (id) initFromFile: (FILE *)fp;
|
||||
|
||||
- (id) parseMultipleFrom:(char *)value;
|
||||
- (int) getValueUnits:(char *)key;
|
||||
- delString:(char *)string fromValue:(char *)key;
|
||||
- addString:(char *)string toValue:(char *)key;
|
||||
- (char *)convertListToString:(id)list;
|
||||
- (char *)getStringFor:(char *)name;
|
||||
- removeKeyword:(char *)key;
|
||||
- (unsigned int)getValueFor:(char *)name;
|
||||
- changeStringFor:(char *)key to:(char *)value;
|
||||
- (dict_t *) findKeyword:(char *)key;
|
||||
- (int) getValueUnits: (const char *)key;
|
||||
|
||||
- writeBlockTo:(FILE *)fp;
|
||||
- writeFile:(char *)path;
|
||||
- (struct plitem_s *) getArrayFor: (const char *)name;
|
||||
- (const char *) getStringFor: (const char *)name;
|
||||
- (unsigned int) getValueFor: (const char *)name;
|
||||
- (id) changeStringFor: (const char *)key to: (const char *)value;
|
||||
|
||||
// INTERNAL
|
||||
- init;
|
||||
- (id) parseBraceBlock:(FILE *)fp;
|
||||
- setupMultiple:(char *)value;
|
||||
- (char *)getNextParameter;
|
||||
- (id) writeBlockTo: (FILE *)fp;
|
||||
- (id) writeFile: (const char *)path;
|
||||
|
||||
@end
|
||||
|
||||
int GetNextChar(FILE *fp);
|
||||
void CopyUntilWhitespc(FILE *fp,char *buffer);
|
||||
void CopyUntilQuote(FILE *fp,char *buffer);
|
||||
int FindBrace(FILE *fp);
|
||||
int FindQuote(FILE *fp);
|
||||
int FindWhitespc(FILE *fp);
|
||||
int FindNonwhitespc(FILE *fp);
|
||||
int GetNextChar (FILE * fp);
|
||||
void CopyUntilWhitespc (FILE * fp, char *buffer);
|
||||
void CopyUntilQuote (FILE * fp, char *buffer);
|
||||
int FindBrace (FILE * fp);
|
||||
int FindQuote (FILE * fp);
|
||||
int FindWhitespc (FILE * fp);
|
||||
int FindNonwhitespc (FILE * fp);
|
||||
|
||||
char *FindWhitespcInBuffer(char *buffer);
|
||||
char *FindNonwhitespcInBuffer(char *buffer);
|
||||
char *FindWhitespcInBuffer (char *buffer);
|
||||
char *FindNonwhitespcInBuffer (char *buffer);
|
||||
|
||||
#endif // Dict_h
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
#include "QF/dstring.h"
|
||||
#include "QF/qfplist.h"
|
||||
#include "QF/script.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "Dict.h"
|
||||
|
||||
@implementation Dict
|
||||
|
||||
- init
|
||||
/*
|
||||
- (id) print
|
||||
{
|
||||
[super initCount:0
|
||||
elementSize:sizeof(dict_t)
|
||||
description:NULL];
|
||||
return self;
|
||||
}
|
||||
NSUInteger i;
|
||||
dict_t *d;
|
||||
|
||||
- print
|
||||
{
|
||||
int i;
|
||||
dict_t *d;
|
||||
|
||||
for (i=0 ; i<numElements ; i++)
|
||||
{
|
||||
for (i = 0; i < numElements; i++) {
|
||||
d = [self elementAt: i];
|
||||
printf ("%s : %s\n",d->key, d->value);
|
||||
printf ("%s : %s\n", d->key, d->value);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
===========
|
||||
copyFromZone
|
||||
|
@ -31,553 +28,128 @@ copyFromZone
|
|||
JDC
|
||||
===========
|
||||
*/
|
||||
- copyFromZone:(NSZone *)zone
|
||||
- (id) copy
|
||||
{
|
||||
id new;
|
||||
int i;
|
||||
dict_t *d;
|
||||
char *old;
|
||||
|
||||
new = [super copyFromZone: zone];
|
||||
for (i=0 ; i<numElements ; i++)
|
||||
{
|
||||
d = [self elementAt: i];
|
||||
old = d->key;
|
||||
d->key = malloc(strlen(old)+1);
|
||||
strcpy (d->key, old);
|
||||
|
||||
old = d->value;
|
||||
d->value = malloc(strlen(old)+1);
|
||||
strcpy (d->value, old);
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
- initFromFile:(FILE *)fp
|
||||
{
|
||||
[self init];
|
||||
return [self parseBraceBlock:fp];
|
||||
}
|
||||
|
||||
//===============================================
|
||||
//
|
||||
// Dictionary pair functions
|
||||
//
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// Write a { } block out to a FILE*
|
||||
//
|
||||
- writeBlockTo:(FILE *)fp
|
||||
{
|
||||
int max;
|
||||
int i;
|
||||
dict_t *d;
|
||||
|
||||
fprintf(fp,"{\n");
|
||||
max = [super count];
|
||||
for (i = 0;i < max;i++)
|
||||
{
|
||||
d = [super elementAt:i];
|
||||
fprintf(fp,"\t{\"%s\"\t\"%s\"}\n",d->key,d->value);
|
||||
}
|
||||
fprintf(fp,"}\n");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Write a single { } block out
|
||||
//
|
||||
- writeFile:(char *)path
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(path,"w+t");
|
||||
if (fp != NULL)
|
||||
{
|
||||
printf("Writing dictionary file %s.\n",path);
|
||||
fprintf(fp,"// QE_Project file %s\n",path);
|
||||
[self writeBlockTo:fp];
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error writing %s!\n",path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//===============================================
|
||||
//
|
||||
// Utility methods
|
||||
//
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// Find a keyword in storage
|
||||
// Returns * to dict_t, otherwise NULL
|
||||
//
|
||||
- (dict_t *) findKeyword:(char *)key
|
||||
{
|
||||
int max;
|
||||
int i;
|
||||
dict_t *d;
|
||||
|
||||
max = [super count];
|
||||
for (i = 0;i < max;i++)
|
||||
{
|
||||
d = [super elementAt:i];
|
||||
if (!strcmp(d->key,key))
|
||||
return d;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Change a keyword's string
|
||||
//
|
||||
- changeStringFor:(char *)key to:(char *)value
|
||||
{
|
||||
dict_t *d;
|
||||
dict_t newd;
|
||||
|
||||
d = [self findKeyword:key];
|
||||
if (d != NULL)
|
||||
{
|
||||
free(d->value);
|
||||
d->value = malloc(strlen(value)+1);
|
||||
strcpy(d->value,value);
|
||||
}
|
||||
else
|
||||
{
|
||||
newd.key = malloc(strlen(key)+1);
|
||||
strcpy(newd.key,key);
|
||||
newd.value = malloc(strlen(value)+1);
|
||||
strcpy(newd.value,value);
|
||||
[self addElement:&newd];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Search for keyword, return the string *
|
||||
//
|
||||
- (char *)getStringFor:(char *)name
|
||||
{
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:name];
|
||||
if (d != NULL)
|
||||
return d->value;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//
|
||||
// Search for keyword, return the value
|
||||
//
|
||||
- (unsigned int)getValueFor:(char *)name
|
||||
{
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:name];
|
||||
if (d != NULL)
|
||||
return atol(d->value);
|
||||
|
||||
Sys_Printf ("Dict copy: not implemented\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Return # of units in keyword's value
|
||||
//
|
||||
- (int) getValueUnits:(char *)key
|
||||
- (id) initFromFile: (FILE *)fp
|
||||
{
|
||||
id temp;
|
||||
int count;
|
||||
|
||||
temp = [self parseMultipleFrom:key];
|
||||
count = [temp count];
|
||||
[temp free];
|
||||
|
||||
return count;
|
||||
}
|
||||
dstring_t *text = dstring_newstr ();
|
||||
char *str;
|
||||
size_t read;
|
||||
const size_t readsize = 1024;
|
||||
|
||||
//
|
||||
// Convert List to string
|
||||
//
|
||||
- (char *)convertListToString:(id)list
|
||||
{
|
||||
int i;
|
||||
int max;
|
||||
char tempstr[4096];
|
||||
char *s;
|
||||
char *newstr;
|
||||
|
||||
max = [list count];
|
||||
tempstr[0] = 0;
|
||||
for (i = 0;i < max;i++)
|
||||
{
|
||||
s = [list elementAt:i];
|
||||
strcat(tempstr,s);
|
||||
strcat(tempstr," ");
|
||||
}
|
||||
newstr = malloc(strlen(tempstr)+1);
|
||||
strcpy(newstr,tempstr);
|
||||
|
||||
return newstr;
|
||||
}
|
||||
[self init];
|
||||
|
||||
//
|
||||
// JDC: I wrote this to simplify removing vectors
|
||||
//
|
||||
- removeKeyword:(char *)key
|
||||
{
|
||||
dict_t *d;
|
||||
do {
|
||||
str = dstring_reservestr (text, readsize);
|
||||
read = fread (str, 1, readsize, fp);
|
||||
if (read)
|
||||
str[read] = 0;
|
||||
} while (read == readsize);
|
||||
|
||||
d = [self findKeyword:key];
|
||||
if (d == NULL)
|
||||
return self;
|
||||
[self removeElementAt:d - (dict_t*)dataPtr];
|
||||
|
||||
plist = PL_GetPropertyList (text->str);
|
||||
dstring_delete (text);
|
||||
if (!plist)
|
||||
return 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Delete string from keyword's value
|
||||
//
|
||||
- delString:(char *)string fromValue:(char *)key
|
||||
- (void) dealloc
|
||||
{
|
||||
id temp;
|
||||
int count;
|
||||
int i;
|
||||
char *s;
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:key];
|
||||
if (d == NULL)
|
||||
return NULL;
|
||||
temp = [self parseMultipleFrom:key];
|
||||
count = [temp count];
|
||||
for (i = 0;i < count;i++)
|
||||
{
|
||||
s = [temp elementAt:i];
|
||||
if (!strcmp(s,string))
|
||||
{
|
||||
[temp removeElementAt:i];
|
||||
free(d->value);
|
||||
d->value = [self convertListToString:temp];
|
||||
[temp free];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (plist)
|
||||
PL_Free (plist);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
//
|
||||
// Dictionary pair functions
|
||||
//
|
||||
// ===============================================
|
||||
|
||||
- (id) writeBlockTo: (FILE *)fp
|
||||
{
|
||||
char *data;
|
||||
|
||||
data = PL_WritePropertyList (plist);
|
||||
fputs (data, fp);
|
||||
free (data);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Add string to keyword's value
|
||||
//
|
||||
- addString:(char *)string toValue:(char *)key
|
||||
- (id) writeFile: (const char *)path
|
||||
{
|
||||
char *newstr;
|
||||
char spacing[] = "\t";
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:key];
|
||||
if (d == NULL)
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen (path, "w+t");
|
||||
if (fp != NULL) {
|
||||
printf ("Writing dictionary file %s.\n", path);
|
||||
fprintf (fp, "// QE_Project file %s\n", path);
|
||||
[self writeBlockTo: fp];
|
||||
fclose (fp);
|
||||
} else {
|
||||
printf ("Error writing %s!\n", path);
|
||||
return NULL;
|
||||
newstr = malloc(strlen(string) + strlen(d->value) + strlen(spacing) + 1);
|
||||
strcpy(newstr,d->value);
|
||||
strcat(newstr,spacing);
|
||||
strcat(newstr,string);
|
||||
free(d->value);
|
||||
d->value = newstr;
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//===============================================
|
||||
// ===============================================
|
||||
//
|
||||
// Use these for multiple parameters in a keyword value
|
||||
// Utility methods
|
||||
//
|
||||
//===============================================
|
||||
char *searchStr;
|
||||
char item[4096];
|
||||
// ===============================================
|
||||
|
||||
- setupMultiple:(char *)value
|
||||
// Change a keyword's string
|
||||
- (id) changeStringFor: (const char *)key to: (const char *)value
|
||||
{
|
||||
searchStr = value;
|
||||
PL_D_AddObject (plist, key, PL_NewString (value));
|
||||
return self;
|
||||
}
|
||||
|
||||
- (char *)getNextParameter
|
||||
- (plitem_t *) getArrayFor: (const char *)name
|
||||
{
|
||||
char *s;
|
||||
|
||||
if (!searchStr)
|
||||
return NULL;
|
||||
strcpy(item,searchStr);
|
||||
s = FindWhitespcInBuffer(item);
|
||||
if (!*s)
|
||||
searchStr = NULL;
|
||||
else
|
||||
{
|
||||
*s = 0;
|
||||
searchStr = FindNonwhitespcInBuffer(s+1);
|
||||
}
|
||||
return item;
|
||||
plitem_t *item;
|
||||
item = PL_ObjectForKey (plist, name);
|
||||
if (item && PL_Type (item) == QFArray)
|
||||
return item;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Parses a keyvalue string & returns a Storage full of those items
|
||||
//
|
||||
- (id) parseMultipleFrom:(char *)key
|
||||
// Search for keyword, return the string *
|
||||
- (const char *) getStringFor: (const char *)name
|
||||
{
|
||||
#define ITEMSIZE 128
|
||||
id stuff;
|
||||
char string[ITEMSIZE];
|
||||
char *s;
|
||||
|
||||
s = [self getStringFor:key];
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
stuff = [[Storage alloc]
|
||||
initCount:0
|
||||
elementSize:ITEMSIZE
|
||||
description:NULL];
|
||||
|
||||
[self setupMultiple:s];
|
||||
while((s = [self getNextParameter]))
|
||||
{
|
||||
bzero(string,ITEMSIZE);
|
||||
strcpy(string,s);
|
||||
[stuff addElement:string];
|
||||
}
|
||||
|
||||
return stuff;
|
||||
plitem_t *item;
|
||||
const char *str;
|
||||
|
||||
item = PL_ObjectForKey (plist, name);
|
||||
if (item && (str = PL_String (item)))
|
||||
return str;
|
||||
return "";
|
||||
}
|
||||
|
||||
//===============================================
|
||||
//
|
||||
// Dictionary pair parsing
|
||||
//
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// parse all keyword/value pairs within { } 's
|
||||
//
|
||||
- (id) parseBraceBlock:(FILE *)fp
|
||||
// Search for keyword, return the value
|
||||
- (unsigned int) getValueFor: (const char *)name
|
||||
{
|
||||
int c;
|
||||
dict_t pair;
|
||||
char string[1024];
|
||||
|
||||
c = FindBrace(fp);
|
||||
if (c == -1)
|
||||
return NULL;
|
||||
|
||||
while((c = FindBrace(fp)) != '}')
|
||||
{
|
||||
if (c == -1)
|
||||
return NULL;
|
||||
// c = FindNonwhitespc(fp);
|
||||
// if (c == -1)
|
||||
// return NULL;
|
||||
// CopyUntilWhitespc(fp,string);
|
||||
return atol ([self getStringFor: name]);
|
||||
}
|
||||
|
||||
// JDC: fixed to allow quoted keys
|
||||
c = FindNonwhitespc(fp);
|
||||
if (c == -1)
|
||||
return NULL;
|
||||
c = fgetc(fp);
|
||||
if ( c == '\"')
|
||||
CopyUntilQuote(fp,string);
|
||||
else
|
||||
{
|
||||
ungetc (c,fp);
|
||||
CopyUntilWhitespc(fp,string);
|
||||
}
|
||||
// Return # of units in keyword's value
|
||||
- (int) getValueUnits: (const char *)key
|
||||
{
|
||||
plitem_t *item;
|
||||
|
||||
pair.key = malloc(strlen(string)+1);
|
||||
strcpy(pair.key,string);
|
||||
|
||||
c = FindQuote(fp);
|
||||
CopyUntilQuote(fp,string);
|
||||
pair.value = malloc(strlen(string)+1);
|
||||
strcpy(pair.value,string);
|
||||
|
||||
[super addElement:&pair];
|
||||
c = FindBrace(fp);
|
||||
}
|
||||
|
||||
return self;
|
||||
item = PL_ObjectForKey (plist, key);
|
||||
if (!item || PL_Type (item) != QFArray)
|
||||
return 0;
|
||||
|
||||
return PL_A_NumObjects (item);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//===============================================
|
||||
//
|
||||
// C routines for string parsing
|
||||
//
|
||||
//===============================================
|
||||
int GetNextChar(FILE *fp)
|
||||
{
|
||||
int c;
|
||||
int c2;
|
||||
|
||||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c == '/') // parse comments
|
||||
{
|
||||
c2 = getc(fp);
|
||||
if (c2 == '/')
|
||||
{
|
||||
while((c2 = getc(fp)) != '\n');
|
||||
c = getc(fp);
|
||||
}
|
||||
else
|
||||
ungetc(c2,fp);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void CopyUntilWhitespc(FILE *fp,char *buffer)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
if (c == EOF)
|
||||
return;
|
||||
if (c <= ' ')
|
||||
{
|
||||
*buffer = 0;
|
||||
return;
|
||||
}
|
||||
*buffer++ = c;
|
||||
}
|
||||
}
|
||||
|
||||
void CopyUntilQuote(FILE *fp,char *buffer)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
if (c == EOF)
|
||||
return;
|
||||
if (c == '\"')
|
||||
{
|
||||
*buffer = 0;
|
||||
return;
|
||||
}
|
||||
*buffer++ = c;
|
||||
}
|
||||
}
|
||||
|
||||
int FindBrace(FILE *fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c == '{' ||
|
||||
c == '}')
|
||||
return c;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FindQuote(FILE *fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c == '\"')
|
||||
return c;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FindWhitespc(FILE *fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c <= ' ')
|
||||
{
|
||||
ungetc(c,fp);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FindNonwhitespc(FILE *fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c > ' ')
|
||||
{
|
||||
ungetc(c,fp);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *FindWhitespcInBuffer(char *buffer)
|
||||
{
|
||||
int count = 1000;
|
||||
char *b = buffer;
|
||||
|
||||
while(count--)
|
||||
if (*b <= ' ')
|
||||
return b;
|
||||
else
|
||||
b++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *FindNonwhitespcInBuffer(char *buffer)
|
||||
{
|
||||
int count = 1000;
|
||||
char *b = buffer;
|
||||
|
||||
while(count--)
|
||||
if (*b > ' ')
|
||||
return b;
|
||||
else
|
||||
b++;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface DictList:List
|
||||
{
|
||||
}
|
||||
|
||||
- initListFromFile:(FILE *)fp;
|
||||
- writeListFile:(char *)filename;
|
||||
- (id) findDictKeyword:(char *)key;
|
||||
|
||||
@end
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#include "qedefs.h"
|
||||
|
||||
@implementation DictList
|
||||
|
||||
//
|
||||
// Read in variable # of objects from FILE *
|
||||
//
|
||||
- initListFromFile:(FILE *)fp
|
||||
{
|
||||
id d;
|
||||
|
||||
[super init];
|
||||
do
|
||||
{
|
||||
d = [(Dict *)[Dict alloc] initFromFile:fp];
|
||||
if (d != NULL)
|
||||
[self addObject:d];
|
||||
} while(d != NULL);
|
||||
[d free];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Write out list file
|
||||
//
|
||||
- writeListFile:(char *)filename
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
id obj;
|
||||
|
||||
fp = fopen(filename,"w+t");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
fprintf(fp,"// Object List written by QuakeEd\n");
|
||||
|
||||
for (i = 0;i < maxElements;i++)
|
||||
{
|
||||
obj = [self objectAt:i];
|
||||
[obj writeBlockTo:fp];
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Find the keyword in all the Dict objects
|
||||
//
|
||||
- (id) findDictKeyword:(char *)key
|
||||
{
|
||||
int i;
|
||||
dict_t *d;
|
||||
id dict;
|
||||
|
||||
for (i = 0;i < maxElements;i++)
|
||||
{
|
||||
dict = [self objectAt:i];
|
||||
d = [(Dict *)dict findKeyword:key];
|
||||
if (d != NULL)
|
||||
return dict;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,40 +1,46 @@
|
|||
#ifndef Entity_h
|
||||
#define Entity_h
|
||||
|
||||
#define MAX_KEY 64
|
||||
#define MAX_VALUE 128
|
||||
typedef struct epair_s
|
||||
{
|
||||
struct epair_s *next;
|
||||
char key[MAX_KEY];
|
||||
char value[MAX_VALUE];
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
typedef struct epair_s {
|
||||
struct epair_s *next;
|
||||
char *key;
|
||||
char *value;
|
||||
} epair_t;
|
||||
|
||||
// an Entity is a list of brush objects, with additional key / value info
|
||||
|
||||
@interface Entity : NSObject <NSCopying, NSMutableCopying>
|
||||
@interface Entity: NSMutableArray
|
||||
{
|
||||
epair_t *epairs;
|
||||
BOOL modifiable;
|
||||
NSMutableArray *array;
|
||||
epair_t *epairs;
|
||||
BOOL modifiable;
|
||||
}
|
||||
|
||||
- initClass: (char *)classname;
|
||||
- initFromTokens;
|
||||
- (Entity *) initClass: (const char *)classname;
|
||||
- (Entity *) initFromScript: (struct script_s *)script;
|
||||
|
||||
- free;
|
||||
- (oneway void) dealloc;
|
||||
|
||||
- (BOOL)modifiable;
|
||||
- setModifiable: (BOOL)m;
|
||||
- (BOOL) modifiable;
|
||||
- (void) setModifiable: (BOOL)m;
|
||||
|
||||
- (char *)targetname;
|
||||
- (const char *) targetname;
|
||||
|
||||
- writeToFILE: (FILE *)f region:(BOOL)reg;
|
||||
- (void) writeToFILE: (FILE *)f region: (BOOL)reg;
|
||||
|
||||
- (char *)valueForQKey: (char *)k;
|
||||
- getVector: (vec3_t)v forKey: (char *)k;
|
||||
- setKey:(char *)k toValue:(char *)v;
|
||||
- (int)numPairs;
|
||||
- (epair_t *)epairs;
|
||||
- removeKeyPair: (char *)key;
|
||||
- (const char *) valueForQKey: (const char *)k;
|
||||
- (void) getVector: (vec3_t)v forKey: (const char *)k;
|
||||
|
||||
- (void) setKey: (const char *)k
|
||||
toValue: (const char *)v;
|
||||
|
||||
- (int) numPairs;
|
||||
- (epair_t *) epairs;
|
||||
- (void) removeKeyPair: (const char *)key;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif // Entity_h
|
||||
|
|
|
@ -1,27 +1,36 @@
|
|||
#include "QF/dstring.h"
|
||||
#include "QF/script.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "Entity.h"
|
||||
#include "EntityClass.h"
|
||||
#include "TexturePalette.h"
|
||||
#include "SetBrush.h"
|
||||
#include "Map.h"
|
||||
#include "CameraView.h"
|
||||
|
||||
#define THING Entity
|
||||
#include "THING+NSArray.m"
|
||||
|
||||
@implementation Entity
|
||||
|
||||
vec3_t bad_mins = {-8, -8, -8};
|
||||
vec3_t bad_maxs = {8, 8, 8};
|
||||
vec3_t bad_mins = {-8, -8, -8};
|
||||
vec3_t bad_maxs = {8, 8, 8};
|
||||
|
||||
- createFixedBrush: (vec3_t)org
|
||||
- (id) createFixedBrush: (vec3_t)org
|
||||
{
|
||||
vec3_t emins, emaxs;
|
||||
float *v, *v2, *color;
|
||||
id new;
|
||||
texturedef_t td;
|
||||
|
||||
// get class
|
||||
vec3_t emins, emaxs;
|
||||
float *v, *v2, *color;
|
||||
id new;
|
||||
texturedef_t td;
|
||||
|
||||
// get class
|
||||
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
||||
if (new)
|
||||
{
|
||||
if (new) {
|
||||
v = [new mins];
|
||||
v2 = [new maxs];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
v = bad_mins;
|
||||
v2 = bad_maxs;
|
||||
}
|
||||
|
@ -29,239 +38,227 @@ vec3_t bad_maxs = {8, 8, 8};
|
|||
color = [new drawColor];
|
||||
|
||||
modifiable = NO;
|
||||
memset(&td,0,sizeof(td));
|
||||
strcpy (td.texture,"entity");
|
||||
memset (&td, 0, sizeof (td));
|
||||
strcpy (td.texture, "entity");
|
||||
|
||||
VectorAdd (org, v, emins);
|
||||
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];
|
||||
|
||||
[self addObject: new];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- copyWithZone:(NSZone *)zone
|
||||
- (id) copyWithZone: (NSZone *) zone
|
||||
{
|
||||
id new, nb;
|
||||
epair_t *e;
|
||||
int i;
|
||||
|
||||
new = [[Entity alloc] init];
|
||||
id new, nb;
|
||||
epair_t *e;
|
||||
int i, c;
|
||||
|
||||
new = [[Entity allocWithZone: zone] init];
|
||||
[new setModifiable: modifiable];
|
||||
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
{ // don't copy target and targetname fields
|
||||
if (strncmp(e->key,"target",6))
|
||||
|
||||
for (e = epairs; e; e = e->next) {
|
||||
// don't copy target and targetname fields
|
||||
if (strncmp (e->key, "target", 6))
|
||||
[new setKey: e->key toValue: e->value];
|
||||
}
|
||||
|
||||
for (i=0 ; i<numElements ; i++)
|
||||
{
|
||||
nb = [[self objectAt: i] copy];
|
||||
c = [self count];
|
||||
for (i = 0; i < c; i++) {
|
||||
nb = [[self objectAtIndex: i] copy];
|
||||
[nb setParent: new];
|
||||
[new addObject: nb];
|
||||
}
|
||||
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
- initClass: (char *)classname
|
||||
- (Entity *) initClass: (const char *)classname
|
||||
{
|
||||
id new;
|
||||
esize_t esize;
|
||||
char value[80];
|
||||
vec3_t min, max;
|
||||
float *v;
|
||||
|
||||
[super init];
|
||||
|
||||
id new;
|
||||
esize_t esize;
|
||||
vec3_t min, max;
|
||||
int org[3];
|
||||
float *v;
|
||||
|
||||
self = [super init];
|
||||
array = [[NSMutableArray alloc] init];
|
||||
|
||||
modifiable = YES;
|
||||
|
||||
[self setKey: "classname" toValue:classname];
|
||||
[self setKey: "classname" toValue: classname];
|
||||
|
||||
// get class
|
||||
// get class
|
||||
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
||||
if (!new)
|
||||
esize = esize_model;
|
||||
else
|
||||
esize = [new esize];
|
||||
|
||||
// create a brush if needed
|
||||
if (esize == esize_fixed)
|
||||
{
|
||||
|
||||
// create a brush if needed
|
||||
if (esize == esize_fixed) {
|
||||
v = [new mins];
|
||||
[[map_i selectedBrush] getMins: min maxs: max];
|
||||
[[map_i selectedBrush] getMins: min maxs: max];
|
||||
VectorSubtract (min, v, min);
|
||||
|
||||
sprintf (value, "%i %i %i",(int)min[0], (int)min[1], (int)min[2]);
|
||||
[self setKey:"origin" toValue: value];
|
||||
VectorCopy (min, org);
|
||||
|
||||
// convert to integer
|
||||
[self setKey: "origin" toValue: va ("%i %i %i", org[0], org[1], org[2])];
|
||||
|
||||
[self createFixedBrush: min];
|
||||
}
|
||||
else
|
||||
} else {
|
||||
modifiable = YES;
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- free
|
||||
- (oneway void) dealloc
|
||||
{
|
||||
epair_t *e, *n;
|
||||
|
||||
for (e=epairs ; e ; e=n)
|
||||
{
|
||||
epair_t *e, *n;
|
||||
|
||||
for (e = epairs; e; e = n) {
|
||||
n = e->next;
|
||||
free (e->key);
|
||||
free (e->value);
|
||||
free (e);
|
||||
}
|
||||
return [super free];
|
||||
[array release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)modifiable
|
||||
- (BOOL) modifiable
|
||||
{
|
||||
return modifiable;
|
||||
}
|
||||
|
||||
- setModifiable: (BOOL)m
|
||||
- (void) setModifiable: (BOOL)m
|
||||
{
|
||||
modifiable = m;
|
||||
return self;
|
||||
return;
|
||||
}
|
||||
|
||||
- removeObject: o
|
||||
- (void) removeObject: (id)o
|
||||
{
|
||||
o = [super removeObject: o];
|
||||
if (numElements)
|
||||
return o;
|
||||
// the entity is empty, so remove the entire thing
|
||||
if ( self == [map_i objectAt: 0])
|
||||
return o; // never remove the world
|
||||
|
||||
[super removeObject: o];
|
||||
if ([self count])
|
||||
return;
|
||||
|
||||
// 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 free];
|
||||
|
||||
return o;
|
||||
[self release];
|
||||
}
|
||||
|
||||
|
||||
- (char *)valueForQKey: (char *)k
|
||||
- (const char *) valueForQKey: (const char *)k
|
||||
{
|
||||
epair_t *e;
|
||||
static char ret[64];
|
||||
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
if (!strcmp(k,e->key))
|
||||
{
|
||||
strcpy (ret, e->value);
|
||||
return ret;
|
||||
}
|
||||
epair_t *e;
|
||||
|
||||
for (e = epairs; e; e = e->next) {
|
||||
if (!strcmp (k, e->key))
|
||||
return e->value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
- getVector: (vec3_t)v forKey: (char *)k
|
||||
- (void) getVector: (vec3_t)v
|
||||
forKey: (const char *)k
|
||||
{
|
||||
char *c;
|
||||
|
||||
const char *c;
|
||||
|
||||
c = [self valueForQKey: k];
|
||||
|
||||
v[0] = v[1] = v[2] = 0;
|
||||
|
||||
|
||||
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
|
||||
}
|
||||
|
||||
- (id) print
|
||||
{
|
||||
epair_t *e;
|
||||
|
||||
for (e = epairs; e; e = e->next)
|
||||
printf ("%20s : %20s\n", e->key, e->value);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- print
|
||||
- (void) setKey: (const char *)k
|
||||
toValue: (const char *)v
|
||||
{
|
||||
epair_t *e;
|
||||
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
printf ("%20s : %20s\n",e->key, e->value);
|
||||
epair_t *e;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- setKey:(char *)k toValue:(char *)v
|
||||
{
|
||||
epair_t *e;
|
||||
|
||||
if (strlen(k) > MAX_KEY)
|
||||
Error ("setKey: %s > MAX_KEY", k);
|
||||
if (strlen(v) > MAX_VALUE)
|
||||
Error ("setKey: %s > MAX_VALUE", v);
|
||||
|
||||
while (*k && *k <= ' ')
|
||||
k++;
|
||||
if (!*k)
|
||||
return self; // don't set NULL values
|
||||
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
if (!strcmp(k,e->key))
|
||||
{
|
||||
memset (e->value, 0, sizeof(e->value));
|
||||
strcpy (e->value, v);
|
||||
return self;
|
||||
}
|
||||
|
||||
e = malloc (sizeof(epair_t));
|
||||
memset (e, 0, sizeof(epair_t));
|
||||
|
||||
strcpy (e->key, k);
|
||||
strcpy (e->value, v);
|
||||
// don't set NULL values
|
||||
if (!*k)
|
||||
return;
|
||||
|
||||
for (e = epairs; e; e = e->next) {
|
||||
if (!strcmp (k, e->key)) {
|
||||
if (e->value == v)
|
||||
return;
|
||||
free (e->value);
|
||||
e->value = strdup (v);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
e = malloc (sizeof (epair_t));
|
||||
|
||||
e->key = strdup (k);
|
||||
e->value = strdup (v);
|
||||
e->next = epairs;
|
||||
epairs = e;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int)numPairs
|
||||
- (int) numPairs
|
||||
{
|
||||
int i;
|
||||
epair_t *e;
|
||||
|
||||
i=0;
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
int i;
|
||||
epair_t *e;
|
||||
|
||||
i = 0;
|
||||
for (e = epairs; e; e = e->next)
|
||||
i++;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
- (epair_t *)epairs
|
||||
- (epair_t *) epairs
|
||||
{
|
||||
return epairs;
|
||||
}
|
||||
|
||||
- removeKeyPair: (char *)key
|
||||
- (void) removeKeyPair: (char *)key
|
||||
{
|
||||
epair_t *e, *e2;
|
||||
|
||||
epair_t *e, *e2;
|
||||
|
||||
if (!epairs)
|
||||
return self;
|
||||
return;
|
||||
|
||||
e = epairs;
|
||||
if (!strcmp(e->key, key))
|
||||
{
|
||||
if (!strcmp (e->key, key)) {
|
||||
epairs = e->next;
|
||||
free (e);
|
||||
return self;
|
||||
return;
|
||||
}
|
||||
|
||||
for (; e ; e=e->next)
|
||||
{
|
||||
if (e->next && !strcmp(e->next->key, key))
|
||||
{
|
||||
|
||||
for ( ; e; e = e->next) {
|
||||
if (e->next && !strcmp (e->next->key, key)) {
|
||||
e2 = e->next;
|
||||
e->next = e2->next;
|
||||
free (e2);
|
||||
return self;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
printf ("WARNING: removeKeyPair: %s not found\n", key);
|
||||
return self;
|
||||
}
|
||||
|
||||
printf ("WARNING: removeKeyPair: %s not found\n", key);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
|
@ -270,37 +267,33 @@ targetname
|
|||
If the entity does not have a "targetname" key, a unique one is generated
|
||||
=============
|
||||
*/
|
||||
- (char *)targetname
|
||||
- (const char *) targetname
|
||||
{
|
||||
char *t;
|
||||
int i, count;
|
||||
id ent;
|
||||
int tval, maxt;
|
||||
char name[20];
|
||||
|
||||
const char *t;
|
||||
int i, count;
|
||||
id ent;
|
||||
int tval, maxt;
|
||||
|
||||
t = [self valueForQKey: "targetname"];
|
||||
if (t && t[0])
|
||||
return t;
|
||||
|
||||
// make a unique name of the form t<number>
|
||||
|
||||
// make a unique name of the form t<number>
|
||||
count = [map_i count];
|
||||
maxt = 0;
|
||||
for (i=1 ; i<count ; i++)
|
||||
{
|
||||
ent = [map_i objectAt: i];
|
||||
for (i = 1; i < count; i++) {
|
||||
ent = [map_i objectAtIndex: i];
|
||||
t = [ent valueForQKey: "targetname"];
|
||||
if (!t || t[0] != 't')
|
||||
continue;
|
||||
tval = atoi (t+1);
|
||||
tval = atoi (t + 1);
|
||||
if (tval > maxt)
|
||||
maxt = tval;
|
||||
}
|
||||
|
||||
sprintf (name,"t%i",maxt+1);
|
||||
|
||||
[self setKey: "targetname" toValue: name];
|
||||
|
||||
return [self valueForQKey: "targetname"]; // so it's not on the stack
|
||||
|
||||
[self setKey: "targetname" toValue: va ("t%i", maxt + 1)];
|
||||
|
||||
return [self valueForQKey: "targetname"];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -311,167 +304,159 @@ FILE METHODS
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
int nument;
|
||||
int nument;
|
||||
|
||||
- initFromTokens
|
||||
- (Entity *) initFromScript: (script_t *)script
|
||||
{
|
||||
char key[MAXTOKEN];
|
||||
id eclass, brush;
|
||||
char *spawn;
|
||||
vec3_t emins, emaxs;
|
||||
vec3_t org;
|
||||
texturedef_t td;
|
||||
esize_t esize;
|
||||
int i, c;
|
||||
float *color;
|
||||
|
||||
[self init];
|
||||
char *key;
|
||||
id eclass, brush;
|
||||
const char *spawn;
|
||||
vec3_t emins, emaxs;
|
||||
vec3_t org;
|
||||
texturedef_t td;
|
||||
esize_t esize;
|
||||
int i, c;
|
||||
float *color;
|
||||
|
||||
if (!GetToken (true))
|
||||
{
|
||||
[self free];
|
||||
self = [super init];
|
||||
array = [[NSMutableArray alloc] init];
|
||||
|
||||
if (!Script_GetToken (script, true)) {
|
||||
[self dealloc];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (strcmp (token, "{") )
|
||||
Error ("initFromFileP: { not found");
|
||||
|
||||
do
|
||||
{
|
||||
if (!GetToken (true))
|
||||
if (strcmp (Script_Token (script), "{"))
|
||||
Sys_Error ("initFromScript: { not found");
|
||||
|
||||
do {
|
||||
if (!Script_GetToken (script, true))
|
||||
break;
|
||||
if (!strcmp (token, "}") )
|
||||
if (!strcmp (Script_Token (script), "}"))
|
||||
break;
|
||||
if (!strcmp (token, "{") )
|
||||
{ // read a brush
|
||||
brush = [[SetBrush alloc] initFromTokens: self];
|
||||
if (!strcmp (Script_Token (script), "{")) {
|
||||
// read a brush
|
||||
brush = [[SetBrush alloc] initFromScript: script owner: self];
|
||||
[self addObject: brush];
|
||||
}
|
||||
else
|
||||
{ // read a key / value pair
|
||||
strcpy (key, token);
|
||||
GetToken (false);
|
||||
[self setKey: key toValue:token];
|
||||
} else {
|
||||
// read a key / value pair
|
||||
key = strdup (Script_Token (script));
|
||||
Script_GetToken (script, false);
|
||||
[self setKey: key toValue: Script_Token (script)];
|
||||
free (key);
|
||||
}
|
||||
} while (1);
|
||||
|
||||
|
||||
nument++;
|
||||
|
||||
// get class
|
||||
// get class
|
||||
spawn = [self valueForQKey: "classname"];
|
||||
eclass = [entity_classes_i classForName: spawn];
|
||||
|
||||
esize = [eclass esize];
|
||||
|
||||
[self getVector: org forKey: "origin"];
|
||||
|
||||
if ([self count] && esize != esize_model)
|
||||
{
|
||||
printf ("WARNING:Entity with brushes and wrong model type\n");
|
||||
[self empty];
|
||||
|
||||
if ([self count] && esize != esize_model) {
|
||||
printf ("WARNING:Entity with brushes and wrong model type\n");
|
||||
[self removeAllObjects];
|
||||
}
|
||||
|
||||
if (![self count] && esize == esize_model)
|
||||
{
|
||||
printf ("WARNING:Entity with no brushes and esize_model\n");
|
||||
|
||||
if (![self count] && esize == esize_model) {
|
||||
printf ("WARNING:Entity with no brushes and esize_model: %s\n",
|
||||
[self valueForQKey: "classname"]);
|
||||
[texturepalette_i getTextureDef: &td];
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
for (i = 0; i < 3; i++) {
|
||||
emins[i] = org[i] - 8;
|
||||
emaxs[i] = org[i] + 8;
|
||||
}
|
||||
brush = [[SetBrush alloc] initOwner: self mins:emins maxs:emaxs
|
||||
texture: &td];
|
||||
brush =
|
||||
[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td];
|
||||
[self addObject: brush];
|
||||
}
|
||||
|
||||
// create a brush if needed
|
||||
|
||||
// create a brush if needed
|
||||
if (esize == esize_fixed)
|
||||
[self createFixedBrush: org];
|
||||
else
|
||||
modifiable = YES;
|
||||
|
||||
// set all the brush colors
|
||||
// set all the brush colors
|
||||
color = [eclass drawColor];
|
||||
|
||||
c = [self count];
|
||||
for (i=0 ; i<c ; i++)
|
||||
{
|
||||
brush = [self objectAt: i];
|
||||
for (i = 0; i < c; i++) {
|
||||
brush = [self objectAtIndex: i];
|
||||
[brush setEntityColor: color];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- writeToFILE: (FILE *)f region:(BOOL)reg;
|
||||
- (void) writeToFILE: (FILE *)f
|
||||
region: (BOOL)reg;
|
||||
{
|
||||
epair_t *e;
|
||||
int i;
|
||||
id new;
|
||||
char value[80];
|
||||
vec3_t mins, maxs, org;
|
||||
float *v;
|
||||
BOOL temporg;
|
||||
char oldang[80];
|
||||
|
||||
temporg = NO;
|
||||
if (reg)
|
||||
{
|
||||
if ( !strcmp ([self valueForQKey: "classname"], "info_player_start") )
|
||||
{ // move the playerstart temporarily to the camera position
|
||||
temporg = YES;
|
||||
strcpy (oldang, [self valueForQKey: "angle"]);
|
||||
sprintf (value, "%i", (int)([cameraview_i yawAngle]*180/M_PI));
|
||||
[self setKey: "angle" toValue: value];
|
||||
}
|
||||
else if ( self != [map_i objectAt: 0]
|
||||
&& [[self objectAt: 0] regioned] )
|
||||
return self; // skip the entire entity definition
|
||||
}
|
||||
|
||||
fprintf (f,"{\n");
|
||||
epair_t *e;
|
||||
int ang;
|
||||
unsigned int i;
|
||||
id new;
|
||||
vec3_t mins, maxs;
|
||||
int org[3];
|
||||
const vec_t *v;
|
||||
char *oldang = 0;
|
||||
|
||||
// set an origin epair
|
||||
if (!modifiable)
|
||||
{
|
||||
[[self objectAt: 0] getMins: mins maxs: maxs];
|
||||
if (temporg)
|
||||
{
|
||||
if (reg) {
|
||||
if (!strcmp ([self valueForQKey: "classname"], "info_player_start")) {
|
||||
// move the playerstart temporarily to the camera position
|
||||
oldang = strdup ([self valueForQKey: "angle"]);
|
||||
ang = (int) ([cameraview_i yawAngle] * 180 / M_PI);
|
||||
[self setKey: "angle" toValue: va ("%i", ang)];
|
||||
} else if (self != [map_i objectAtIndex: 0]
|
||||
&& [[self objectAtIndex: 0] regioned]) {
|
||||
return; // skip the entire entity definition
|
||||
}
|
||||
}
|
||||
|
||||
fprintf (f, "{\n");
|
||||
|
||||
// set an origin epair
|
||||
if (!modifiable) {
|
||||
[[self objectAtIndex: 0] getMins: mins maxs: maxs];
|
||||
if (oldang) {
|
||||
[cameraview_i getOrigin: mins];
|
||||
mins[0] -= 16;
|
||||
mins[1] -= 16;
|
||||
mins[2] -= 48;
|
||||
}
|
||||
new = [entity_classes_i classForName:
|
||||
[self valueForQKey: "classname"]];
|
||||
new = [entity_classes_i classForName:
|
||||
[self valueForQKey: "classname"]];
|
||||
if (new)
|
||||
v = [new mins];
|
||||
else
|
||||
v = vec3_origin;
|
||||
|
||||
VectorSubtract (mins, v, org);
|
||||
sprintf (value, "%i %i %i",(int)org[0], (int)org[1], (int)org[2]);
|
||||
[self setKey:"origin" toValue: value];
|
||||
}
|
||||
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
fprintf (f,"\"%s\"\t\"%s\"\n", e->key, e->value);
|
||||
|
||||
// fixed size entities don't save out brushes
|
||||
if ( modifiable )
|
||||
{
|
||||
for (i=0 ; i<numElements ; i++)
|
||||
[[self objectAt: i] writeToFILE: f region: reg];
|
||||
}
|
||||
|
||||
fprintf (f,"}\n");
|
||||
|
||||
if (temporg)
|
||||
[self setKey: "angle" toValue: oldang];
|
||||
|
||||
return self;
|
||||
VectorSubtract (mins, v, org);
|
||||
[self setKey: "origin"
|
||||
toValue: va ("%i %i %i", org[0], org[1], org[2])];
|
||||
}
|
||||
|
||||
for (e = epairs; e; e = e->next)
|
||||
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
|
||||
|
||||
// fixed size entities don't save out brushes
|
||||
if (modifiable) {
|
||||
for (i = 0; i < [self count]; i++)
|
||||
[[self objectAtIndex: i] writeToFILE: f region: reg];
|
||||
}
|
||||
|
||||
fprintf (f, "}\n");
|
||||
|
||||
if (oldang) {
|
||||
[self setKey: "angle" toValue: oldang];
|
||||
free (oldang);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,42 +1,46 @@
|
|||
#ifndef EntityClass_h
|
||||
#define EntityClass_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "mathlib.h"
|
||||
|
||||
typedef enum {esize_model, esize_fixed} esize_t;
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
#define MAX_FLAGS 8
|
||||
typedef enum {esize_model, esize_fixed} esize_t;
|
||||
|
||||
@interface EntityClass : Object
|
||||
#define MAX_FLAGS 8
|
||||
|
||||
@interface EntityClass: NSObject
|
||||
{
|
||||
char *name;
|
||||
esize_t esize;
|
||||
vec3_t mins, maxs;
|
||||
vec3_t color;
|
||||
char *comments;
|
||||
char flagnames[MAX_FLAGS][32];
|
||||
char *name;
|
||||
esize_t esize;
|
||||
vec3_t mins, maxs;
|
||||
vec3_t color;
|
||||
char *comments;
|
||||
char *flagnames[MAX_FLAGS];
|
||||
}
|
||||
|
||||
- initFromText: (char *)text;
|
||||
- (char *)classname;
|
||||
- (esize_t)esize;
|
||||
- (float *)mins; // only for esize_fixed
|
||||
- (float *)maxs; // only for esize_fixed
|
||||
- (float *)drawColor;
|
||||
- (char *)comments;
|
||||
- (char *)flagName: (unsigned)flagnum;
|
||||
- (id) initFromText: (const char *)text source: (const char *)filename;
|
||||
|
||||
@end
|
||||
- (const char *) classname;
|
||||
- (esize_t) esize;
|
||||
- (float *) mins; // only for esize_fixed
|
||||
- (float *) maxs; // only for esize_fixed
|
||||
- (float *) drawColor;
|
||||
- (const char *) comments;
|
||||
- (const char *) flagName: (unsigned)flagnum;
|
||||
|
||||
extern id entity_classes_i;
|
||||
@end extern id entity_classes_i;
|
||||
|
||||
@interface EntityClassList : NSMutableArray
|
||||
@interface EntityClassList: NSMutableArray
|
||||
{
|
||||
id nullclass;
|
||||
char *source_path;
|
||||
NSMutableArray *array;
|
||||
id nullclass;
|
||||
char *source_path;
|
||||
}
|
||||
|
||||
- initForSourceDirectory: (char *)path;
|
||||
- (id)classForName: (char *)name;
|
||||
- (void)scanDirectory;
|
||||
- (id) initForSourceDirectory: (const char *)path;
|
||||
- (id) classForName: (const char *)name;
|
||||
- (void) scanDirectory;
|
||||
|
||||
@end
|
||||
|
||||
#endif // EntityClass_h
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
#include <dirent.h>
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "QF/quakeio.h"
|
||||
#include "QF/script.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "EntityClass.h"
|
||||
|
||||
@implementation EntityClass
|
||||
|
||||
static int
|
||||
parse_vector (script_t * script, vec3_t vec)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!Script_GetToken (script, 0))
|
||||
return 0;
|
||||
if (strcmp (Script_Token (script), "("))
|
||||
return 0;
|
||||
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
|
||||
if (r != 3)
|
||||
return 0;
|
||||
while (strcmp (Script_Token (script), ")")) {
|
||||
if (!Script_GetToken (script, 0))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// the classname, color triple, and bounding box are parsed out of comments
|
||||
// A ? size means take the exact brush size.
|
||||
//
|
||||
|
@ -11,255 +36,235 @@
|
|||
//
|
||||
// Flag names can follow the size description:
|
||||
//
|
||||
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
|
||||
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY
|
||||
// SILVER_KEY
|
||||
|
||||
char *debugname;
|
||||
- initFromText: (char *)text
|
||||
- (id) initFromText: (const char *)text source: (const char *)filename
|
||||
{
|
||||
char *t;
|
||||
int len;
|
||||
int r, i;
|
||||
char parms[256], *p;
|
||||
|
||||
const char *t;
|
||||
size_t len;
|
||||
int i;
|
||||
script_t *script;
|
||||
|
||||
[super init];
|
||||
|
||||
text += strlen("/*QUAKED ");
|
||||
|
||||
// grab the name
|
||||
text = COM_Parse (text);
|
||||
name = malloc (strlen(com_token)+1);
|
||||
strcpy (name, com_token);
|
||||
debugname = name;
|
||||
|
||||
// grab the color
|
||||
r = sscanf (text," (%f %f %f)", &color[0], &color[1], &color[2]);
|
||||
if (r != 3)
|
||||
return NULL;
|
||||
|
||||
while (*text != ')')
|
||||
{
|
||||
if (!*text)
|
||||
return NULL;
|
||||
text++;
|
||||
}
|
||||
text++;
|
||||
|
||||
// get the size
|
||||
text = COM_Parse (text);
|
||||
if (com_token[0] == '(')
|
||||
{ // parse the size as two vectors
|
||||
|
||||
text += strlen ("/*QUAKED ");
|
||||
|
||||
script = Script_New ();
|
||||
Script_Start (script, filename, text);
|
||||
|
||||
// grab the name
|
||||
if (!Script_GetToken (script, 0))
|
||||
return 0;
|
||||
if (!strcmp (Script_Token (script), "*/"))
|
||||
return 0;
|
||||
name = strdup (Script_Token (script));
|
||||
|
||||
// grab the color
|
||||
if (!parse_vector (script, color))
|
||||
return 0;
|
||||
// get the size
|
||||
if (!Script_GetToken (script, 0))
|
||||
return 0;
|
||||
if (!strcmp (Script_Token (script), "(")) {
|
||||
Script_UngetToken (script);
|
||||
if (!parse_vector (script, mins))
|
||||
return 0;
|
||||
if (!parse_vector (script, maxs))
|
||||
return 0;
|
||||
esize = esize_fixed;
|
||||
r = sscanf (text,"%f %f %f) (%f %f %f)", &mins[0], &mins[1], &mins[2], &maxs[0], &maxs[1], &maxs[2]);
|
||||
if (r != 6)
|
||||
return NULL;
|
||||
|
||||
for (i=0 ; i<2 ; i++)
|
||||
{
|
||||
while (*text != ')')
|
||||
{
|
||||
if (!*text)
|
||||
return NULL;
|
||||
text++;
|
||||
}
|
||||
text++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // use the brushes
|
||||
} else if (!strcmp (Script_Token (script), "?")) {
|
||||
// use the brushes
|
||||
esize = esize_model;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// get the flags
|
||||
|
||||
|
||||
// copy to the first /n
|
||||
p = parms;
|
||||
while (*text && *text != '\n')
|
||||
*p++ = *text++;
|
||||
*p = 0;
|
||||
text++;
|
||||
|
||||
// any remaining words are parm flags
|
||||
p = parms;
|
||||
for (i=0 ; i<8 ; i++)
|
||||
{
|
||||
p = COM_Parse (p);
|
||||
if (!p)
|
||||
// get the flags
|
||||
// any remaining words on the line are parm flags
|
||||
for (i = 0; i < MAX_FLAGS; i++) {
|
||||
if (!Script_TokenAvailable (script, 0))
|
||||
break;
|
||||
strcpy (flagnames[i], com_token);
|
||||
}
|
||||
Script_GetToken (script, 0);
|
||||
flagnames[i] = strdup (Script_Token (script));
|
||||
}
|
||||
while (Script_TokenAvailable (script, 0))
|
||||
Script_GetToken (script, 0);
|
||||
|
||||
// find the length until close comment
|
||||
for (t=text ; t[0] && !(t[0]=='*' && t[1]=='/') ; t++)
|
||||
;
|
||||
|
||||
// copy the comment block out
|
||||
len = t-text;
|
||||
comments = malloc (len+1);
|
||||
// find the length until close comment
|
||||
for (t = script->p; t[0] && !(t[0] == '*' && t[1] == '/'); t++)
|
||||
;
|
||||
|
||||
// copy the comment block out
|
||||
len = t - text;
|
||||
comments = malloc (len + 1);
|
||||
memcpy (comments, text, len);
|
||||
comments[len] = 0;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (esize_t)esize
|
||||
- (esize_t) esize
|
||||
{
|
||||
return esize;
|
||||
}
|
||||
|
||||
- (char *)classname
|
||||
- (const char *) classname
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
- (float *)mins
|
||||
- (float *) mins
|
||||
{
|
||||
return mins;
|
||||
}
|
||||
|
||||
- (float *)maxs
|
||||
- (float *) maxs
|
||||
{
|
||||
return maxs;
|
||||
}
|
||||
|
||||
- (float *)drawColor
|
||||
- (float *) drawColor
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
- (char *)comments
|
||||
- (const char *) comments
|
||||
{
|
||||
return comments;
|
||||
}
|
||||
|
||||
|
||||
- (char *)flagName: (unsigned)flagnum
|
||||
- (const char *) flagName: (unsigned)flagnum
|
||||
{
|
||||
if (flagnum >= MAX_FLAGS)
|
||||
Error ("EntityClass flagName: bad number");
|
||||
Sys_Error ("EntityClass flagName: bad number");
|
||||
return flagnames[flagnum];
|
||||
}
|
||||
|
||||
@end
|
||||
// ===========================================================================
|
||||
|
||||
//===========================================================================
|
||||
#define THING EntityClassList
|
||||
#include "THING+NSArray.m"
|
||||
|
||||
@implementation EntityClassList
|
||||
|
||||
/*
|
||||
=================
|
||||
insertEC:
|
||||
=================
|
||||
*/
|
||||
- (void)insertEC: ec
|
||||
- (void) insertEC: ec
|
||||
{
|
||||
char *name;
|
||||
int i;
|
||||
|
||||
const char *name;
|
||||
unsigned int i;
|
||||
|
||||
name = [ec classname];
|
||||
for (i=0 ; i<[self count] ; i++)
|
||||
{
|
||||
if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0)
|
||||
{
|
||||
[self insertObject: ec atIndex:i];
|
||||
for (i = 0; i < [self count]; i++) {
|
||||
if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0) {
|
||||
[self insertObject: ec atIndex: i];
|
||||
return;
|
||||
}
|
||||
}
|
||||
[self addObject: ec];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
scanFile
|
||||
=================
|
||||
*/
|
||||
- (void)scanFile: (char *)filename
|
||||
- (void) scanFile: (const char *)filename
|
||||
{
|
||||
int size;
|
||||
char *data;
|
||||
id cl;
|
||||
int i;
|
||||
char path[1024];
|
||||
|
||||
sprintf (path,"%s/%s", source_path, filename);
|
||||
|
||||
size = LoadFile (path, (void *)&data);
|
||||
|
||||
for (i=0 ; i<size ; i++)
|
||||
if (!strncmp(data+i, "/*QUAKED",8))
|
||||
{
|
||||
cl = [[EntityClass alloc] initFromText: data+i];
|
||||
int size, line;
|
||||
char *data;
|
||||
id cl;
|
||||
int i;
|
||||
const char *path;
|
||||
QFile *file;
|
||||
|
||||
path = va ("%s/%s", source_path, filename);
|
||||
|
||||
file = Qopen (path, "rt");
|
||||
if (!file)
|
||||
return;
|
||||
size = Qfilesize (file);
|
||||
data = malloc (size + 1);
|
||||
size = Qread (file, data, size);
|
||||
data[size] = 0;
|
||||
Qclose (file);
|
||||
|
||||
line = 1;
|
||||
for (i = 0; i < size; i++) {
|
||||
if (!strncmp (data + i, "/*QUAKED", 8)) {
|
||||
cl = [[EntityClass alloc]
|
||||
initFromText: (data + i)
|
||||
source: va ("%s:%d", filename, line)];
|
||||
if (cl)
|
||||
[self insertEC: cl];
|
||||
else
|
||||
printf ("Error parsing: %s in %s\n",debugname, filename);
|
||||
} else if (data[i] == '\n') {
|
||||
line++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
free (data);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
scanDirectory
|
||||
=================
|
||||
*/
|
||||
- (void)scanDirectory
|
||||
- (void) scanDirectory
|
||||
{
|
||||
int count, i;
|
||||
struct direct **namelist, *ent;
|
||||
|
||||
int count, i;
|
||||
struct dirent **namelist, *ent;
|
||||
|
||||
[self removeAllObjects];
|
||||
|
||||
count = scandir(source_path, &namelist, NULL, NULL);
|
||||
|
||||
for (i=0 ; i<count ; i++)
|
||||
{
|
||||
int len;
|
||||
|
||||
count = scandir (source_path, &namelist, NULL, NULL);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
int len;
|
||||
|
||||
ent = namelist[i];
|
||||
len = strlen (ent->d_name);
|
||||
if (len <= 3)
|
||||
continue;
|
||||
if (!strcmp (ent->d_name+len-3,".qc"))
|
||||
if (!strcmp (ent->d_name + len - 3, ".qc"))
|
||||
[self scanFile: ent->d_name];
|
||||
}
|
||||
}
|
||||
|
||||
id entity_classes_i;
|
||||
|
||||
id entity_classes_i;
|
||||
|
||||
|
||||
- initForSourceDirectory: (char *)path
|
||||
- (id) initForSourceDirectory: (const char *)path
|
||||
{
|
||||
[super init];
|
||||
|
||||
source_path = path;
|
||||
self = [super init];
|
||||
array = [[NSMutableArray alloc] init];
|
||||
|
||||
source_path = strdup (path); // FIXME leak?
|
||||
[self scanDirectory];
|
||||
|
||||
|
||||
entity_classes_i = self;
|
||||
|
||||
nullclass = [[EntityClass alloc] initFromText:
|
||||
"/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?"];
|
||||
|
||||
nullclass = [[EntityClass alloc]
|
||||
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/"
|
||||
source: va ("%s:%d", __FILE__, __LINE__ - 1)];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)classForName: (char *)name
|
||||
- (id) classForName: (const char *)name
|
||||
{
|
||||
int i;
|
||||
id o;
|
||||
|
||||
for (i=0 ; i<[self count] ; i++)
|
||||
{
|
||||
unsigned int i;
|
||||
id o;
|
||||
|
||||
for (i = 0; i < [self count]; i++) {
|
||||
o = [self objectAtIndex: i];
|
||||
if (!strcmp (name,[o classname]) )
|
||||
if (!strcmp (name, [o classname]))
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
return nullclass;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -1,27 +1,80 @@
|
|||
include GNUmakefile.find-makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
BUNDLE_NAME= MapEdit
|
||||
BUNDLE_EXTENSION= .forgeb
|
||||
#
|
||||
# We don't install this bundle, it goes inside the app.
|
||||
# Subprojects
|
||||
#
|
||||
BUNDLE_INSTALL_DIR= none
|
||||
MapEdit_STANDARD_INSTALL= no
|
||||
SUBPROJECTS=
|
||||
|
||||
MapEdit_RESOURCE_FILES= \
|
||||
MapEdit.gorm
|
||||
#
|
||||
# Main application
|
||||
#
|
||||
PACKAGE_NAME= QuakeEd
|
||||
APP_NAME= QuakeEd
|
||||
QuakeEd_PRINCIPAL_CLASS= QuakeEdApp
|
||||
QuakeEd_APPLICATION_ICON=
|
||||
|
||||
MapEdit_OBJC_FILES= \
|
||||
CameraView.m Clipper.m EntityClass.m KeypairView.m PopScrollView.m ZView.m misc.m render.m
|
||||
#
|
||||
# Additional libraries
|
||||
#
|
||||
ADDITIONAL_GUI_LIBS +=
|
||||
|
||||
MapEdit_HEADERS= \
|
||||
EntityClass.h
|
||||
#
|
||||
# Resource files
|
||||
#
|
||||
QuakeEd_MAIN_MODEL_FILE= MapEdit.gorm
|
||||
QuakeEd_RESOURCE_FILES= \
|
||||
MapEdit.gorm \
|
||||
help.txt \
|
||||
../../Images/DownArrow.tiff \
|
||||
../../Images/UpArrow.tiff \
|
||||
../../Images/i_90d.tiff \
|
||||
../../Images/i_add.tiff \
|
||||
../../Images/i_brushes.tiff \
|
||||
../../Images/i_fliph.tiff \
|
||||
../../Images/i_flipv.tiff \
|
||||
../../Images/i_quakeed.tiff \
|
||||
../../Images/i_sub.tiff \
|
||||
../../Images/short.tiff \
|
||||
../../Images/tall.tiff
|
||||
|
||||
MapEdit_PRINCIPAL_CLASS= \
|
||||
MapEdit
|
||||
QuakeEd_LOCALIZED_RESOURCE_FILES=
|
||||
|
||||
# Languages we're localized for
|
||||
QuakeEd_LANGUAGES= \
|
||||
English
|
||||
|
||||
#
|
||||
# Header files
|
||||
#
|
||||
QuakeEd_HEADERS= \
|
||||
CameraView.h Clipper.h Dict.h Entity.h EntityClass.h \
|
||||
InspectorControl.h KeypairView.h Map.h PopScrollView.h Preferences.h \
|
||||
Project.h QuakeEd.h SetBrush.h Storage.h TexturePalette.h TextureView.h \
|
||||
Things.h XYView.h ZScrollView.h ZView.h render.h \
|
||||
\
|
||||
THING+NSArray.m
|
||||
|
||||
#
|
||||
# Class files
|
||||
#
|
||||
QuakeEd_OBJC_FILES= \
|
||||
CameraView.m Clipper.m Dict.m Entity.m EntityClass.m \
|
||||
InspectorControl.m KeypairView.m Map.m PopScrollView.m Preferences.m \
|
||||
Project.m QuakeEd.m QuakeEd_main.m SetBrush.m Storage.m TexturePalette.m \
|
||||
TextureView.m Things.m XYView.m ZScrollView.m ZView.m render.m
|
||||
|
||||
#
|
||||
# C files
|
||||
#
|
||||
QuakeEd_C_FILES=
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
-include GNUmakefile.local
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
include $(GNUSTEP_MAKEFILES)/application.make
|
||||
|
||||
-include GNUmakefile.postamble
|
||||
|
||||
|
|
29
tools/Forge/Bundles/MapEdit/GNUmakefile.bundle
Normal file
29
tools/Forge/Bundles/MapEdit/GNUmakefile.bundle
Normal file
|
@ -0,0 +1,29 @@
|
|||
include GNUmakefile.find-makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
BUNDLE_NAME= MapEdit
|
||||
BUNDLE_EXTENSION= .forgeb
|
||||
#
|
||||
# We don't install this bundle, it goes inside the app.
|
||||
#
|
||||
BUNDLE_INSTALL_DIR= none
|
||||
MapEdit_STANDARD_INSTALL= no
|
||||
|
||||
MapEdit_RESOURCE_FILES= \
|
||||
MapEdit.gorm
|
||||
|
||||
MapEdit_OBJC_FILES= \
|
||||
CameraView.m Clipper.m Dict.m DictList.m Entity.m EntityClass.m InspectorControl.m KeypairView.m Map.m PopScrollView.m Preferences.m Project.m QuakeEd.m QuakeEd_main.m SetBrush.m Storage.m TexturePalette.m TextureView.m Things.m XYView.m ZScrollView.m ZView.m render.m
|
||||
|
||||
MapEdit_HEADERS= \
|
||||
EntityClass.h
|
||||
|
||||
MapEdit_PRINCIPAL_CLASS= \
|
||||
MapEdit
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
|
||||
-include GNUmakefile.postamble
|
13
tools/Forge/Bundles/MapEdit/GNUmakefile.find-makefiles
Normal file
13
tools/Forge/Bundles/MapEdit/GNUmakefile.find-makefiles
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Make sure that GNUSTEP_MAKEFILES is set.
|
||||
# First, try the "gnustep-config" program which should be in the path somewhere.
|
||||
# If that fails, try sourcing the GNUstep.conf file (which should be a legal Make fragment).
|
||||
# Finally, just give up and assume the default value.
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES=$(shell gnustep-config --variable=GNUSTEP_MAKEFILES)
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
-include /etc/GNUstep/GNUstep.conf
|
||||
ifeq ($(GNUSTEP_MAKEFILES),)
|
||||
GNUSTEP_MAKEFILES=/usr/GNUstep/Library/Makefiles
|
||||
endif
|
||||
endif
|
||||
endif
|
|
@ -2,16 +2,16 @@
|
|||
ADDITIONAL_CPPFLAGS +=
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS += -DUSING_NIBS -Wall -Werror
|
||||
ADDITIONAL_OBJCFLAGS += -DUSING_NIBS -Wall -Werror -Wsign-compare -Wwrite-strings #-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
ADDITIONAL_CFLAGS += -Wall -Werror
|
||||
ADDITIONAL_CFLAGS += -Wall -Werror -Wsign-compare -Wwrite-strings #-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
|
||||
|
||||
# Additional include directories the compiler should search
|
||||
ADDITIONAL_INCLUDE_DIRS += -I ../..
|
||||
ADDITIONAL_INCLUDE_DIRS += -I ../.. -I ../../../../include
|
||||
|
||||
# Additional LDFLAGS to pass to the linker
|
||||
ADDITIONAL_LDFLAGS +=
|
||||
ADDITIONAL_LDFLAGS += -lQFutil
|
||||
|
||||
# Additional library directories the linker should search
|
||||
ADDITIONAL_LIB_DIRS +=
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#ifndef InspectorControl_h
|
||||
#define InspectorControl_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#define MINIWINICON "DoomEdIcon"
|
||||
#define MINIWINICON "DoomEdIcon"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
i_project,
|
||||
i_textures,
|
||||
i_things,
|
||||
|
@ -13,59 +14,69 @@ typedef enum
|
|||
i_output,
|
||||
i_help,
|
||||
i_end
|
||||
} insp_e;
|
||||
} insp_e;
|
||||
|
||||
extern id inspcontrol_i;
|
||||
@class InspectorControl;
|
||||
|
||||
@interface InspectorControl:Object
|
||||
extern InspectorControl *inspcontrol_i;
|
||||
|
||||
@interface InspectorControl: NSObject
|
||||
{
|
||||
id inspectorView_i; // inspector view
|
||||
id inspectorSubview_i; // inspector view's current subview (gets replaced)
|
||||
IBOutlet NSView *inspectorView_i; // inspector view
|
||||
IBOutlet NSView *inspectorSubview_i; // inspector view's current subview
|
||||
// (gets replaced)
|
||||
|
||||
id contentList; // List of contentviews (corresponds to
|
||||
// insp_e enum order)
|
||||
id windowList; // List of Windows (corresponds to
|
||||
// insp_e enum order)
|
||||
id contentList; // List of contentviews (corresponds to
|
||||
// insp_e enum order)
|
||||
|
||||
id obj_textures_i; // TexturePalette object (for delegating)
|
||||
id obj_genkeypair_i; // GenKeyPair object
|
||||
id windowList; // List of Windows (corresponds to
|
||||
// insp_e enum order)
|
||||
|
||||
id obj_textures_i; // TexturePalette object (for
|
||||
// delegating)
|
||||
id obj_genkeypair_i; // GenKeyPair object
|
||||
|
||||
NSPopUpButton *popUpButton_i; // PopUpList title button
|
||||
NSMatrix *popUpMatrix_i; // PopUpList matrix
|
||||
NSMutableArray *itemList; // List of popUp buttons
|
||||
|
||||
IBOutlet NSTextView *helpView;
|
||||
|
||||
insp_e currentInspectorType; // keep track of current inspector
|
||||
|
||||
id popUpButton_i; // PopUpList title button
|
||||
id popUpMatrix_i; // PopUpList matrix
|
||||
id itemList; // List of popUp buttons
|
||||
|
||||
insp_e currentInspectorType; // keep track of current inspector
|
||||
//
|
||||
// Add id's here for new inspectors
|
||||
// **NOTE: Make sure PopUpList has correct TAG value that
|
||||
// corresponds to the enums above!
|
||||
|
||||
// Add id's here for new inspectors
|
||||
// **NOTE: Make sure PopUpList has correct TAG value that
|
||||
// corresponds to the enums above!
|
||||
|
||||
// Windows
|
||||
id win_project_i; // project
|
||||
id win_textures_i; // textures
|
||||
id win_things_i; // things
|
||||
id win_prefs_i; // preferences
|
||||
id win_settings_i; // project settings
|
||||
id win_output_i; // bsp output
|
||||
id win_help_i; // documentation
|
||||
|
||||
IBOutlet NSWindow *win_project_i; // project
|
||||
IBOutlet NSWindow *win_textures_i; // textures
|
||||
IBOutlet NSWindow *win_things_i; // things
|
||||
IBOutlet NSWindow *win_prefs_i; // preferences
|
||||
IBOutlet NSWindow *win_settings_i; // project settings
|
||||
IBOutlet NSWindow *win_output_i; // bsp output
|
||||
IBOutlet NSWindow *win_help_i; // documentation
|
||||
|
||||
// PopUpList objs
|
||||
id itemProject_i; // project
|
||||
id itemTextures_i; // textures
|
||||
id itemThings_i; // things
|
||||
id itemPrefs_i; // preferences
|
||||
id itemSettings_i; // project settings
|
||||
id itemOutput_i; // bsp output
|
||||
id itemHelp_i; // docs
|
||||
IBOutlet id <NSMenuItem> itemProject_i; // project
|
||||
IBOutlet id <NSMenuItem> itemTextures_i; // textures
|
||||
IBOutlet id <NSMenuItem> itemThings_i; // things
|
||||
IBOutlet id <NSMenuItem> itemPrefs_i; // preferences
|
||||
IBOutlet id <NSMenuItem> itemSettings_i; // project settings
|
||||
IBOutlet id <NSMenuItem> itemOutput_i; // bsp output
|
||||
IBOutlet id <NSMenuItem> itemHelp_i; // docs
|
||||
}
|
||||
|
||||
- awakeFromNib;
|
||||
- changeInspector:sender;
|
||||
- changeInspectorTo:(insp_e)which;
|
||||
- (insp_e)getCurrentInspector;
|
||||
- (IBAction) changeInspector: (id)sender;
|
||||
|
||||
- (void) setCurrentInspector: (insp_e)which;
|
||||
- (insp_e) currentInspector;
|
||||
|
||||
@end
|
||||
|
||||
@protocol InspectorControl
|
||||
- windowResized;
|
||||
- (void) windowResized;
|
||||
@end
|
||||
|
||||
#endif // InspectorControl_h
|
||||
|
|
|
@ -1,128 +1,128 @@
|
|||
#include "QF/sys.h"
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "InspectorControl.h"
|
||||
|
||||
// Add .h-files here for new inspectors
|
||||
#include "Things.h"
|
||||
#include "TexturePalette.h"
|
||||
#include "Preferences.h"
|
||||
#include "Things.h"
|
||||
#include "TexturePalette.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
id inspcontrol_i;
|
||||
InspectorControl *inspcontrol_i;
|
||||
|
||||
@interface CustomView: NSView
|
||||
@end
|
||||
@implementation CustomView
|
||||
@end
|
||||
|
||||
@implementation InspectorControl
|
||||
|
||||
- awakeFromNib
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
NSBundle *mainBundle = [NSBundle mainBundle];
|
||||
NSString *path = [mainBundle pathForResource: @"help" ofType: @"txt"
|
||||
inDirectory: nil];
|
||||
NSString *help = [NSString stringWithContentsOfFile: path];
|
||||
|
||||
[helpView setString: help];
|
||||
|
||||
inspcontrol_i = self;
|
||||
|
||||
|
||||
currentInspectorType = -1;
|
||||
|
||||
contentList = [[List alloc] init];
|
||||
windowList = [[List alloc] init];
|
||||
itemList = [[List alloc] init];
|
||||
contentList = [[NSMutableArray alloc] init];
|
||||
windowList = [[NSMutableArray alloc] init];
|
||||
itemList = [[NSMutableArray alloc] init];
|
||||
|
||||
// ADD NEW INSPECTORS HERE...
|
||||
|
||||
[windowList addObject:win_project_i];
|
||||
[contentList addObject:[win_project_i contentView]];
|
||||
[itemProject_i setKeyEquivalent:'1'];
|
||||
[itemList addObject:itemProject_i];
|
||||
[windowList addObject: win_project_i];
|
||||
[contentList addObject: [win_project_i contentView]];
|
||||
[itemProject_i setKeyEquivalent: @"1"];
|
||||
[itemList addObject: itemProject_i];
|
||||
|
||||
[windowList addObject:win_textures_i];
|
||||
[contentList addObject:[win_textures_i contentView]];
|
||||
[itemTextures_i setKeyEquivalent:'2'];
|
||||
[itemList addObject:itemTextures_i];
|
||||
[windowList addObject: win_textures_i];
|
||||
[contentList addObject: [win_textures_i contentView]];
|
||||
[itemTextures_i setKeyEquivalent: @"2"];
|
||||
[itemList addObject: itemTextures_i];
|
||||
|
||||
[windowList addObject:win_things_i];
|
||||
[contentList addObject:[win_things_i contentView]];
|
||||
[itemThings_i setKeyEquivalent:'3'];
|
||||
[itemList addObject:itemThings_i];
|
||||
|
||||
[windowList addObject:win_prefs_i];
|
||||
[contentList addObject:[win_prefs_i contentView]];
|
||||
[itemPrefs_i setKeyEquivalent:'4'];
|
||||
[itemList addObject:itemPrefs_i];
|
||||
[windowList addObject: win_things_i];
|
||||
[contentList addObject: [win_things_i contentView]];
|
||||
[itemThings_i setKeyEquivalent: @"3"];
|
||||
[itemList addObject: itemThings_i];
|
||||
|
||||
[windowList addObject:win_settings_i];
|
||||
[contentList addObject:[win_settings_i contentView]];
|
||||
[itemSettings_i setKeyEquivalent:'5'];
|
||||
[itemList addObject:itemSettings_i];
|
||||
[windowList addObject: win_prefs_i];
|
||||
[contentList addObject: [win_prefs_i contentView]];
|
||||
[itemPrefs_i setKeyEquivalent: @"4"];
|
||||
[itemList addObject: itemPrefs_i];
|
||||
|
||||
[windowList addObject:win_output_i];
|
||||
[contentList addObject:[win_output_i contentView]];
|
||||
[itemOutput_i setKeyEquivalent:'6'];
|
||||
[itemList addObject:itemOutput_i];
|
||||
[windowList addObject: win_settings_i];
|
||||
[contentList addObject: [win_settings_i contentView]];
|
||||
[itemSettings_i setKeyEquivalent: @"5"];
|
||||
[itemList addObject: itemSettings_i];
|
||||
|
||||
[windowList addObject:win_help_i];
|
||||
[contentList addObject:[win_help_i contentView]];
|
||||
[itemHelp_i setKeyEquivalent:'7'];
|
||||
[itemList addObject:itemHelp_i];
|
||||
[windowList addObject: win_output_i];
|
||||
[contentList addObject: [win_output_i contentView]];
|
||||
[itemOutput_i setKeyEquivalent: @"6"];
|
||||
[itemList addObject: itemOutput_i];
|
||||
|
||||
[windowList addObject: win_help_i];
|
||||
[contentList addObject: [win_help_i contentView]];
|
||||
[itemHelp_i setKeyEquivalent: @"7"];
|
||||
[itemList addObject: itemHelp_i];
|
||||
|
||||
// Setup inspector window with project subview first
|
||||
|
||||
[inspectorView_i setAutoresizeSubviews:YES];
|
||||
[inspectorView_i setAutoresizesSubviews: YES];
|
||||
|
||||
inspectorSubview_i = [contentList objectAt:i_project];
|
||||
[inspectorView_i addSubview:inspectorSubview_i];
|
||||
inspectorSubview_i = [contentList objectAtIndex: i_project];
|
||||
|
||||
[inspectorView_i addSubview: inspectorSubview_i];
|
||||
|
||||
currentInspectorType = -1;
|
||||
[self changeInspectorTo:i_project];
|
||||
|
||||
return self;
|
||||
[self setCurrentInspector: i_project];
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Sent by the PopUpList in the Inspector
|
||||
// Each cell in the PopUpList must have the correct tag
|
||||
//
|
||||
- changeInspector:sender
|
||||
// Sent by the PopUpList in the Inspector
|
||||
// Each cell in the PopUpList must have the correct tag
|
||||
- (IBAction) changeInspector: sender
|
||||
{
|
||||
id cell;
|
||||
|
||||
cell = [sender selectedCell];
|
||||
[self changeInspectorTo:[cell tag]];
|
||||
return self;
|
||||
[self setCurrentInspector: [sender selectedTag]];
|
||||
}
|
||||
|
||||
//
|
||||
// Change to specific Inspector
|
||||
//
|
||||
- changeInspectorTo:(insp_e)which
|
||||
// Change to specific Inspector
|
||||
- (void) setCurrentInspector: (insp_e)which
|
||||
{
|
||||
id newView;
|
||||
NSRect r;
|
||||
id cell;
|
||||
NSRect f;
|
||||
|
||||
id newView;
|
||||
NSRect r;
|
||||
NSRect f;
|
||||
|
||||
if (which == currentInspectorType)
|
||||
return self;
|
||||
|
||||
return;
|
||||
currentInspectorType = which;
|
||||
newView = [contentList objectAt:which];
|
||||
|
||||
cell = [itemList objectAt:which]; // set PopUpButton title
|
||||
[popUpButton_i setTitle:[cell title]];
|
||||
|
||||
[inspectorView_i replaceSubview:inspectorSubview_i with:newView];
|
||||
[inspectorView_i getFrame:&r];
|
||||
newView = [contentList objectAtIndex: which];
|
||||
|
||||
[popUpButton_i selectItemAtIndex: which];
|
||||
|
||||
[inspectorView_i replaceSubview: inspectorSubview_i with: newView];
|
||||
r = [inspectorView_i frame];
|
||||
inspectorSubview_i = newView;
|
||||
[inspectorSubview_i setAutosizing:NS_WIDTHSIZABLE | NS_HEIGHTSIZABLE];
|
||||
[inspectorSubview_i sizeTo:r.size.width - 4 :r.size.height - 4];
|
||||
|
||||
[inspectorSubview_i setAutoresizingMask: NSViewWidthSizable |
|
||||
NSViewHeightSizable];
|
||||
r.size.width -= 4;
|
||||
r.size.height -= 4;
|
||||
[inspectorSubview_i setFrameSize: r.size];
|
||||
|
||||
[inspectorSubview_i lockFocus];
|
||||
[inspectorSubview_i getBounds:&f];
|
||||
PSsetgray(NS_LTGRAY);
|
||||
NSRectFill(&f);
|
||||
f = [inspectorSubview_i bounds];
|
||||
[[NSColor windowBackgroundColor] set];
|
||||
NSRectFill (f);
|
||||
[inspectorSubview_i unlockFocus];
|
||||
[inspectorView_i display];
|
||||
|
||||
return self;
|
||||
[inspectorView_i setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (insp_e)getCurrentInspector
|
||||
- (insp_e) currentInspector
|
||||
{
|
||||
return currentInspectorType;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
#ifndef KeypairView_h
|
||||
#define KeypairView_h
|
||||
|
||||
extern id keypairview_i;
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface KeypairView:NSView
|
||||
extern id keypairview_i;
|
||||
|
||||
@interface KeypairView: NSView
|
||||
{
|
||||
}
|
||||
|
||||
- calcViewSize;
|
||||
- (id) calcViewSize;
|
||||
|
||||
#define SPACING 4
|
||||
#define FONTSIZE 12
|
||||
#define EXTRASPC 2
|
||||
#define SPACING 4
|
||||
#define FONTSIZE 12
|
||||
#define EXTRASPC 2
|
||||
|
||||
#define LINEHEIGHT 16
|
||||
#define LINEHEIGHT 16
|
||||
|
||||
@end
|
||||
|
||||
#endif // KeypairView_h
|
||||
|
|
|
@ -1,92 +1,98 @@
|
|||
#include "KeypairView.h"
|
||||
#include "Map.h"
|
||||
#include "Entity.h"
|
||||
#include "Things.h"
|
||||
|
||||
#include "qedefs.h"
|
||||
|
||||
id keypairview_i;
|
||||
id keypairview_i;
|
||||
|
||||
@implementation KeypairView
|
||||
|
||||
/*
|
||||
==================
|
||||
initWithFrame:
|
||||
==================
|
||||
*/
|
||||
- initWithFrame:(NSRect)frameRect
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
{
|
||||
[super initWithFrame:frameRect];
|
||||
[super initWithFrame: frameRect];
|
||||
keypairview_i = self;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- calcViewSize
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
NSRect b;
|
||||
NSPoint pt;
|
||||
int count;
|
||||
id ent;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id) calcViewSize
|
||||
{
|
||||
NSRect b;
|
||||
NSPoint pt;
|
||||
int count;
|
||||
id ent;
|
||||
|
||||
ent = [map_i currentEntity];
|
||||
count = [ent numPairs];
|
||||
|
||||
//XXX[_super_view setFlipped: YES];
|
||||
|
||||
b = [_super_view bounds];
|
||||
b.size.height = LINEHEIGHT*count + SPACING;
|
||||
[self setBounds: b];
|
||||
b = [[self superview] bounds];
|
||||
b.size.height = LINEHEIGHT * count + SPACING;
|
||||
[self setFrameSize: b.size];
|
||||
pt.x = pt.y = 0;
|
||||
[self scrollPoint: pt];
|
||||
return self;
|
||||
}
|
||||
|
||||
- drawSelf:(const NSRect *)rects :(int)rectCount
|
||||
- (id) drawRect: (NSRect)rects
|
||||
{
|
||||
epair_t *pair;
|
||||
int y;
|
||||
|
||||
//XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||
PSrectfill(0,0,_bounds.size.width,_bounds.size.height);
|
||||
|
||||
//XXX PSselectfont("Helvetica-Bold",FONTSIZE);
|
||||
PSrotate(0);
|
||||
PSsetgray(0);
|
||||
|
||||
epair_t *pair;
|
||||
int y;
|
||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||
|
||||
[[NSColor lightGrayColor] set];
|
||||
NSRectFill (NSMakeRect (0, 0, _bounds.size.width, _bounds.size.height));
|
||||
|
||||
[[NSFont systemFontOfSize: FONTSIZE] set];
|
||||
[[NSColor blackColor] set];
|
||||
|
||||
pair = [[map_i currentEntity] epairs];
|
||||
y = _bounds.size.height - LINEHEIGHT;
|
||||
for ( ; pair ; pair=pair->next)
|
||||
{
|
||||
PSmoveto(SPACING, y);
|
||||
PSshow(pair->key);
|
||||
PSmoveto(100, y);
|
||||
PSshow(pair->value);
|
||||
for ( ; pair; pair = pair->next) {
|
||||
NSString *key = [NSString stringWithCString: pair->key];
|
||||
NSString *value = [NSString stringWithCString: pair->value];
|
||||
|
||||
[key drawAtPoint: NSMakePoint (SPACING, y) withAttributes: attribs];
|
||||
[value drawAtPoint: NSMakePoint (100, y) withAttributes: attribs];
|
||||
y -= LINEHEIGHT;
|
||||
}
|
||||
PSstroke();
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
- (void) mouseDown: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint loc;
|
||||
int i;
|
||||
epair_t *p;
|
||||
NSPoint loc;
|
||||
int i;
|
||||
epair_t *p;
|
||||
|
||||
loc = [theEvent locationInWindow];
|
||||
loc = [self convertPoint:loc fromView:NULL];
|
||||
|
||||
loc = [self convertPoint: loc fromView: NULL];
|
||||
|
||||
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
|
||||
|
||||
p = [[map_i currentEntity] epairs];
|
||||
while ( i )
|
||||
{
|
||||
p=p->next;
|
||||
while (i) {
|
||||
p = p->next;
|
||||
if (!p)
|
||||
return;
|
||||
i--;
|
||||
}
|
||||
if (p)
|
||||
[things_i setSelectedKey: p];
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,68 +1,77 @@
|
|||
#ifndef Map_h
|
||||
#define Map_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
// Map is a list of Entity objects
|
||||
|
||||
extern id map_i;
|
||||
extern id map_i;
|
||||
|
||||
@interface Map : NSMutableArray
|
||||
@interface Map: NSMutableArray
|
||||
{
|
||||
id currentEntity;
|
||||
id oldselection; // temp when loading a new map
|
||||
float minz, maxz;
|
||||
NSMutableArray *array;
|
||||
id currentEntity;
|
||||
id oldselection; // temp when loading a new map
|
||||
float minz, maxz;
|
||||
}
|
||||
|
||||
- newMap;
|
||||
- (id) newMap;
|
||||
|
||||
- writeStats;
|
||||
- (id) writeStats;
|
||||
|
||||
- readMapFile: (char *)fname;
|
||||
- writeMapFile: (char *)fname useRegion: (BOOL)reg;
|
||||
- (id) readMapFile: (const char *)fname;
|
||||
- (id) writeMapFile: (const char *)fname useRegion: (BOOL)reg;
|
||||
|
||||
- entityConnect: (vec3_t)p1 : (vec3_t)p2;
|
||||
- (id) entityConnect: (vec3_t)p1: (vec3_t)p2;
|
||||
|
||||
- selectRay: (vec3_t)p1 : (vec3_t)p2 : (BOOL)ef;
|
||||
- grabRay: (vec3_t)p1 : (vec3_t)p2;
|
||||
- setTextureRay: (vec3_t)p1 : (vec3_t)p2 : (BOOL)allsides;
|
||||
- getTextureRay: (vec3_t)p1 : (vec3_t)p2;
|
||||
- (id) selectRay: (vec3_t)p1: (vec3_t)p2: (BOOL)ef;
|
||||
- (id) grabRay: (vec3_t)p1: (vec3_t)p2;
|
||||
- (id) setTextureRay: (vec3_t)p1: (vec3_t)p2: (BOOL)allsides;
|
||||
- (id) getTextureRay: (vec3_t)p1: (vec3_t)p2;
|
||||
|
||||
- currentEntity;
|
||||
- setCurrentEntity: ent;
|
||||
- (id) currentEntity;
|
||||
- (id) setCurrentEntity: ent;
|
||||
|
||||
- (float)currentMinZ;
|
||||
- setCurrentMinZ: (float)m;
|
||||
- (float)currentMaxZ;
|
||||
- setCurrentMaxZ: (float)m;
|
||||
- (float) currentMinZ;
|
||||
- (id) setCurrentMinZ: (float)m;
|
||||
- (float) currentMaxZ;
|
||||
- (id) setCurrentMaxZ: (float)m;
|
||||
|
||||
- (int)numSelected;
|
||||
- selectedBrush; // returns the first selected brush
|
||||
- (int) numSelected;
|
||||
- (id) selectedBrush; // returns the first selected brush
|
||||
|
||||
//
|
||||
// operations on current selection
|
||||
//
|
||||
- makeSelectedPerform: (SEL)sel;
|
||||
- makeUnselectedPerform: (SEL)sel;
|
||||
- makeAllPerform: (SEL)sel;
|
||||
- makeGlobalPerform: (SEL)sel; // in and out of region
|
||||
- (id) makeSelectedPerform: (SEL)sel;
|
||||
- (id) makeUnselectedPerform: (SEL)sel;
|
||||
- (id) makeAllPerform: (SEL)sel;
|
||||
- (id) makeGlobalPerform: (SEL)sel; // in and out of region
|
||||
|
||||
- cloneSelection: sender;
|
||||
- (id) cloneSelection: sender;
|
||||
|
||||
- makeEntity: sender;
|
||||
- (id) makeEntity: sender;
|
||||
|
||||
- subtractSelection: sender;
|
||||
- (id) subtractSelection: sender;
|
||||
|
||||
- selectCompletelyInside: sender;
|
||||
- selectPartiallyInside: sender;
|
||||
- (id) selectCompletelyInside: sender;
|
||||
- (id) selectPartiallyInside: sender;
|
||||
|
||||
- tallBrush: sender;
|
||||
- shortBrush: sender;
|
||||
- (id) tallBrush: sender;
|
||||
- (id) shortBrush: sender;
|
||||
|
||||
- rotate_x: sender;
|
||||
- rotate_y: sender;
|
||||
- rotate_z: sender;
|
||||
- (id) rotate_x: sender;
|
||||
- (id) rotate_y: sender;
|
||||
- (id) rotate_z: sender;
|
||||
|
||||
- flip_x: sender;
|
||||
- flip_y: sender;
|
||||
- flip_z: sender;
|
||||
- (id) flip_x: sender;
|
||||
- (id) flip_y: sender;
|
||||
- (id) flip_z: sender;
|
||||
|
||||
- selectCompleteEntity: sender;
|
||||
- (id) selectCompleteEntity: sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif // Map_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/DownArrow.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/DownArrow.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/UpArrow.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/UpArrow.tiff
Normal file
Binary file not shown.
316
tools/Forge/Bundles/MapEdit/MapEdit.gorm/data.classes
Normal file
316
tools/Forge/Bundles/MapEdit/MapEdit.gorm/data.classes
Normal file
|
@ -0,0 +1,316 @@
|
|||
{
|
||||
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
||||
CameraView = {
|
||||
Actions = (
|
||||
"drawMode:",
|
||||
"homeView:",
|
||||
"upFloor:",
|
||||
"downFloor:"
|
||||
);
|
||||
Outlets = (
|
||||
mode_radio_i
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
Clipper = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
FirstResponder = {
|
||||
Actions = (
|
||||
"BSP_FastVis:",
|
||||
"BSP_Full:",
|
||||
"BSP_NoVis:",
|
||||
"BSP_entities:",
|
||||
"BSP_relight:",
|
||||
"BSP_stop:",
|
||||
"UIChanged:",
|
||||
"addPair:",
|
||||
"appDidInit:",
|
||||
"appWillTerminate:",
|
||||
"applyRegion:",
|
||||
"centerCamera:",
|
||||
"centerZChecker:",
|
||||
"changeInspector:",
|
||||
"changeXYLookUp:",
|
||||
"clear:",
|
||||
"clearBspOutput:",
|
||||
"clearTexinfo:",
|
||||
"clickedOnMap:",
|
||||
"clickedOnWad:",
|
||||
"cloneSelection:",
|
||||
"decRotate:",
|
||||
"decXScale:",
|
||||
"decXShift:",
|
||||
"decYScale:",
|
||||
"decYShift:",
|
||||
"delPair:",
|
||||
"doubleClickEntity:",
|
||||
"downFloor:",
|
||||
"drawMode:",
|
||||
"flip_x:",
|
||||
"flip_y:",
|
||||
"flip_z:",
|
||||
"homeView:",
|
||||
"incRotate:",
|
||||
"incXScale:",
|
||||
"incXShift:",
|
||||
"incYScale:",
|
||||
"incYShift:",
|
||||
"makeEntity:",
|
||||
"onlyShowMapTextures:",
|
||||
"openProject:",
|
||||
"reloadEntityClasses:",
|
||||
"rotate_x:",
|
||||
"rotate_y:",
|
||||
"rotate_z:",
|
||||
"save:",
|
||||
"saveAs:",
|
||||
"searchForTexture:",
|
||||
"selectCompleteEntity:",
|
||||
"selectCompletelyInside:",
|
||||
"selectEntity:",
|
||||
"selectPartiallyInside:",
|
||||
"setAngle:",
|
||||
"setBrushRegion:",
|
||||
"setBspSound:",
|
||||
"setCurrentEntity:",
|
||||
"setCurrentProject:",
|
||||
"setFlags:",
|
||||
"setModeRadio:",
|
||||
"setParent:",
|
||||
"setXYRegion:",
|
||||
"shortBrush:",
|
||||
"subtractSelection:",
|
||||
"tallBrush:",
|
||||
"textCommand:",
|
||||
"texturedefChanged:",
|
||||
"upFloor:",
|
||||
"updateAll:"
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
InspectorControl = {
|
||||
Actions = (
|
||||
"changeInspector:"
|
||||
);
|
||||
Outlets = (
|
||||
inspectorView_i,
|
||||
inspectorSubview_i,
|
||||
contentList,
|
||||
windowList,
|
||||
obj_textures_i,
|
||||
obj_genkeypair_i,
|
||||
popUpButton_i,
|
||||
popUpMatrix_i,
|
||||
itemList,
|
||||
helpView,
|
||||
win_project_i,
|
||||
win_textures_i,
|
||||
win_things_i,
|
||||
win_prefs_i,
|
||||
win_settings_i,
|
||||
win_output_i,
|
||||
win_help_i,
|
||||
itemProject_i,
|
||||
itemTextures_i,
|
||||
itemThings_i,
|
||||
itemPrefs_i,
|
||||
itemSettings_i,
|
||||
itemOutput_i,
|
||||
itemHelp_i
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
Map = {
|
||||
Actions = (
|
||||
"setCurrentEntity:",
|
||||
"cloneSelection:",
|
||||
"makeEntity:",
|
||||
"subtractSelection:",
|
||||
"selectCompletelyInside:",
|
||||
"selectPartiallyInside:",
|
||||
"tallBrush:",
|
||||
"shortBrush:",
|
||||
"rotate_x:",
|
||||
"rotate_y:",
|
||||
"rotate_z:",
|
||||
"flip_x:",
|
||||
"flip_y:",
|
||||
"flip_z:",
|
||||
"selectCompleteEntity:"
|
||||
);
|
||||
Outlets = (
|
||||
currentEntity,
|
||||
oldselection
|
||||
);
|
||||
Super = NSMutableArray;
|
||||
};
|
||||
Preferences = {
|
||||
Actions = (
|
||||
"setBspSound:",
|
||||
"setCurrentProject:",
|
||||
"UIChanged:"
|
||||
);
|
||||
Outlets = (
|
||||
bspSound_i,
|
||||
startproject_i,
|
||||
bspSoundField_i,
|
||||
brushOffset_i,
|
||||
showBSP_i,
|
||||
startwad_i,
|
||||
xlight_i,
|
||||
ylight_i,
|
||||
zlight_i
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
Project = {
|
||||
Actions = (
|
||||
"clearBspOutput:",
|
||||
"clickedOnMap:",
|
||||
"clickedOnWad:"
|
||||
);
|
||||
Outlets = (
|
||||
projectInfo,
|
||||
basepathinfo_i,
|
||||
mapbrowse_i,
|
||||
currentmap_i,
|
||||
mapList,
|
||||
descList,
|
||||
wadList,
|
||||
pis_panel_i,
|
||||
pis_basepath_i,
|
||||
pis_wads_i,
|
||||
pis_fullvis_i,
|
||||
pis_fastvis_i,
|
||||
pis_novis_i,
|
||||
pis_relight_i,
|
||||
pis_leaktest_i,
|
||||
BSPoutput_i
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
QuakeEd = {
|
||||
Actions = (
|
||||
"updateAll:",
|
||||
"appDidInit:",
|
||||
"appWillTerminate:",
|
||||
"openProject:",
|
||||
"textCommand:",
|
||||
"applyRegion:",
|
||||
"clear:",
|
||||
"centerCamera:",
|
||||
"centerZChecker:",
|
||||
"changeXYLookUp:",
|
||||
"setBrushRegion:",
|
||||
"setXYRegion:",
|
||||
"open:",
|
||||
"save:",
|
||||
"saveAs:",
|
||||
"BSP_Full:",
|
||||
"BSP_FastVis:",
|
||||
"BSP_NoVis:",
|
||||
"BSP_relight:",
|
||||
"BSP_stop:",
|
||||
"BSP_entities:"
|
||||
);
|
||||
Outlets = (
|
||||
brushcount_i,
|
||||
entitycount_i,
|
||||
regionbutton_i,
|
||||
show_coordinates_i,
|
||||
show_names_i,
|
||||
filter_light_i,
|
||||
filter_path_i,
|
||||
filter_entities_i,
|
||||
filter_clip_i,
|
||||
filter_water_i,
|
||||
filter_world_i,
|
||||
cmd_in_i,
|
||||
cmd_out_i,
|
||||
xy_drawmode_i
|
||||
);
|
||||
Super = NSWindow;
|
||||
};
|
||||
TexturePalette = {
|
||||
Actions = (
|
||||
"searchForTexture:",
|
||||
"clearTexinfo:",
|
||||
"incXShift:",
|
||||
"decXShift:",
|
||||
"incYShift:",
|
||||
"decYShift:",
|
||||
"incRotate:",
|
||||
"decRotate:",
|
||||
"incXScale:",
|
||||
"decXScale:",
|
||||
"incYScale:",
|
||||
"decYScale:",
|
||||
"texturedefChanged:",
|
||||
"onlyShowMapTextures:"
|
||||
);
|
||||
Outlets = (
|
||||
textureList_i,
|
||||
textureView_i,
|
||||
searchField_i,
|
||||
sizeField_i,
|
||||
field_Xshift_i,
|
||||
field_Yshift_i,
|
||||
field_Xscale_i,
|
||||
field_Yscale_i,
|
||||
field_Rotate_i
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
TextureView = {
|
||||
Actions = (
|
||||
"setParent:"
|
||||
);
|
||||
Outlets = (
|
||||
parent_i
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
Things = {
|
||||
Actions = (
|
||||
"reloadEntityClasses:",
|
||||
"selectEntity:",
|
||||
"doubleClickEntity:",
|
||||
"addPair:",
|
||||
"delPair:",
|
||||
"setAngle:",
|
||||
"setFlags:"
|
||||
);
|
||||
Outlets = (
|
||||
entity_browser_i,
|
||||
entity_comment_i,
|
||||
prog_path_i,
|
||||
keyInput_i,
|
||||
valueInput_i,
|
||||
flags_i
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
XYView = {
|
||||
Actions = (
|
||||
"setModeRadio:",
|
||||
"drawMode:",
|
||||
"drawMode:"
|
||||
);
|
||||
Outlets = (
|
||||
mode_radio_i
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
ZView = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
}
|
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/data.info
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/data.info
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_90d.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_90d.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_add.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_add.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_brushes.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_brushes.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_fliph.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_fliph.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_flipv.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_flipv.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_quakeed.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_quakeed.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_sub.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/i_sub.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/objects.gorm
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/objects.gorm
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/short.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/short.tiff
Normal file
Binary file not shown.
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/tall.tiff
Normal file
BIN
tools/Forge/Bundles/MapEdit/MapEdit.gorm/tall.tiff
Normal file
Binary file not shown.
|
@ -1,11 +1,18 @@
|
|||
#ifndef PopScrollView_h
|
||||
#define PopScrollView_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface PopScrollView : NSScrollView
|
||||
@interface PopScrollView: NSScrollView
|
||||
{
|
||||
id button1, button2;
|
||||
id button1, button2;
|
||||
}
|
||||
|
||||
- initWithFrame:(NSRect)frameRect button1: b1 button2: b2;
|
||||
- tile;
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
button1: b1
|
||||
button2: b2;
|
||||
|
||||
- (id) tile;
|
||||
|
||||
@end
|
||||
#endif // PopScrollView_h
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
#include "qedefs.h"
|
||||
#include "PopScrollView.h"
|
||||
|
||||
@implementation PopScrollView
|
||||
|
||||
/*
|
||||
====================
|
||||
initWithFrame: button:
|
||||
|
@ -10,10 +8,11 @@ initWithFrame: button:
|
|||
Initizes a scroll view with a button at it's lower right corner
|
||||
====================
|
||||
*/
|
||||
|
||||
- initWithFrame:(NSRect)frameRect button1:b1 button2:b2
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
button1: b1
|
||||
button2: b2
|
||||
{
|
||||
[super initWithFrame: frameRect];
|
||||
[super initWithFrame: frameRect];
|
||||
|
||||
[self addSubview: b1];
|
||||
[self addSubview: b2];
|
||||
|
@ -25,10 +24,14 @@ Initizes a scroll view with a button at it's lower right corner
|
|||
[self setHasVerticalScroller: YES];
|
||||
|
||||
[self setBorderType: NSBezelBorder];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -37,20 +40,20 @@ tile
|
|||
Adjust the size for the pop up scale menu
|
||||
=================
|
||||
*/
|
||||
|
||||
- tile
|
||||
- (id) tile
|
||||
{
|
||||
NSRect scrollerframe;
|
||||
NSRect buttonframe, buttonframe2;
|
||||
NSRect newframe;
|
||||
|
||||
NSRect scrollerframe;
|
||||
NSRect buttonframe, buttonframe2;
|
||||
NSRect newframe;
|
||||
|
||||
[super tile];
|
||||
buttonframe = [button1 frame];
|
||||
buttonframe2 = [button2 frame];
|
||||
scrollerframe = [_horizScroller frame];
|
||||
|
||||
newframe.origin.y = scrollerframe.origin.y;
|
||||
newframe.origin.x = scrollerframe.size.width - buttonframe.size.width;
|
||||
newframe.origin.x = scrollerframe.origin.x + scrollerframe.size.width -
|
||||
buttonframe.size.width;
|
||||
newframe.size.width = buttonframe.size.width;
|
||||
newframe.size.height = scrollerframe.size.height;
|
||||
scrollerframe.size.width -= newframe.size.width;
|
||||
|
@ -66,22 +69,19 @@ Adjust the size for the pop up scale menu
|
|||
}
|
||||
|
||||
/*
|
||||
- superviewSizeChanged:(const NSSize *)oldSize
|
||||
- (id) superviewSizeChanged: (const NSSize *)oldSize
|
||||
{
|
||||
[super superviewSizeChanged: oldSize];
|
||||
|
||||
[[self docView] newSuperBounds];
|
||||
|
||||
return self;
|
||||
[super superviewSizeChanged: oldSize];
|
||||
|
||||
[[self docView] newSuperBounds];
|
||||
|
||||
return self;
|
||||
}
|
||||
*/
|
||||
|
||||
-(BOOL) acceptsFirstResponder
|
||||
- (BOOL) acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -1,78 +1,84 @@
|
|||
#ifndef Preferences_h
|
||||
#define Preferences_h
|
||||
|
||||
extern id preferences_i;
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
extern float lightaxis[3];
|
||||
extern id preferences_i;
|
||||
|
||||
extern float lightaxis[3];
|
||||
|
||||
// these are personal preferences saved in NeXT defaults, not project
|
||||
// parameters saved in the quake.qe_project file
|
||||
|
||||
@interface Preferences:Object
|
||||
@interface Preferences: NSObject
|
||||
{
|
||||
id bspSound_i; // actual sound object
|
||||
id bspSound_i; // actual sound object
|
||||
|
||||
// internal state
|
||||
char projectpath[1024];
|
||||
char bspSound[1024];
|
||||
|
||||
BOOL brushOffset;
|
||||
BOOL showBSP;
|
||||
NSString *projectpath;
|
||||
NSString *bspSound;
|
||||
|
||||
BOOL brushOffset;
|
||||
BOOL showBSP;
|
||||
|
||||
float xlight;
|
||||
float ylight;
|
||||
float zlight; // 0.0 - 1.0
|
||||
|
||||
int startwad; // 0 - 2
|
||||
|
||||
float xlight;
|
||||
float ylight;
|
||||
float zlight; // 0.0 - 1.0
|
||||
|
||||
int startwad; // 0 - 2
|
||||
|
||||
// UI targets
|
||||
id startproject_i; // TextField
|
||||
id startproject_i; // TextField
|
||||
|
||||
id bspSoundField_i; // TextField of bspSound
|
||||
id bspSoundField_i; // TextField of bspSound
|
||||
|
||||
id brushOffset_i; // Brush Offset checkbox
|
||||
id showBSP_i; // Show BSP Output checkbox
|
||||
|
||||
id startwad_i; // which wad to load at startup
|
||||
id brushOffset_i; // Brush Offset checkbox
|
||||
id showBSP_i; // Show BSP Output checkbox
|
||||
|
||||
id xlight_i; // X-side lighting
|
||||
id ylight_i; // Y-side lighting
|
||||
id zlight_i; // Z-side lighting
|
||||
id startwad_i; // which wad to load at startup
|
||||
|
||||
id xlight_i; // X-side lighting
|
||||
id ylight_i; // Y-side lighting
|
||||
id zlight_i; // Z-side lighting
|
||||
|
||||
NSUserDefaults *prefs;
|
||||
}
|
||||
|
||||
- readDefaults;
|
||||
- (id) readDefaults;
|
||||
|
||||
//
|
||||
// validate and set methods called by UI or defaults
|
||||
//
|
||||
- setProjectPath:(char *)path;
|
||||
- setBspSoundPath:(char *)path; // set the path of the soundfile externally
|
||||
- setShowBSP:(int)state; // set the state of ShowBSP
|
||||
- setBrushOffset:(int)state; // set the state of BrushOffset
|
||||
- setStartWad:(int)value; // set start wad (0-2)
|
||||
- setXlight:(float)value; // set Xlight value for CameraView
|
||||
- setYlight:(float)value; // set Ylight value for CameraView
|
||||
- setZlight:(float)value; // set Zlight value for CameraView
|
||||
- (id) setProjectPath: (NSString *)path;
|
||||
- (id) setBspSoundPath: (NSString *)path; // set the path of the soundfile
|
||||
- (id) setShowBSP: (int)state; // set the state of ShowBSP
|
||||
- (id) setBrushOffset: (int)state; // set the state of BrushOffset
|
||||
- (id) setStartWad: (int)value; // set start wad (0-2)
|
||||
- (id) setXlight: (float)value; // set Xlight value for CameraView
|
||||
- (id) setYlight: (float)value; // set Ylight value for CameraView
|
||||
- (id) setZlight: (float)value; // set Zlight value for CameraView
|
||||
|
||||
//
|
||||
// UI targets
|
||||
//
|
||||
- setBspSound:sender; // use OpenPanel to select sound
|
||||
- setCurrentProject:sender; // make current roject the default
|
||||
- UIChanged: sender; // target for all checks and fields
|
||||
- (id) setBspSound: sender; // use OpenPanel to select sound
|
||||
- (id) setCurrentProject: sender; // make current project the default
|
||||
- (id) UIChanged: sender; // target for all checks and fields
|
||||
|
||||
//
|
||||
// methods used by other objects to retreive defaults
|
||||
//
|
||||
- playBspSound;
|
||||
- (id) playBspSound;
|
||||
|
||||
- (char *)getProjectPath;
|
||||
- (int)getBrushOffset; // get the state
|
||||
- (int)getShowBSP; // get the state
|
||||
- (NSString *) getProjectPath;
|
||||
- (int) getBrushOffset; // get the state
|
||||
- (int) getShowBSP; // get the state
|
||||
|
||||
- (float)getXlight; // get Xlight value
|
||||
- (float)getYlight; // get Ylight value
|
||||
- (float)getZlight; // get Zlight value
|
||||
|
||||
- (int)getStartWad;
|
||||
- (float) getXlight; // get Xlight value
|
||||
- (float) getYlight; // get Ylight value
|
||||
- (float) getZlight; // get Zlight value
|
||||
|
||||
- (int) getStartWad;
|
||||
|
||||
@end
|
||||
#endif // Preferences_h
|
||||
|
|
|
@ -1,305 +1,272 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
id preferences_i;
|
||||
#include "Preferences.h"
|
||||
#include "Map.h"
|
||||
#include "QuakeEd.h"
|
||||
#include "Project.h"
|
||||
|
||||
#define DEFOWNER "QuakeEd2"
|
||||
id preferences_i;
|
||||
|
||||
float lightaxis[3] = {1, 0.6, 0.75};
|
||||
#define DEFOWNER "QuakeEd2"
|
||||
|
||||
float lightaxis[3] = {1, 0.6, 0.75};
|
||||
|
||||
@implementation Preferences
|
||||
|
||||
- init
|
||||
void
|
||||
WriteStringDefault (id prefs, NSString *name, NSString *value)
|
||||
{
|
||||
[prefs setObject: value forKey: name];
|
||||
}
|
||||
|
||||
void
|
||||
WriteNumericDefault (id prefs, NSString *name, float value)
|
||||
{
|
||||
WriteStringDefault (prefs, name, [NSString stringWithFormat: @"%f", value]);
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
preferences_i = self;
|
||||
|
||||
NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
|
||||
|
||||
WriteStringDefault (defaults, @"ProjectPath", @"");
|
||||
WriteStringDefault (defaults, @"BspSoundPath", @"");
|
||||
WriteNumericDefault (defaults, @"ShowBSPOutput", NO);
|
||||
WriteNumericDefault (defaults, @"OffsetBrushCopy", NO);
|
||||
WriteNumericDefault (defaults, @"StartWad", 0);
|
||||
WriteNumericDefault (defaults, @"Xlight", 0);
|
||||
WriteNumericDefault (defaults, @"Ylight", 0);
|
||||
WriteNumericDefault (defaults, @"Zlight", 0);
|
||||
|
||||
prefs = [[NSUserDefaults standardUserDefaults] retain];
|
||||
[prefs registerDefaults: defaults];
|
||||
return self;
|
||||
}
|
||||
|
||||
int _atoi (char *c)
|
||||
// Read in at start of program
|
||||
- (id) readDefaults
|
||||
{
|
||||
if (!c)
|
||||
return 0;
|
||||
return atoi(c);
|
||||
}
|
||||
[self setProjectPath: [prefs stringForKey: @"ProjectPath"]];
|
||||
[self setBspSoundPath: [prefs stringForKey: @"BspSoundPath"]];
|
||||
|
||||
int _atof (char *c)
|
||||
{
|
||||
if (!c)
|
||||
return 0;
|
||||
return atof(c);
|
||||
}
|
||||
[self setShowBSP: [[prefs stringForKey: @"ShowBSPOutput"] intValue]];
|
||||
[self setBrushOffset: [[prefs stringForKey: @"OffsetBrushCopy"] intValue]];
|
||||
[self setStartWad: [[prefs stringForKey: @"StartWad"] intValue]];
|
||||
|
||||
void WriteNumericDefault (char *name, float value)
|
||||
{
|
||||
char str[128];
|
||||
|
||||
sprintf (str,"%f", value);
|
||||
NSWriteDefault (DEFOWNER, name, str);
|
||||
}
|
||||
void WriteStringDefault (char *name, char *value)
|
||||
{
|
||||
NSWriteDefault (DEFOWNER, name, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Read in at start of program
|
||||
//
|
||||
- readDefaults
|
||||
{
|
||||
char *string;
|
||||
float value;
|
||||
|
||||
string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
|
||||
[self setProjectPath: string];
|
||||
|
||||
string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
|
||||
[self setBspSoundPath:string];
|
||||
|
||||
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
|
||||
[self setShowBSP:value];
|
||||
|
||||
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
|
||||
[self setBrushOffset:value];
|
||||
|
||||
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
|
||||
[self setStartWad:value];
|
||||
|
||||
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
|
||||
[self setXlight:value];
|
||||
|
||||
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
|
||||
[self setYlight:value];
|
||||
|
||||
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
|
||||
[self setZlight:value];
|
||||
[self setXlight: [[prefs stringForKey: @"Xlight"] floatValue]];
|
||||
[self setYlight: [[prefs stringForKey: @"Ylight"] floatValue]];
|
||||
[self setZlight: [[prefs stringForKey: @"Zlight"] floatValue]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- setProjectPath:(char *)path
|
||||
- (id) setProjectPath: (NSString *)path
|
||||
{
|
||||
if (!path)
|
||||
path = "";
|
||||
strcpy (projectpath, path);
|
||||
[startproject_i setStringValue: path];
|
||||
WriteStringDefault ("ProjectPath", path);
|
||||
[path retain];
|
||||
[projectpath release];
|
||||
projectpath = path;
|
||||
[startproject_i setStringValue: projectpath];
|
||||
WriteStringDefault (prefs, @"ProjectPath", projectpath);
|
||||
return self;
|
||||
}
|
||||
|
||||
- setCurrentProject:sender
|
||||
- (id) setCurrentProject: sender
|
||||
{
|
||||
[startproject_i setStringValue: [project_i currentProjectFile]];
|
||||
[self UIChanged: self];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (char *)getProjectPath
|
||||
- (NSString *) getProjectPath
|
||||
{
|
||||
return projectpath;
|
||||
}
|
||||
|
||||
|
||||
// ===============================================
|
||||
// BSP sound stuff
|
||||
// ===============================================
|
||||
//
|
||||
//===============================================
|
||||
// BSP sound stuff
|
||||
//===============================================
|
||||
//
|
||||
// Set the BSP sound using an OpenPanel
|
||||
//
|
||||
- setBspSound:sender
|
||||
// Set the BSP sound using an OpenPanel
|
||||
- (id) setBspSound: sender
|
||||
{
|
||||
id panel;
|
||||
char *types[]={"snd",NULL};
|
||||
int rtn;
|
||||
char **filename;
|
||||
char path[1024], file[64];
|
||||
|
||||
panel = [OpenPanel new];
|
||||
id panel;
|
||||
NSString *types[] = {@"snd"};
|
||||
int rtn;
|
||||
NSArray *filenames;
|
||||
NSString *path, *file;
|
||||
|
||||
ExtractFilePath (bspSound, path);
|
||||
ExtractFileBase (bspSound, file);
|
||||
|
||||
rtn = [panel
|
||||
runModalForDirectory:path
|
||||
file: file
|
||||
types: types];
|
||||
panel = [NSOpenPanel new];
|
||||
|
||||
if (rtn)
|
||||
{
|
||||
filename = (char **)[panel filenames];
|
||||
strcpy(bspSound,[panel directory]);
|
||||
strcat(bspSound,"/");
|
||||
strcat(bspSound,filename[0]);
|
||||
[self setBspSoundPath:bspSound];
|
||||
path = [bspSound stringByDeletingLastPathComponent];
|
||||
file = [bspSound lastPathComponent];
|
||||
|
||||
rtn = [panel runModalForDirectory: path file: file
|
||||
types: [NSArray arrayWithObjects: types
|
||||
count: 1]
|
||||
];
|
||||
|
||||
if (rtn) {
|
||||
filenames = [panel filenames];
|
||||
[self setBspSoundPath: [filenames objectAtIndex: 0]];
|
||||
[self playBspSound];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Play the BSP sound
|
||||
//
|
||||
- playBspSound
|
||||
// Play the BSP sound
|
||||
- (id) playBspSound
|
||||
{
|
||||
[bspSound_i play];
|
||||
[bspSound_i play];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Set the bspSound path
|
||||
//
|
||||
- setBspSoundPath:(char *)path
|
||||
// Set the bspSound path
|
||||
- (id) setBspSoundPath: (NSString *)path
|
||||
{
|
||||
if (!path)
|
||||
path = "";
|
||||
strcpy(bspSound,path);
|
||||
|
||||
[path retain];
|
||||
[bspSound release];
|
||||
bspSound = path;
|
||||
|
||||
if (bspSound_i)
|
||||
[bspSound_i free];
|
||||
bspSound_i = [[Sound alloc] initFromSoundfile:bspSound];
|
||||
if (!bspSound_i)
|
||||
{
|
||||
strcpy (bspSound, "/NextLibrary/Sounds/Funk.snd");
|
||||
bspSound_i = [[Sound alloc] initFromSoundfile:bspSound];
|
||||
if (bspSound_i) {
|
||||
[bspSound_i release];
|
||||
bspSound_i = nil;
|
||||
}
|
||||
if (access ([path cString], R_OK)) {
|
||||
bspSound_i = [[NSSound alloc] initWithContentsOfFile: bspSound
|
||||
byReference: YES];
|
||||
}
|
||||
if (!bspSound_i)
|
||||
return self;
|
||||
|
||||
[bspSoundField_i setStringValue: bspSound];
|
||||
|
||||
WriteStringDefault (prefs, @"BspSoundPath", bspSound);
|
||||
|
||||
[bspSoundField_i setStringValue:bspSound];
|
||||
|
||||
WriteStringDefault ("BspSoundPath", bspSound);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//===============================================
|
||||
// Show BSP Output management
|
||||
//===============================================
|
||||
// ===============================================
|
||||
// Show BSP Output management
|
||||
// ===============================================
|
||||
|
||||
//
|
||||
// Set the state
|
||||
//
|
||||
- setShowBSP:(int)state
|
||||
// Set the state
|
||||
- (id) setShowBSP: (int)state
|
||||
{
|
||||
showBSP = state;
|
||||
[showBSP_i setIntValue:state];
|
||||
WriteNumericDefault ("ShowBSPOutput", showBSP);
|
||||
[showBSP_i setIntValue: state];
|
||||
WriteNumericDefault (prefs, @"ShowBSPOutput", showBSP);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the state
|
||||
//
|
||||
- (int)getShowBSP
|
||||
// Get the state
|
||||
- (int) getShowBSP
|
||||
{
|
||||
return showBSP;
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// "Offset Brush ..." management
|
||||
// ===============================================
|
||||
|
||||
//===============================================
|
||||
// "Offset Brush ..." management
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// Set the state
|
||||
//
|
||||
- setBrushOffset:(int)state
|
||||
// Set the state
|
||||
- (id) setBrushOffset: (int)state
|
||||
{
|
||||
brushOffset = state;
|
||||
[brushOffset_i setIntValue:state];
|
||||
WriteNumericDefault ("OffsetBrushCopy", state);
|
||||
[brushOffset_i setIntValue: state];
|
||||
WriteNumericDefault (prefs, @"OffsetBrushCopy", state);
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the state
|
||||
//
|
||||
- (int)getBrushOffset
|
||||
// Get the state
|
||||
- (int) getBrushOffset
|
||||
{
|
||||
return brushOffset;
|
||||
}
|
||||
|
||||
//===============================================
|
||||
// StartWad
|
||||
//===============================================
|
||||
// ===============================================
|
||||
// StartWad
|
||||
// ===============================================
|
||||
|
||||
- setStartWad:(int)value // set start wad (0-2)
|
||||
- (id) setStartWad: (int)value // set start wad (0-2)
|
||||
{
|
||||
startwad = value;
|
||||
if (startwad<0 || startwad>2)
|
||||
if (startwad < 0 || startwad > 2)
|
||||
startwad = 0;
|
||||
|
||||
[startwad_i selectCellAt:startwad : 0];
|
||||
|
||||
WriteNumericDefault ("StartWad", value);
|
||||
[startwad_i selectCellAtRow: startwad column: 0];
|
||||
|
||||
WriteNumericDefault (prefs, @"StartWad", value);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int)getStartWad
|
||||
- (int) getStartWad
|
||||
{
|
||||
return startwad;
|
||||
}
|
||||
|
||||
|
||||
//===============================================
|
||||
// X,Y,Z light values
|
||||
//===============================================
|
||||
// ===============================================
|
||||
// X,Y,Z light values
|
||||
// ===============================================
|
||||
//
|
||||
// Set the state
|
||||
//
|
||||
- setXlight:(float)value
|
||||
// Set the state
|
||||
- (id) setXlight: (float)value
|
||||
{
|
||||
xlight = value;
|
||||
if (xlight < 0.25 || xlight > 1)
|
||||
xlight = 0.6;
|
||||
lightaxis[1] = xlight;
|
||||
[xlight_i setFloatValue:xlight];
|
||||
WriteNumericDefault ("Xlight", xlight);
|
||||
[xlight_i setFloatValue: xlight];
|
||||
WriteNumericDefault (prefs, @"Xlight", xlight);
|
||||
return self;
|
||||
}
|
||||
- setYlight:(float)value
|
||||
|
||||
- (id) setYlight: (float)value
|
||||
{
|
||||
ylight = value;
|
||||
if (ylight < 0.25 || ylight > 1)
|
||||
ylight = 0.75;
|
||||
lightaxis[2] = ylight;
|
||||
[ylight_i setFloatValue:ylight];
|
||||
WriteNumericDefault ("Ylight", ylight);
|
||||
[ylight_i setFloatValue: ylight];
|
||||
WriteNumericDefault (prefs, @"Ylight", ylight);
|
||||
return self;
|
||||
}
|
||||
- setZlight:(float)value
|
||||
|
||||
- (id) setZlight: (float)value
|
||||
{
|
||||
zlight = value;
|
||||
if (zlight < 0.25 || zlight > 1)
|
||||
zlight = 1;
|
||||
lightaxis[0] = zlight;
|
||||
[zlight_i setFloatValue:zlight];
|
||||
WriteNumericDefault ("Zlight", zlight);
|
||||
[zlight_i setFloatValue: zlight];
|
||||
WriteNumericDefault (prefs, @"Zlight", zlight);
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the state
|
||||
//
|
||||
- (float)getXlight
|
||||
// Get the state
|
||||
- (float) getXlight
|
||||
{
|
||||
return [xlight_i floatValue];
|
||||
}
|
||||
- (float)getYlight
|
||||
|
||||
- (float) getYlight
|
||||
{
|
||||
return [ylight_i floatValue];
|
||||
}
|
||||
- (float)getZlight
|
||||
|
||||
- (float) getZlight
|
||||
{
|
||||
return [zlight_i floatValue];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
UIChanged
|
||||
|
@ -307,12 +274,12 @@ UIChanged
|
|||
Grab all the current UI state
|
||||
============
|
||||
*/
|
||||
-UIChanged: sender
|
||||
- (id) UIChanged: sender
|
||||
{
|
||||
qprintf ("defaults updated");
|
||||
|
||||
[self setProjectPath: (char *)[startproject_i stringValue]];
|
||||
[self setBspSoundPath: (char *)[bspSoundField_i stringValue]];
|
||||
Sys_Printf ("defaults updated\n");
|
||||
|
||||
[self setProjectPath: [startproject_i stringValue]];
|
||||
[self setBspSoundPath: [bspSoundField_i stringValue]];
|
||||
[self setShowBSP: [showBSP_i intValue]];
|
||||
[self setBrushOffset: [brushOffset_i intValue]];
|
||||
[self setStartWad: [startwad_i selectedRow]];
|
||||
|
@ -320,11 +287,10 @@ Grab all the current UI state
|
|||
[self setYlight: [ylight_i floatValue]];
|
||||
[self setZlight: [zlight_i floatValue]];
|
||||
|
||||
[map_i makeGlobalPerform: @selector(flushTextures)];
|
||||
[map_i makeGlobalPerform: @selector (flushTextures)];
|
||||
[quakeed_i updateAll];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,108 +1,110 @@
|
|||
#ifndef Project_h
|
||||
#define Project_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define BASEPATHKEY "basepath"
|
||||
#define MAPNAMESKEY "maps"
|
||||
#define DESCKEY "desc"
|
||||
#define WADSKEY "wads"
|
||||
#define BSPFULLVIS "bspfullvis"
|
||||
#define BSPFASTVIS "bspfastvis"
|
||||
#define BSPNOVIS "bspnovis"
|
||||
#define BSPRELIGHT "bsprelight"
|
||||
#define BSPLEAKTEST "bspleaktest"
|
||||
#define BSPENTITIES "bspentities"
|
||||
#define BASEPATHKEY "basepath"
|
||||
#define MAPNAMESKEY "maps"
|
||||
#define DESCKEY "desc"
|
||||
#define WADSKEY "wads"
|
||||
#define BSPFULLVIS "bspfullvis"
|
||||
#define BSPFASTVIS "bspfastvis"
|
||||
#define BSPNOVIS "bspnovis"
|
||||
#define BSPRELIGHT "bsprelight"
|
||||
#define BSPLEAKTEST "bspleaktest"
|
||||
#define BSPENTITIES "bspentities"
|
||||
|
||||
#define SUBDIR_ENT "progs" // subdir names in heirarchy
|
||||
#define SUBDIR_MAPS "maps"
|
||||
#define SUBDIR_GFX "gfx"
|
||||
#define SUBDIR_ENT @"progs" // subdir names in heirarchy
|
||||
#define SUBDIR_MAPS @"maps"
|
||||
#define SUBDIR_GFX @"gfx"
|
||||
|
||||
extern id project_i;
|
||||
extern id project_i;
|
||||
|
||||
@interface Project:Object
|
||||
@interface Project: NSObject
|
||||
{
|
||||
id projectInfo; // dictionary storage of project info
|
||||
id projectInfo; // dictionary storage of project info
|
||||
|
||||
id basepathinfo_i; // outlet to base path info textfield
|
||||
id mapbrowse_i; // outlet to QuakeEd Maps browser
|
||||
id currentmap_i; // outlet to current map textfield
|
||||
id mapList; // list of map names (Storage)
|
||||
id descList; // list of map descriptions (Storage)
|
||||
id wadList; // list of wad names (Storage)
|
||||
|
||||
id pis_panel_i; // outlet to Project Info Settings (PIS) panel
|
||||
id basepathinfo_i; // outlet to base path info textfield
|
||||
id mapbrowse_i; // outlet to QuakeEd Maps browser
|
||||
id currentmap_i; // outlet to current map textfield
|
||||
struct plitem_s *mapList; // list of map names
|
||||
struct plitem_s *descList; // list of map descriptions
|
||||
struct plitem_s *wadList; // list of wad names
|
||||
|
||||
id pis_basepath_i; // outlet to PIS->base path
|
||||
id pis_wads_i; // outlet to PIS->wad browser
|
||||
id pis_fullvis_i; // outlet to PIS->full vis command
|
||||
id pis_fastvis_i; // outlet to PIS->fast vis command
|
||||
id pis_novis_i; // outlet to PIS->no vis command
|
||||
id pis_relight_i; // outlet to PIS->relight command
|
||||
id pis_leaktest_i; // outlet to PIS->leak test command
|
||||
id pis_panel_i; // outlet to Project Info Settings (PIS)
|
||||
// panel
|
||||
|
||||
id BSPoutput_i; // outlet to Text
|
||||
|
||||
char path_projectinfo[128]; // path of QE_Project file
|
||||
id pis_basepath_i; // outlet to PIS->base path
|
||||
id pis_wads_i; // outlet to PIS->wad browser
|
||||
id pis_fullvis_i; // outlet to PIS->full vis command
|
||||
id pis_fastvis_i; // outlet to PIS->fast vis command
|
||||
id pis_novis_i; // outlet to PIS->no vis command
|
||||
id pis_relight_i; // outlet to PIS->relight command
|
||||
id pis_leaktest_i; // outlet to PIS->leak test command
|
||||
|
||||
char path_basepath[128]; // base path of heirarchy
|
||||
id BSPoutput_i; // outlet to Text
|
||||
|
||||
char path_progdir[128]; // derived from basepath
|
||||
char path_mapdirectory[128]; // derived from basepath
|
||||
char path_finalmapdir[128]; // derived from basepath
|
||||
|
||||
char path_wad8[128]; // path of texture WAD for cmd-8 key
|
||||
char path_wad9[128]; // path of texture WAD for cmd-9 key
|
||||
char path_wad0[128]; // path of texture WAD for cmd-0 key
|
||||
NSString *path_projectinfo; // path of QE_Project file
|
||||
|
||||
char string_fullvis[1024]; // cmd-line parm
|
||||
char string_fastvis[1024]; // cmd-line parm
|
||||
char string_novis[1024]; // cmd-line parm
|
||||
char string_relight[1024]; // cmd-line parm
|
||||
char string_leaktest[1024]; // cmd-line parm
|
||||
char string_entities[1024]; // cmd-line parm
|
||||
NSString *path_basepath; // base path of heirarchy
|
||||
|
||||
int showDescriptions; // 1 = show map descs in browser
|
||||
NSString *path_progdir; // derived from basepath
|
||||
NSString *path_mapdirectory; // derived from basepath
|
||||
NSString *path_finalmapdir; // derived from basepath
|
||||
|
||||
time_t lastModified; // last time project file was modified
|
||||
char path_wad8[128]; // path of texture WAD for cmd-8 key
|
||||
char path_wad9[128]; // path of texture WAD for cmd-9 key
|
||||
char path_wad0[128]; // path of texture WAD for cmd-0 key
|
||||
|
||||
const char *string_fullvis; // cmd-line parm
|
||||
const char *string_fastvis; // cmd-line parm
|
||||
const char *string_novis; // cmd-line parm
|
||||
const char *string_relight; // cmd-line parm
|
||||
const char *string_leaktest; // cmd-line parm
|
||||
const char *string_entities; // cmd-line parm
|
||||
|
||||
int showDescriptions; // 1 = show map descs in browser
|
||||
|
||||
time_t lastModified; // last time project file was modified
|
||||
}
|
||||
|
||||
- initProject;
|
||||
- initVars;
|
||||
- (id) initProject;
|
||||
- (id) initVars;
|
||||
|
||||
- (char *)currentProjectFile;
|
||||
- (NSString *) currentProjectFile;
|
||||
|
||||
- setTextureWad: (char *)wf;
|
||||
- (id) setTextureWad: (const char *)wf;
|
||||
|
||||
- addToOutput:(char *)string;
|
||||
- clearBspOutput:sender;
|
||||
- initProjSettings;
|
||||
- changeChar:(char)f to:(char)t in:(id)obj;
|
||||
- (int)searchForString:(char *)str in:(id)obj;
|
||||
- (id) addToOutput: (const char *)string;
|
||||
- (id) clearBspOutput: (id)sender;
|
||||
- (id) initProjSettings;
|
||||
|
||||
- parseProjectFile; // read defaultsdatabase for project path
|
||||
- openProjectFile:(char *)path; // called by openProject and newProject
|
||||
- openProject;
|
||||
- clickedOnMap:sender; // called if clicked on map in browser
|
||||
- clickedOnWad:sender; // called if clicked on wad in browser
|
||||
- (id) parseProjectFile; // read defaultsdatabase for project path
|
||||
- (id) openProjectFile: (NSString *)path; // called by openProject, newProject
|
||||
- (id) openProject;
|
||||
- (id) clickedOnMap: sender; // called if clicked on map in browser
|
||||
- (id) clickedOnWad: sender; // called if clicked on wad in browser
|
||||
|
||||
// methods to querie the project file
|
||||
//
|
||||
// methods to query the project file
|
||||
//
|
||||
- (NSString *) baseDirectoryPath;
|
||||
- (NSString *) getMapDirectory;
|
||||
- (NSString *) getFinalMapDirectory;
|
||||
- (NSString *) getProgDirectory;
|
||||
|
||||
- (char *)getMapDirectory;
|
||||
- (char *)getFinalMapDirectory;
|
||||
- (char *)getProgDirectory;
|
||||
- (const char *) getWAD8;
|
||||
- (const char *) getWAD9;
|
||||
- (const char *) getWAD0;
|
||||
|
||||
- (char *)getWAD8;
|
||||
- (char *)getWAD9;
|
||||
- (char *)getWAD0;
|
||||
|
||||
- (char *)getFullVisCmd;
|
||||
- (char *)getFastVisCmd;
|
||||
- (char *)getNoVisCmd;
|
||||
- (char *)getRelightCmd;
|
||||
- (char *)getLeaktestCmd;
|
||||
- (char *)getEntitiesCmd;
|
||||
- (const char *) getFullVisCmd;
|
||||
- (const char *) getFastVisCmd;
|
||||
- (const char *) getNoVisCmd;
|
||||
- (const char *) getRelightCmd;
|
||||
- (const char *) getLeaktestCmd;
|
||||
- (const char *) getEntitiesCmd;
|
||||
|
||||
@end
|
||||
|
||||
void changeString(char cf,char ct,char *string);
|
||||
|
||||
#endif // Project_h
|
||||
|
|
|
@ -1,526 +1,431 @@
|
|||
//======================================
|
||||
// ======================================
|
||||
//
|
||||
// QuakeEd Project Management
|
||||
//
|
||||
//======================================
|
||||
// ======================================
|
||||
|
||||
#include "qedefs.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#include "QF/qfplist.h"
|
||||
#include "QF/quakefs.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
id project_i;
|
||||
#include "Project.h"
|
||||
#include "Map.h"
|
||||
#include "QuakeEd.h"
|
||||
#include "Preferences.h"
|
||||
#include "Dict.h"
|
||||
#include "Things.h"
|
||||
#include "TexturePalette.h"
|
||||
|
||||
id project_i;
|
||||
|
||||
@implementation Project
|
||||
|
||||
- init
|
||||
- (id) init
|
||||
{
|
||||
project_i = self;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// ===========================================================
|
||||
//
|
||||
// Project code
|
||||
// Project code
|
||||
//
|
||||
//===========================================================
|
||||
- initVars
|
||||
// ===========================================================
|
||||
- (id) initVars
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = [preferences_i getProjectPath];
|
||||
StripFilename(s);
|
||||
strcpy(path_basepath,s);
|
||||
|
||||
strcpy(path_progdir,s);
|
||||
strcat(path_progdir,"/"SUBDIR_ENT);
|
||||
|
||||
strcpy(path_mapdirectory,s);
|
||||
strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir
|
||||
NSString *ts;
|
||||
|
||||
strcpy(path_finalmapdir,s);
|
||||
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
||||
|
||||
[basepathinfo_i setStringValue:s]; // in Project Inspector
|
||||
|
||||
#if 0
|
||||
if ((s = [projectInfo getStringFor:BASEPATHKEY]))
|
||||
{
|
||||
strcpy(path_basepath,s);
|
||||
|
||||
strcpy(path_progdir,s);
|
||||
strcat(path_progdir,"/"SUBDIR_ENT);
|
||||
|
||||
strcpy(path_mapdirectory,s);
|
||||
strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir
|
||||
ts = path_projectinfo;
|
||||
ts = path_basepath = [[ts stringByDeletingLastPathComponent] retain];
|
||||
|
||||
strcpy(path_finalmapdir,s);
|
||||
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
||||
|
||||
[basepathinfo_i setStringValue:s]; // in Project Inspector
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPFULLVIS]))
|
||||
{
|
||||
strcpy(string_fullvis,s);
|
||||
changeString('@','\"',string_fullvis);
|
||||
}
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPFASTVIS]))
|
||||
{
|
||||
strcpy(string_fastvis,s);
|
||||
changeString('@','\"',string_fastvis);
|
||||
}
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPNOVIS]))
|
||||
{
|
||||
strcpy(string_novis,s);
|
||||
changeString('@','\"',string_novis);
|
||||
}
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPRELIGHT]))
|
||||
{
|
||||
strcpy(string_relight,s);
|
||||
changeString('@','\"',string_relight);
|
||||
}
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPLEAKTEST]))
|
||||
{
|
||||
strcpy(string_leaktest,s);
|
||||
changeString('@','\"',string_leaktest);
|
||||
}
|
||||
path_progdir = [[ts stringByAppendingPathComponent: SUBDIR_ENT] retain];
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPENTITIES]))
|
||||
{
|
||||
strcpy(string_entities,s);
|
||||
changeString('@','\"', string_entities);
|
||||
path_mapdirectory = [[ts stringByAppendingPathComponent: SUBDIR_MAPS] retain];
|
||||
path_finalmapdir = [[ts stringByAppendingPathComponent: SUBDIR_MAPS] retain];
|
||||
|
||||
// in Project Inspector
|
||||
[basepathinfo_i setStringValue: ts];
|
||||
|
||||
#if 0 // FIXME: for "out-of-tree" projects ?
|
||||
if ((s = [projectInfo getStringFor: BASEPATHKEY])) {
|
||||
strcpy (path_basepath, s);
|
||||
|
||||
strcpy (path_progdir, s);
|
||||
strcat (path_progdir, "/" SUBDIR_ENT);
|
||||
|
||||
strcpy (path_mapdirectory, s);
|
||||
strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir
|
||||
|
||||
strcpy (path_finalmapdir, s);
|
||||
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
||||
|
||||
[basepathinfo_i setStringValue: s]; // in Project Inspector
|
||||
}
|
||||
#endif
|
||||
|
||||
// Build list of wads
|
||||
wadList = [projectInfo parseMultipleFrom:WADSKEY];
|
||||
string_fullvis = [projectInfo getStringFor: BSPFULLVIS];
|
||||
string_fastvis = [projectInfo getStringFor: BSPFASTVIS];
|
||||
string_novis = [projectInfo getStringFor: BSPNOVIS];
|
||||
string_relight = [projectInfo getStringFor: BSPRELIGHT];
|
||||
string_leaktest = [projectInfo getStringFor: BSPLEAKTEST];
|
||||
string_entities = [projectInfo getStringFor: BSPENTITIES];
|
||||
|
||||
// Build list of wads
|
||||
wadList = [projectInfo getArrayFor: WADSKEY];
|
||||
|
||||
// Build list of maps & descriptions
|
||||
mapList = [projectInfo getArrayFor: MAPNAMESKEY];
|
||||
descList = [projectInfo getArrayFor: DESCKEY];
|
||||
|
||||
// Build list of maps & descriptions
|
||||
mapList = [projectInfo parseMultipleFrom:MAPNAMESKEY];
|
||||
descList = [projectInfo parseMultipleFrom:DESCKEY];
|
||||
[self changeChar:'_' to:' ' in:descList];
|
||||
|
||||
[self initProjSettings];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Init Project Settings fields
|
||||
//
|
||||
- initProjSettings
|
||||
// Init Project Settings fields
|
||||
- (id) initProjSettings
|
||||
{
|
||||
[pis_basepath_i setStringValue:path_basepath];
|
||||
[pis_fullvis_i setStringValue:string_fullvis];
|
||||
[pis_fastvis_i setStringValue:string_fastvis];
|
||||
[pis_novis_i setStringValue:string_novis];
|
||||
[pis_relight_i setStringValue:string_relight];
|
||||
[pis_leaktest_i setStringValue:string_leaktest];
|
||||
|
||||
[pis_basepath_i setStringValue: path_basepath];
|
||||
[pis_fullvis_i setStringValue: [NSString stringWithCString: string_fullvis]];
|
||||
[pis_fastvis_i setStringValue: [NSString stringWithCString: string_fastvis]];
|
||||
[pis_novis_i setStringValue: [NSString stringWithCString: string_novis]];
|
||||
[pis_relight_i setStringValue: [NSString stringWithCString: string_relight]];
|
||||
[pis_leaktest_i setStringValue: [NSString stringWithCString: string_leaktest]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Add text to the BSP Output window
|
||||
//
|
||||
- addToOutput:(char *)string
|
||||
// Add text to the BSP Output window
|
||||
- (id) addToOutput: (const char *)string
|
||||
{
|
||||
int end;
|
||||
|
||||
int end;
|
||||
|
||||
end = [BSPoutput_i textLength];
|
||||
[BSPoutput_i setSel:end :end];
|
||||
[BSPoutput_i replaceSel:string];
|
||||
|
||||
[BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0)
|
||||
withString: [NSString stringWithCString: string]];
|
||||
|
||||
end = [BSPoutput_i textLength];
|
||||
[BSPoutput_i setSel:end :end];
|
||||
[BSPoutput_i scrollSelToVisible];
|
||||
|
||||
[BSPoutput_i setSelectedRange: NSMakeRange (end, 0)];
|
||||
// XXX [BSPoutput_i scrollSelToVisible];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- clearBspOutput:sender
|
||||
- (id) clearBspOutput: sender
|
||||
{
|
||||
[BSPoutput_i selectAll:self];
|
||||
[BSPoutput_i replaceSel:"\0"];
|
||||
|
||||
int end;
|
||||
|
||||
end = [BSPoutput_i textLength];
|
||||
[BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString: @""];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- print
|
||||
- (id) print
|
||||
{
|
||||
[BSPoutput_i printPSCode:self];
|
||||
// XXX [BSPoutput_i printPSCode:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- initProject
|
||||
- (id) initProject
|
||||
{
|
||||
[self parseProjectFile];
|
||||
if (projectInfo == NULL)
|
||||
return self;
|
||||
[self initVars];
|
||||
[mapbrowse_i reuseColumns:YES];
|
||||
[mapbrowse_i setReusesColumns: YES];
|
||||
[mapbrowse_i loadColumnZero];
|
||||
[pis_wads_i reuseColumns:YES];
|
||||
[pis_wads_i setReusesColumns: YES];
|
||||
[pis_wads_i loadColumnZero];
|
||||
|
||||
[things_i initEntities];
|
||||
|
||||
[things_i initEntities];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Change a character to another in a Storage list of strings
|
||||
//
|
||||
- changeChar:(char)f to:(char)t in:(id)obj
|
||||
// Fill the QuakeEd Maps or wads browser
|
||||
// (Delegate method - delegated in Interface Builder)
|
||||
- (void) browser: sender createRowsForColumn: (int)column inMatrix: matrix
|
||||
{
|
||||
int i;
|
||||
int max;
|
||||
char *string;
|
||||
id cell;
|
||||
plitem_t *list;
|
||||
int max;
|
||||
const char *name;
|
||||
int i;
|
||||
|
||||
max = [obj count];
|
||||
for (i = 0;i < max;i++)
|
||||
{
|
||||
string = [obj elementAt:i];
|
||||
changeString(f,t,string);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill the QuakeEd Maps or wads browser
|
||||
// (Delegate method - delegated in Interface Builder)
|
||||
//
|
||||
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
|
||||
{
|
||||
id cell, list;
|
||||
int max;
|
||||
char *name;
|
||||
int i;
|
||||
|
||||
if (sender == mapbrowse_i)
|
||||
if (sender == mapbrowse_i) {
|
||||
list = mapList;
|
||||
else if (sender == pis_wads_i)
|
||||
} else if (sender == pis_wads_i) {
|
||||
list = wadList;
|
||||
else
|
||||
{
|
||||
list = nil;
|
||||
Error ("Project: unknown browser to fill");
|
||||
} else {
|
||||
list = 0;
|
||||
Sys_Error ("Project: unknown browser to fill");
|
||||
}
|
||||
|
||||
max = [list count];
|
||||
for (i = 0 ; i<max ; i++)
|
||||
{
|
||||
name = [list elementAt:i];
|
||||
|
||||
max = list ? PL_A_NumObjects (list) : 0;
|
||||
for (i = 0; i < max; i++) {
|
||||
name = PL_String (PL_ObjectAtIndex (list, i));
|
||||
[matrix addRow];
|
||||
cell = [matrix cellAt:i :0];
|
||||
[cell setStringValue:name];
|
||||
[cell setLeaf:YES];
|
||||
[cell setLoaded:YES];
|
||||
cell = [matrix cellAtRow: i column: 0];
|
||||
[cell setStringValue: [NSString stringWithCString: name]];
|
||||
[cell setLeaf: YES];
|
||||
[cell setLoaded: YES];
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
//
|
||||
// Clicked on a map name or description!
|
||||
//
|
||||
- clickedOnMap:sender
|
||||
// Clicked on a map name or description!
|
||||
- (id) clickedOnMap: sender
|
||||
{
|
||||
id matrix;
|
||||
int row;
|
||||
char fname[1024];
|
||||
id panel;
|
||||
|
||||
matrix = [sender matrixInColumn:0];
|
||||
id matrix;
|
||||
int row;
|
||||
NSString *mapname;
|
||||
NSString *fname;
|
||||
id panel;
|
||||
NSModalSession session;
|
||||
|
||||
matrix = [sender matrixInColumn: 0];
|
||||
row = [matrix selectedRow];
|
||||
sprintf(fname,"%s/%s.map",path_mapdirectory,
|
||||
(char *)[mapList elementAt:row]);
|
||||
|
||||
panel = NSGetAlertPanel("Loading...",
|
||||
"Loading map. Please wait.",NULL,NULL,NULL);
|
||||
[panel orderFront:NULL];
|
||||
mapname = [NSString stringWithCString:
|
||||
PL_String (PL_ObjectAtIndex (mapList, row))];
|
||||
fname = [[path_mapdirectory stringByAppendingPathComponent: mapname]
|
||||
stringByAppendingPathExtension: @"map"];
|
||||
|
||||
[quakeed_i doOpen:fname];
|
||||
panel = NSGetAlertPanel (@"Loading...",
|
||||
@"Loading map. Please wait.", NULL, NULL, NULL);
|
||||
|
||||
[panel performClose:NULL];
|
||||
NSFreeAlertPanel(panel);
|
||||
session = [NSApp beginModalSessionForWindow: panel];
|
||||
[NSApp runModalSession: session];
|
||||
|
||||
[quakeed_i doOpen: fname];
|
||||
|
||||
[NSApp endModalSession: session];
|
||||
[panel close];
|
||||
NSReleaseAlertPanel (panel);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- setTextureWad: (char *)wf
|
||||
- (id) setTextureWad: (const char *)wf
|
||||
{
|
||||
int i, c;
|
||||
char *name;
|
||||
|
||||
qprintf ("loading %s", wf);
|
||||
int i, c;
|
||||
const char *name;
|
||||
|
||||
// set the row in the settings inspector wad browser
|
||||
c = [wadList count];
|
||||
for (i=0 ; i<c ; i++)
|
||||
{
|
||||
name = (char *)[wadList elementAt:i];
|
||||
if (!strcmp(name, wf))
|
||||
{
|
||||
[[pis_wads_i matrixInColumn:0] selectCellAt: i : 0];
|
||||
Sys_Printf ("loading %s\n", wf);
|
||||
|
||||
// set the row in the settings inspector wad browser
|
||||
c = PL_A_NumObjects (wadList);
|
||||
for (i = 0; i < c; i++) {
|
||||
name = PL_String (PL_ObjectAtIndex (wadList, i));
|
||||
if (!strcmp (name, wf)) {
|
||||
[[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column: 0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// update the texture inspector
|
||||
[texturepalette_i initPaletteFromWadfile:wf ];
|
||||
[[map_i objectAt: 0] setKey:"wad" toValue: wf];
|
||||
// [inspcontrol_i changeInspectorTo:i_textures];
|
||||
// update the texture inspector
|
||||
[texturepalette_i initPaletteFromWadfile: wf];
|
||||
[[map_i objectAtIndex: 0] setKey: "wad" toValue: wf];
|
||||
// [inspcontrol_i changeInspectorTo:i_textures];
|
||||
|
||||
[quakeed_i updateAll];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Clicked on a wad name
|
||||
//
|
||||
- clickedOnWad:sender
|
||||
// Clicked on a wad name
|
||||
- (id) clickedOnWad: sender
|
||||
{
|
||||
id matrix;
|
||||
int row;
|
||||
char *name;
|
||||
|
||||
matrix = [sender matrixInColumn:0];
|
||||
id matrix;
|
||||
int row;
|
||||
const char *name;
|
||||
|
||||
matrix = [sender matrixInColumn: 0];
|
||||
row = [matrix selectedRow];
|
||||
|
||||
name = (char *)[wadList elementAt:row];
|
||||
name = PL_String (PL_ObjectAtIndex (wadList, row));
|
||||
[self setTextureWad: name];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Read in the <name>.QE_Project file
|
||||
//
|
||||
- parseProjectFile
|
||||
// Read in the <name>.QE_Project file
|
||||
- (id) parseProjectFile
|
||||
{
|
||||
char *path;
|
||||
int rtn;
|
||||
|
||||
NSString *path;
|
||||
int rtn;
|
||||
|
||||
path = [preferences_i getProjectPath];
|
||||
if (!path || !path[0] || access(path,0))
|
||||
{
|
||||
rtn = NSRunAlertPanel("Project Error!",
|
||||
"A default project has not been found.\n"
|
||||
, "Open Project", NULL, NULL);
|
||||
if ([self openProject] == nil)
|
||||
while (1) // can't run without a project
|
||||
[NSApp terminate: self];
|
||||
return self;
|
||||
if (![path length] || access ([path cString], 0)) {
|
||||
rtn = NSRunAlertPanel (@"Project Error!",
|
||||
@"A default project has not been found.\n",
|
||||
@"Open Project", NULL, NULL);
|
||||
if ([self openProject] == nil) {
|
||||
while (1)
|
||||
[NSApp terminate: self]; // can't run without a project
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
[self openProjectFile:path];
|
||||
[self openProjectFile: path];
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Loads and parses a project file
|
||||
//
|
||||
- openProjectFile:(char *)path
|
||||
{
|
||||
FILE *fp;
|
||||
struct stat s;
|
||||
// Loads and parses a project file
|
||||
- (id) openProjectFile: (NSString *)path
|
||||
{
|
||||
FILE *fp;
|
||||
struct stat s;
|
||||
|
||||
strcpy(path_projectinfo,path);
|
||||
Sys_Printf ("openProjectFile: %s\n", [path cString]);
|
||||
[path retain];
|
||||
[path_projectinfo release];
|
||||
path_projectinfo = path;
|
||||
|
||||
projectInfo = NULL;
|
||||
fp = fopen(path,"r+t");
|
||||
fp = fopen ([path cString], "r+t");
|
||||
if (fp == NULL)
|
||||
return self;
|
||||
|
||||
stat(path,&s);
|
||||
stat ([path cString], &s);
|
||||
lastModified = s.st_mtime;
|
||||
|
||||
projectInfo = [(Dict *)[Dict alloc] initFromFile:fp];
|
||||
fclose(fp);
|
||||
|
||||
projectInfo = [(Dict *)[Dict alloc] initFromFile: fp];
|
||||
fclose (fp);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (char *)currentProjectFile
|
||||
- (NSString *) currentProjectFile
|
||||
{
|
||||
return path_projectinfo;
|
||||
}
|
||||
|
||||
//
|
||||
// Open a project file
|
||||
//
|
||||
- openProject
|
||||
// Open a project file
|
||||
- (id) openProject
|
||||
{
|
||||
char path[128];
|
||||
id openpanel;
|
||||
int rtn;
|
||||
char *projtypes[2] = {"qpr",NULL};
|
||||
char **filenames;
|
||||
char *dir;
|
||||
|
||||
openpanel = [OpenPanel new];
|
||||
[openpanel allowMultipleFiles:NO];
|
||||
[openpanel chooseDirectories:NO];
|
||||
rtn = [openpanel runModalForTypes:projtypes];
|
||||
if (rtn == NS_OKTAG)
|
||||
{
|
||||
(const char *const *)filenames = [openpanel filenames];
|
||||
dir = (char *)[openpanel directory];
|
||||
sprintf(path,"%s/%s",dir,filenames[0]);
|
||||
strcpy(path_projectinfo,path);
|
||||
[self openProjectFile:path];
|
||||
return self;
|
||||
id openpanel;
|
||||
int rtn;
|
||||
NSString *projtypes[] = {@"qpr"};
|
||||
NSArray *projtypes_array;
|
||||
NSArray *filenames;
|
||||
NSString *path;
|
||||
|
||||
openpanel = [NSOpenPanel new];
|
||||
[openpanel setAllowsMultipleSelection:NO];
|
||||
[openpanel setCanChooseDirectories:NO];
|
||||
projtypes_array = [NSArray arrayWithObjects: projtypes count: 1];
|
||||
rtn = [openpanel runModalForTypes: projtypes_array];
|
||||
if (rtn == NSOKButton) {
|
||||
filenames = [openpanel filenames];
|
||||
path = [filenames objectAtIndex: 0];
|
||||
[self openProjectFile: path];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Search for a string in a List of strings
|
||||
//
|
||||
- (int)searchForString:(char *)str in:(id)obj
|
||||
- (NSString *) baseDirectoryPath
|
||||
{
|
||||
int i;
|
||||
int max;
|
||||
char *s;
|
||||
|
||||
max = [obj count];
|
||||
for (i = 0;i < max; i++)
|
||||
{
|
||||
s = (char *)[obj elementAt:i];
|
||||
if (!strcmp(s,str))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return path_basepath;
|
||||
}
|
||||
|
||||
- (char *)getMapDirectory
|
||||
- (NSString *) getMapDirectory
|
||||
{
|
||||
return path_mapdirectory;
|
||||
}
|
||||
|
||||
- (char *)getFinalMapDirectory
|
||||
- (NSString *) getFinalMapDirectory
|
||||
{
|
||||
return path_finalmapdir;
|
||||
}
|
||||
|
||||
- (char *)getProgDirectory
|
||||
- (NSString *) getProgDirectory
|
||||
{
|
||||
return path_progdir;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return the WAD name for cmd-8
|
||||
//
|
||||
- (char *)getWAD8
|
||||
// Return the WAD name for cmd-8
|
||||
- (const char *) getWAD8
|
||||
{
|
||||
if (!path_wad8[0])
|
||||
return NULL;
|
||||
|
||||
return path_wad8;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the WAD name for cmd-9
|
||||
//
|
||||
- (char *)getWAD9
|
||||
// Return the WAD name for cmd-9
|
||||
- (const char *) getWAD9
|
||||
{
|
||||
if (!path_wad9[0])
|
||||
return NULL;
|
||||
|
||||
return path_wad9;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the WAD name for cmd-0
|
||||
//
|
||||
- (char *)getWAD0
|
||||
// Return the WAD name for cmd-0
|
||||
- (const char *) getWAD0
|
||||
{
|
||||
if (!path_wad0[0])
|
||||
return NULL;
|
||||
|
||||
return path_wad0;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the FULLVIS cmd string
|
||||
//
|
||||
- (char *)getFullVisCmd
|
||||
// Return the FULLVIS cmd string
|
||||
- (const char *) getFullVisCmd
|
||||
{
|
||||
if (!string_fullvis[0])
|
||||
return NULL;
|
||||
|
||||
return string_fullvis;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the FASTVIS cmd string
|
||||
//
|
||||
- (char *)getFastVisCmd
|
||||
// Return the FASTVIS cmd string
|
||||
- (const char *) getFastVisCmd
|
||||
{
|
||||
if (!string_fastvis[0])
|
||||
return NULL;
|
||||
|
||||
return string_fastvis;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the NOVIS cmd string
|
||||
//
|
||||
- (char *)getNoVisCmd
|
||||
// Return the NOVIS cmd string
|
||||
- (const char *) getNoVisCmd
|
||||
{
|
||||
if (!string_novis[0])
|
||||
return NULL;
|
||||
|
||||
return string_novis;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the RELIGHT cmd string
|
||||
//
|
||||
- (char *)getRelightCmd
|
||||
// Return the RELIGHT cmd string
|
||||
- (const char *) getRelightCmd
|
||||
{
|
||||
if (!string_relight[0])
|
||||
return NULL;
|
||||
|
||||
return string_relight;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the LEAKTEST cmd string
|
||||
//
|
||||
- (char *)getLeaktestCmd
|
||||
// Return the LEAKTEST cmd string
|
||||
- (const char *) getLeaktestCmd
|
||||
{
|
||||
if (!string_leaktest[0])
|
||||
return NULL;
|
||||
|
||||
return string_leaktest;
|
||||
}
|
||||
|
||||
- (char *)getEntitiesCmd
|
||||
- (const char *) getEntitiesCmd
|
||||
{
|
||||
if (!string_entities[0])
|
||||
return NULL;
|
||||
|
||||
return string_entities;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//====================================================
|
||||
// C Functions
|
||||
//====================================================
|
||||
|
||||
//
|
||||
// Change a character to a different char in a string
|
||||
//
|
||||
void changeString(char cf,char ct,char *string)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0;j < strlen(string);j++)
|
||||
if (string[j] == cf)
|
||||
string[j] = ct;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,98 +1,110 @@
|
|||
#ifndef QuakeEd_h
|
||||
#define QuakeEd_h
|
||||
|
||||
extern id quakeed_i;
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
extern BOOL filter_light, filter_path, filter_entities;
|
||||
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
|
||||
extern id quakeed_i;
|
||||
|
||||
extern UserPath *upath;
|
||||
extern BOOL filter_light, filter_path, filter_entities;
|
||||
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
|
||||
|
||||
extern id g_cmd_out_i;
|
||||
extern id g_cmd_out_i;
|
||||
|
||||
double I_FloatTime (void);
|
||||
double I_FloatTime (void);
|
||||
|
||||
void NopSound (void);
|
||||
void NopSound (void);
|
||||
|
||||
void qprintf (char *fmt, ...); // prints text to cmd_out_i
|
||||
|
||||
@interface QuakeEd : NSWindow
|
||||
@interface QuakeEd: NSWindow
|
||||
{
|
||||
BOOL dirty;
|
||||
char filename[1024]; // full path with .map extension
|
||||
BOOL dirty;
|
||||
NSString *filename; // full path with .map extension
|
||||
|
||||
NSBitmapImageRep *cache[3];
|
||||
NSRect cache_rect[3];
|
||||
BOOL no_restore[3];
|
||||
|
||||
//
|
||||
// UI objects
|
||||
id brushcount_i;
|
||||
id entitycount_i;
|
||||
id regionbutton_i;
|
||||
//
|
||||
id brushcount_i;
|
||||
id entitycount_i;
|
||||
id regionbutton_i;
|
||||
|
||||
id show_coordinates_i;
|
||||
id show_names_i;
|
||||
id show_coordinates_i;
|
||||
id show_names_i;
|
||||
|
||||
id filter_light_i;
|
||||
id filter_path_i;
|
||||
id filter_entities_i;
|
||||
id filter_clip_i;
|
||||
id filter_water_i;
|
||||
id filter_world_i;
|
||||
|
||||
id cmd_in_i; // text fields
|
||||
id cmd_out_i;
|
||||
|
||||
id xy_drawmode_i; // passed over to xyview after init
|
||||
id filter_light_i;
|
||||
id filter_path_i;
|
||||
id filter_entities_i;
|
||||
id filter_clip_i;
|
||||
id filter_water_i;
|
||||
id filter_world_i;
|
||||
|
||||
id cmd_in_i; // text fields
|
||||
id cmd_out_i;
|
||||
|
||||
id xy_drawmode_i; // passed over to xyview after init
|
||||
}
|
||||
|
||||
- setDefaultFilename;
|
||||
- (char *)currentFilename;
|
||||
- (id) setDefaultFilename;
|
||||
- (NSString *) currentFilename;
|
||||
|
||||
- updateAll; // when a model has been changed
|
||||
- updateCamera; // when the camera has moved
|
||||
- updateXY;
|
||||
- updateZ;
|
||||
- (id) updateAll; // when a model has been changed
|
||||
- (id) updateCamera; // when the camera has moved
|
||||
- (id) updateXY;
|
||||
- (id) updateZ;
|
||||
|
||||
- updateAll:sender;
|
||||
- (id) updateAll: sender;
|
||||
|
||||
- newinstance; // force next flushwindow to clear all instance drawing
|
||||
- redrawInstance; // erase and redraw all instance now
|
||||
- (void) cameraNoRestore: (NSRect)rect;
|
||||
- (void) xyNoRestore: (NSRect)rect;
|
||||
- (void) zNoRestore: (NSRect)rect;
|
||||
|
||||
- appDidInit:sender;
|
||||
- appWillTerminate:sender;
|
||||
- (id) newinstance; // force next flushwindow to clear all
|
||||
// instance drawing
|
||||
- (id) redrawInstance; // erase and redraw all instance now
|
||||
|
||||
- openProject:sender;
|
||||
- (id) appWillTerminate: sender;
|
||||
|
||||
- textCommand: sender;
|
||||
- (id) openProject: sender;
|
||||
|
||||
- applyRegion: sender;
|
||||
- (id) textCommand: sender;
|
||||
|
||||
- (BOOL)dirty;
|
||||
- (id) applyRegion: sender;
|
||||
|
||||
- clear: sender;
|
||||
- centerCamera: sender;
|
||||
- centerZChecker: sender;
|
||||
- (BOOL) dirty;
|
||||
|
||||
- changeXYLookUp: sender;
|
||||
- (id) clear: sender;
|
||||
- (id) centerCamera: sender;
|
||||
- (id) centerZChecker: sender;
|
||||
|
||||
- setBrushRegion: sender;
|
||||
- setXYRegion: sender;
|
||||
- (id) changeXYLookUp: sender;
|
||||
|
||||
- open: sender;
|
||||
- save: sender;
|
||||
- saveAs: sender;
|
||||
- (id) setBrushRegion: sender;
|
||||
- (id) setXYRegion: sender;
|
||||
|
||||
- doOpen: (char *)fname;
|
||||
- (id) open: sender;
|
||||
- (id) save: sender;
|
||||
- (id) saveAs: sender;
|
||||
|
||||
- saveBSP:(char *)cmdline dialog:(BOOL)wt;
|
||||
- (id) doOpen: (NSString *)fname;
|
||||
|
||||
- BSP_Full: sender;
|
||||
- BSP_FastVis: sender;
|
||||
- BSP_NoVis: sender;
|
||||
- BSP_relight: sender;
|
||||
- BSP_stop: sender;
|
||||
- BSP_entities: sender;
|
||||
- (id) saveBSP: (const char *)cmdline dialog: (BOOL)wt;
|
||||
|
||||
- (id) BSP_Full: sender;
|
||||
- (id) BSP_FastVis: sender;
|
||||
- (id) BSP_NoVis: sender;
|
||||
- (id) BSP_relight: sender;
|
||||
- (id) BSP_stop: sender;
|
||||
- (id) BSP_entities: sender;
|
||||
|
||||
- (id) applicationDefined: (NSEvent *)theEvent;
|
||||
|
||||
//
|
||||
// UI querie for other objects
|
||||
// UI query for other objects
|
||||
//
|
||||
- (BOOL)showCoordinates;
|
||||
- (BOOL)showNames;
|
||||
- (BOOL) showCoordinates;
|
||||
- (BOOL) showNames;
|
||||
|
||||
@end
|
||||
|
||||
#endif // QuakeEd_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,15 +1,27 @@
|
|||
/* Generated by the NeXT Project Builder
|
||||
NOTE: Do NOT change this file -- Project Builder maintains it.
|
||||
*/
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include <appkit/appkit.h>
|
||||
#include "QF/sys.h"
|
||||
|
||||
void main(int argc, char *argv[]) {
|
||||
#include "QuakeEd.h"
|
||||
|
||||
[Application new];
|
||||
if ([NSApp loadNibSection:"QuakeEd.nib" owner:NSApp withNames:NO])
|
||||
[NSApp run];
|
||||
|
||||
[NSApp free];
|
||||
exit(0);
|
||||
@interface QuakeEdApp: NSApplication
|
||||
- (void) sendEvent: (NSEvent *)evt;
|
||||
@end
|
||||
|
||||
@implementation QuakeEdApp
|
||||
|
||||
- (void) sendEvent: (NSEvent *)evt;
|
||||
{
|
||||
if ([evt type] == NSApplicationDefined)
|
||||
[quakeed_i applicationDefined: evt];
|
||||
else
|
||||
[super sendEvent: evt];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int
|
||||
main (int argc, const char *argv[])
|
||||
{
|
||||
return NSApplicationMain (argc, argv);
|
||||
}
|
||||
|
|
|
@ -1,158 +1,172 @@
|
|||
#ifndef SetBrush_h
|
||||
#define SetBrush_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#define MAX_FACES 16
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
typedef float vec5_t[5];
|
||||
#include "TexturePalette.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int numpoints;
|
||||
vec5_t points[8]; // variable sized
|
||||
#define MAX_FACES 16
|
||||
|
||||
typedef struct {
|
||||
int numpoints;
|
||||
vec5_t points[8]; // variable sized
|
||||
} winding_t;
|
||||
|
||||
#define MAX_POINTS_ON_WINDING 64
|
||||
#define MAX_POINTS_ON_WINDING 64
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
typedef struct {
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
} plane_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
// implicit rep
|
||||
vec3_t planepts[3];
|
||||
texturedef_t texture;
|
||||
vec3_t planepts[3];
|
||||
texturedef_t texture;
|
||||
|
||||
// cached rep
|
||||
plane_t plane;
|
||||
qtexture_t *qtexture;
|
||||
float light; // 0 - 1.0
|
||||
winding_t *w;
|
||||
plane_t plane;
|
||||
qtexture_t *qtexture;
|
||||
float light; // 0 - 1.0
|
||||
winding_t *w;
|
||||
} face_t;
|
||||
|
||||
#define ON_EPSILON 0.1
|
||||
#define FP_EPSILON 0.01
|
||||
#define VECTOR_EPSILON 0.0001
|
||||
#define ON_EPSILON 0.1
|
||||
#define FP_EPSILON 0.01
|
||||
#define VECTOR_EPSILON 0.0001
|
||||
|
||||
#define SIDE_FRONT 0
|
||||
#define SIDE_BACK 1
|
||||
#define SIDE_ON 2
|
||||
#define SIDE_FRONT 0
|
||||
#define SIDE_BACK 1
|
||||
#define SIDE_ON 2
|
||||
|
||||
winding_t *ClipWinding (winding_t * in, plane_t *split);
|
||||
winding_t *CopyWinding (winding_t * w);
|
||||
winding_t *NewWinding (int points);
|
||||
|
||||
winding_t *ClipWinding (winding_t *in, plane_t *split);
|
||||
winding_t *CopyWinding (winding_t *w);
|
||||
winding_t *NewWinding (int points);
|
||||
|
||||
|
||||
@interface SetBrush : Object
|
||||
@interface SetBrush: NSObject
|
||||
{
|
||||
BOOL regioned; // not active
|
||||
BOOL selected;
|
||||
BOOL regioned; // not active
|
||||
BOOL selected;
|
||||
BOOL invalid; // not a proper polyhedron
|
||||
|
||||
BOOL invalid; // not a proper polyhedron
|
||||
|
||||
id parent; // the entity this brush is in
|
||||
vec3_t bmins, bmaxs;
|
||||
vec3_t entitycolor;
|
||||
int numfaces;
|
||||
face_t faces[MAX_FACES];
|
||||
id parent; // the entity this brush is in
|
||||
vec3_t bmins, bmaxs;
|
||||
vec3_t entitycolor;
|
||||
int numfaces;
|
||||
face_t faces[MAX_FACES];
|
||||
}
|
||||
|
||||
- initOwner: own mins:(float *)mins maxs:(float *)maxs texture:(texturedef_t *)tex;
|
||||
- initFromTokens: own;
|
||||
- setMins:(float *)mins maxs:(float *)maxs;
|
||||
- (SetBrush *) initOwner: (id)own
|
||||
mins: (float *)mins
|
||||
maxs: (float *)maxs
|
||||
texture: (texturedef_t *)tex;
|
||||
|
||||
- parent;
|
||||
- setParent: (id)p;
|
||||
- (id) initFromScript: (struct script_s *)script
|
||||
owner: (id)own;
|
||||
|
||||
- setEntityColor: (vec3_t)color;
|
||||
- (id) setMins: (float *)mins maxs: (float *)maxs;
|
||||
|
||||
- calcWindings;
|
||||
- (id) parent;
|
||||
- (id) setParent: (id)p;
|
||||
|
||||
- writeToFILE: (FILE *)f region: (BOOL)reg;
|
||||
- (id) setEntityColor: (vec3_t)color;
|
||||
|
||||
- (BOOL)selected;
|
||||
- (BOOL)regioned;
|
||||
- setSelected: (BOOL)s;
|
||||
- setRegioned: (BOOL)s;
|
||||
- (id) calcWindings;
|
||||
|
||||
- getMins: (vec3_t)mins maxs: (vec3_t)maxs;
|
||||
- (void) writeToFILE: (FILE *)f region: (BOOL)reg;
|
||||
|
||||
- (BOOL)containsPoint: (vec3_t)pt;
|
||||
- (BOOL) selected;
|
||||
- (BOOL) regioned;
|
||||
- (void) setSelected: (BOOL)s;
|
||||
- (void) setRegioned: (BOOL)s;
|
||||
|
||||
- freeWindings;
|
||||
- removeIfInvalid;
|
||||
- (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs;
|
||||
|
||||
extern vec3_t region_min, region_max;
|
||||
- newRegion;
|
||||
- (BOOL) containsPoint: (vec3_t)pt;
|
||||
|
||||
- (texturedef_t *)texturedef;
|
||||
- (texturedef_t *)texturedefForFace: (int)f;
|
||||
- setTexturedef: (texturedef_t *)tex;
|
||||
- setTexturedef: (texturedef_t *)tex forFace:(int)f;
|
||||
- (void) freeWindings;
|
||||
- (id) removeIfInvalid;
|
||||
|
||||
- XYDrawSelf;
|
||||
- ZDrawSelf;
|
||||
- CameraDrawSelf;
|
||||
- XYRenderSelf;
|
||||
- CameraRenderSelf;
|
||||
extern vec3_t region_min, region_max;
|
||||
|
||||
- hitByRay: (vec3_t)p1 : (vec3_t) p2 : (float *)time : (int *)face;
|
||||
- (id) newRegion;
|
||||
|
||||
- (texturedef_t *) texturedef;
|
||||
- (texturedef_t *) texturedefForFace: (int)f;
|
||||
- (void) setTexturedef: (texturedef_t *)tex;
|
||||
- (void) setTexturedef: (texturedef_t *)tex forFace: (int)f;
|
||||
|
||||
- (void) XYDrawSelf;
|
||||
- (void) ZDrawSelf;
|
||||
- (void) CameraDrawSelf;
|
||||
- (void) XYRenderSelf;
|
||||
- (void) CameraRenderSelf;
|
||||
|
||||
- (void) hitByRay: (vec3_t)p1: (vec3_t)p2: (float *)time: (int *)face;
|
||||
|
||||
//
|
||||
// single brush actions
|
||||
//
|
||||
extern int numcontrolpoints;
|
||||
extern float *controlpoints[MAX_FACES*3];
|
||||
- getZdragface: (vec3_t)dragpoint;
|
||||
- getXYdragface: (vec3_t)dragpoint;
|
||||
- getXYShearPoints: (vec3_t)dragpoint;
|
||||
extern int numcontrolpoints;
|
||||
extern float *controlpoints[MAX_FACES * 3];
|
||||
|
||||
- addFace: (face_t *)f;
|
||||
- (void) getZdragface: (vec3_t)dragpoint;
|
||||
- (void) getXYdragface: (vec3_t)dragpoint;
|
||||
- (void) getXYShearPoints: (vec3_t)dragpoint;
|
||||
|
||||
- (id) addFace: (face_t *)f;
|
||||
|
||||
//
|
||||
// multiple brush actions
|
||||
//
|
||||
- carveByClipper;
|
||||
- (void) carveByClipper;
|
||||
|
||||
extern vec3_t sb_translate;
|
||||
- translate;
|
||||
extern vec3_t sb_translate;
|
||||
|
||||
extern id carve_in, carve_out;
|
||||
- select;
|
||||
- deselect;
|
||||
- remove;
|
||||
- flushTextures;
|
||||
- (void) translate;
|
||||
|
||||
extern vec3_t sb_mins, sb_maxs;
|
||||
- addToBBox;
|
||||
extern id carve_in, carve_out;
|
||||
|
||||
extern vec3_t sel_x, sel_y, sel_z;
|
||||
extern vec3_t sel_org;
|
||||
- transform;
|
||||
- (void) select;
|
||||
- (void) deselect;
|
||||
- (void) remove;
|
||||
- (void) flushTextures;
|
||||
|
||||
- flipNormals;
|
||||
extern vec3_t sb_mins, sb_maxs;
|
||||
|
||||
- carve;
|
||||
- setCarveVars;
|
||||
- (void) addToBBox;
|
||||
|
||||
extern id sb_newowner;
|
||||
- moveToEntity;
|
||||
extern vec3_t sel_x, sel_y, sel_z;
|
||||
extern vec3_t sel_org;
|
||||
|
||||
- takeCurrentTexture;
|
||||
- (void) transform;
|
||||
|
||||
extern vec3_t select_min, select_max;
|
||||
- selectPartial;
|
||||
- selectComplete;
|
||||
- regionPartial;
|
||||
- regionComplete;
|
||||
- (void) flipNormals;
|
||||
|
||||
extern float sb_floor_dir, sb_floor_dist;
|
||||
- feetToFloor;
|
||||
- (id) carve;
|
||||
- (void) setCarveVars;
|
||||
|
||||
extern id sb_newowner;
|
||||
|
||||
- (void) moveToEntity;
|
||||
|
||||
- (void) takeCurrentTexture;
|
||||
|
||||
extern vec3_t select_min, select_max;
|
||||
|
||||
- (void) selectPartial;
|
||||
- (void) selectComplete;
|
||||
- (void) regionPartial;
|
||||
- (void) regionComplete;
|
||||
|
||||
extern float sb_floor_dir, sb_floor_dist;
|
||||
|
||||
- (void) feetToFloor;
|
||||
|
||||
- (int) getNumBrushFaces;
|
||||
- (face_t *)getBrushFace: (int)which;
|
||||
- (face_t *) getBrushFace: (int)which;
|
||||
|
||||
@end
|
||||
|
||||
#endif // SetBrush_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
85
tools/Forge/Bundles/MapEdit/Storage.h
Normal file
85
tools/Forge/Bundles/MapEdit/Storage.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Interface for Objective C NeXT-compatible Storage object
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
|
||||
This file is part of the Gnustep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/******************************************************************
|
||||
TODO:
|
||||
Does not implement methods for archiving itself.
|
||||
******************************************************************/
|
||||
|
||||
#ifndef __Storage_h_INCLUDE_GNU
|
||||
#define __Storage_h_INCLUDE_GNU
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface Storage: NSObject
|
||||
{
|
||||
@public
|
||||
void *dataPtr; /* data of the Storage object */
|
||||
const char *description; /* Element description */
|
||||
NSUInteger numElements; /* Actual number of elements */
|
||||
NSUInteger maxElements; /* Total allocated elements */
|
||||
NSUInteger elementSize; /* Element size */
|
||||
}
|
||||
|
||||
/* Creating, freeing, initializing, and emptying */
|
||||
|
||||
- (id) init;
|
||||
- (id) initCount: (NSUInteger)numSlots
|
||||
elementSize: (NSUInteger)sizeInBytes
|
||||
description: (const char *)elemDesc;
|
||||
- (void) dealloc;
|
||||
- (id) empty;
|
||||
- (id) copy;
|
||||
|
||||
/* Manipulating the elements */
|
||||
|
||||
- (BOOL) isEqual: anObject;
|
||||
- (const char *) description;
|
||||
- (NSUInteger) count;
|
||||
- (void *) elementAt: (NSUInteger)index;
|
||||
- (id) replaceElementAt: (NSUInteger)index
|
||||
with: (void *)anElement;
|
||||
|
||||
- (id) setNumSlots: (NSUInteger)numSlots;
|
||||
- (id) setAvailableCapacity: (NSUInteger)numSlots;
|
||||
- (id) addElement: (void *)anElement;
|
||||
- (id) removeLastElement;
|
||||
- (id) insertElement: (void *)anElement
|
||||
at: (NSUInteger)index;
|
||||
|
||||
- (id) removeElementAt: (NSUInteger)index;
|
||||
|
||||
/* old-style creation */
|
||||
|
||||
+ (id) new;
|
||||
+ (id) newCount: (NSUInteger)count
|
||||
elementSize: (NSUInteger)sizeInBytes
|
||||
description: (const char *)descriptor;
|
||||
|
||||
@end
|
||||
|
||||
typedef struct {
|
||||
@defs (Storage)
|
||||
} NXStorageId;
|
||||
|
||||
#endif /* __Storage_h_INCLUDE_GNU */
|
253
tools/Forge/Bundles/MapEdit/Storage.m
Normal file
253
tools/Forge/Bundles/MapEdit/Storage.m
Normal file
|
@ -0,0 +1,253 @@
|
|||
/* Implementation of Objective C NeXT-compatible Storage object
|
||||
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* #include <config.h> */
|
||||
#include "Storage.h"
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#define GNU_STORAGE_NTH(x, N) \
|
||||
({GNUStorageId* __s = (GNUStorageId*) (x); \
|
||||
(void*) (((char*) __s->dataPtr) + (__s->elementSize * (N))); })
|
||||
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
|
||||
|
||||
typedef struct {
|
||||
@defs (Storage)
|
||||
} GNUStorageId;
|
||||
|
||||
@implementation Storage
|
||||
|
||||
+ (id) initialize
|
||||
{
|
||||
if (self == [Storage class])
|
||||
[self setVersion: 0]; /* beta release */
|
||||
return self;
|
||||
}
|
||||
|
||||
// INITIALIZING, FREEING;
|
||||
|
||||
- (id) initCount: (NSUInteger)numSlots elementSize: (NSUInteger)sizeInBytes
|
||||
description: (const char *)
|
||||
elemDesc;
|
||||
{
|
||||
[super init];
|
||||
numElements = numSlots;
|
||||
maxElements = (numSlots > 0) ? numSlots : 1;
|
||||
elementSize = sizeInBytes;
|
||||
description = elemDesc;
|
||||
dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
||||
bzero (dataPtr, numElements * elementSize);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initCount: 1 elementSize: sizeof (id)
|
||||
description: @encode (id)];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (dataPtr)
|
||||
free (dataPtr);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (const char *) description
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
// COPYING;
|
||||
|
||||
- (id) copy
|
||||
{
|
||||
Storage *c = [super copy];
|
||||
|
||||
c->dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
||||
memcpy (c->dataPtr, dataPtr, numElements * elementSize);
|
||||
return c;
|
||||
}
|
||||
|
||||
// COMPARING TWO STORAGES;
|
||||
|
||||
- (BOOL) isEqual: anObject
|
||||
{
|
||||
if ([anObject isKindOfClass: [Storage class]]
|
||||
&& [anObject count] == [self count]
|
||||
&& !memcmp (((GNUStorageId *) anObject)->dataPtr,
|
||||
dataPtr, numElements * elementSize))
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
// MANAGING THE STORAGE CAPACITY;
|
||||
|
||||
static inline void
|
||||
_makeRoomForAnotherIfNecessary (Storage * self)
|
||||
{
|
||||
if (self->numElements == self->maxElements) {
|
||||
self->maxElements *= 2;
|
||||
self->dataPtr = (void *)
|
||||
objc_realloc (self->dataPtr,
|
||||
self->maxElements * self->elementSize);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
_shrinkIfDesired (Storage * self)
|
||||
{
|
||||
if (self->numElements < (self->maxElements / 2)) {
|
||||
self->maxElements /= 2;
|
||||
self->dataPtr = (void *)
|
||||
objc_realloc (self->dataPtr,
|
||||
self->maxElements * self->elementSize);
|
||||
}
|
||||
}
|
||||
|
||||
- (id) setAvailableCapacity: (NSUInteger)numSlots
|
||||
{
|
||||
if (numSlots > numElements) {
|
||||
maxElements = numSlots;
|
||||
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) setNumSlots: (NSUInteger)numSlots
|
||||
{
|
||||
if (numSlots > numElements) {
|
||||
maxElements = numSlots;
|
||||
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||
bzero (STORAGE_NTH (numElements),
|
||||
(maxElements - numElements) * elementSize);
|
||||
} else if (numSlots < numElements) {
|
||||
numElements = numSlots;
|
||||
_shrinkIfDesired (self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Manipulating objects by index */
|
||||
|
||||
#define CHECK_INDEX(IND) if (IND >= numElements) return 0
|
||||
|
||||
- (NSUInteger) count
|
||||
{
|
||||
return numElements;
|
||||
}
|
||||
|
||||
- (void *) elementAt: (NSUInteger)index
|
||||
{
|
||||
CHECK_INDEX (index);
|
||||
return STORAGE_NTH (index);
|
||||
}
|
||||
|
||||
- (id) addElement: (void *)anElement
|
||||
{
|
||||
_makeRoomForAnotherIfNecessary (self);
|
||||
memcpy (STORAGE_NTH (numElements), anElement, elementSize);
|
||||
numElements++;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) insertElement: (void *)
|
||||
anElement at: (NSUInteger)index
|
||||
{
|
||||
NSUInteger i;
|
||||
|
||||
CHECK_INDEX (index);
|
||||
_makeRoomForAnotherIfNecessary (self);
|
||||
#ifndef STABLE_MEMCPY
|
||||
for (i = numElements; i >= index; i--)
|
||||
memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize);
|
||||
|
||||
#else
|
||||
memcpy (STORAGE_NTH (index + 1),
|
||||
STORAGE_NTH (index), elementSize * (numElements - index));
|
||||
#endif
|
||||
memcpy (STORAGE_NTH (i), anElement, elementSize);
|
||||
numElements++;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) removeElementAt: (NSUInteger)index
|
||||
{
|
||||
NSUInteger i;
|
||||
|
||||
CHECK_INDEX (index);
|
||||
numElements--;
|
||||
#ifndef STABLE_MEMCPY
|
||||
for (i = index; i < numElements; i++)
|
||||
memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize);
|
||||
|
||||
#else
|
||||
memcpy (STORAGE_NTH (index),
|
||||
STORAGE_NTH (index + 1), elementSize * (numElements - index - 1));
|
||||
#endif
|
||||
_shrinkIfDesired (self);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) removeLastElement
|
||||
{
|
||||
if (numElements) {
|
||||
numElements--;
|
||||
_shrinkIfDesired (self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) replaceElementAt: (NSUInteger)
|
||||
index with: (void *)newElement
|
||||
{
|
||||
CHECK_INDEX (index);
|
||||
memcpy (STORAGE_NTH (index), newElement, elementSize);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Emptying the Storage */
|
||||
|
||||
- (id) empty
|
||||
{
|
||||
numElements = 0;
|
||||
maxElements = 1;
|
||||
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (id) new
|
||||
{
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
+ (id) newCount: (NSUInteger)
|
||||
count elementSize: (NSUInteger)sizeInBytes
|
||||
description: (const char *)descriptor
|
||||
{
|
||||
return [[self alloc] initCount: count elementSize: sizeInBytes description:
|
||||
descriptor];
|
||||
}
|
||||
|
||||
@end
|
35
tools/Forge/Bundles/MapEdit/THING+NSArray.m
Normal file
35
tools/Forge/Bundles/MapEdit/THING+NSArray.m
Normal file
|
@ -0,0 +1,35 @@
|
|||
@implementation THING (NSArray)
|
||||
|
||||
- (NSUInteger) count
|
||||
{
|
||||
return [array count];
|
||||
}
|
||||
|
||||
- (id) objectAtIndex: (NSUInteger)index
|
||||
{
|
||||
if (index >= [self count])
|
||||
return 0;
|
||||
return [array objectAtIndex: index];
|
||||
}
|
||||
|
||||
- (void) addObject: (id)anObject
|
||||
{
|
||||
[array addObject: anObject];
|
||||
}
|
||||
|
||||
- (void) insertObject: (id)anObject atIndex: (NSUInteger)index
|
||||
{
|
||||
[array insertObject: anObject atIndex: index];
|
||||
}
|
||||
|
||||
- (void) removeObjectAtIndex: (NSUInteger)index
|
||||
{
|
||||
[array removeObjectAtIndex: index];
|
||||
}
|
||||
|
||||
- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
|
||||
{
|
||||
[array replaceObjectAtIndex: index withObject: anObject];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,113 +1,113 @@
|
|||
#ifndef TexturePalette_h
|
||||
#define TexturePalette_h
|
||||
|
||||
typedef union
|
||||
{
|
||||
byte chan[4];
|
||||
unsigned p;
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "QF/qtypes.h"
|
||||
|
||||
typedef union {
|
||||
byte chan[4];
|
||||
unsigned p;
|
||||
} pixel32_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char texture[16];
|
||||
float rotate;
|
||||
float shift[2];
|
||||
float scale[2];
|
||||
typedef struct {
|
||||
char texture[16];
|
||||
float rotate;
|
||||
float shift[2];
|
||||
float scale[2];
|
||||
} texturedef_t;
|
||||
|
||||
typedef struct {
|
||||
char name[16];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[16];
|
||||
|
||||
int width;
|
||||
int height;
|
||||
NSBitmapImageRep *rep;
|
||||
void *data;
|
||||
pixel32_t flatcolor;
|
||||
int width;
|
||||
int height;
|
||||
NSBitmapImageRep *rep;
|
||||
void *data;
|
||||
pixel32_t flatcolor;
|
||||
} qtexture_t;
|
||||
|
||||
#define MAX_TEXTURES 1024
|
||||
#define MAX_TEXTURES 1024
|
||||
|
||||
extern int tex_count;
|
||||
extern qtexture_t qtextures[MAX_TEXTURES];
|
||||
extern int tex_count;
|
||||
extern qtexture_t qtextures[MAX_TEXTURES];
|
||||
|
||||
void TEX_InitFromWad (char *path);
|
||||
qtexture_t *TEX_ForName (char *name);
|
||||
qtexture_t *TEX_ForName (const char *name);
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
id image; // NSImage
|
||||
NSRect r;
|
||||
char *name;
|
||||
int index;
|
||||
int display; // flag (on/off)
|
||||
typedef struct {
|
||||
NSImageRep *image;
|
||||
NSRect r;
|
||||
char *name;
|
||||
int index;
|
||||
int display; // flag (on/off)
|
||||
} texpal_t;
|
||||
|
||||
#define TEX_INDENT 10
|
||||
#define TEX_SPACING 16
|
||||
#define TEX_INDENT 10
|
||||
#define TEX_SPACING 16
|
||||
|
||||
extern id texturepalette_i;
|
||||
extern id texturepalette_i;
|
||||
|
||||
@interface TexturePalette:Object
|
||||
@interface TexturePalette: NSObject
|
||||
{
|
||||
char currentwad[1024];
|
||||
id textureList_i;
|
||||
id textureView_i;
|
||||
id searchField_i;
|
||||
id sizeField_i;
|
||||
|
||||
id field_Xshift_i;
|
||||
id field_Yshift_i;
|
||||
id field_Xscale_i;
|
||||
id field_Yscale_i;
|
||||
id field_Rotate_i;
|
||||
|
||||
int viewWidth;
|
||||
int viewHeight;
|
||||
int selectedTexture;
|
||||
char currentwad[1024];
|
||||
id textureList_i;
|
||||
id textureView_i;
|
||||
id searchField_i;
|
||||
id sizeField_i;
|
||||
|
||||
id field_Xshift_i;
|
||||
id field_Yshift_i;
|
||||
id field_Xscale_i;
|
||||
id field_Yscale_i;
|
||||
id field_Rotate_i;
|
||||
|
||||
int viewWidth;
|
||||
int viewHeight;
|
||||
int selectedTexture;
|
||||
}
|
||||
|
||||
- (char*)currentWad;
|
||||
- initPaletteFromWadfile:(char *)wf;
|
||||
- computeTextureViewSize;
|
||||
- alphabetize;
|
||||
- getList;
|
||||
- (int)getSelectedTexture;
|
||||
- setSelectedTexture:(int)which;
|
||||
- (int)getSelectedTexIndex;
|
||||
- (const char *) currentWad;
|
||||
- (id) initPaletteFromWadfile: (const char *)wf;
|
||||
- (id) computeTextureViewSize;
|
||||
- (id) alphabetize;
|
||||
- (id) getList;
|
||||
- (int) getSelectedTexture;
|
||||
- (id) setSelectedTexture: (int)which;
|
||||
- (int) getSelectedTexIndex;
|
||||
|
||||
// Called externally
|
||||
- (char *)getSelTextureName;
|
||||
- setTextureByName:(char *)name;
|
||||
- (const char *) getSelTextureName;
|
||||
- (id) setTextureByName: (const char *)name;
|
||||
|
||||
// New methods to replace the 2 above ones
|
||||
- setTextureDef:(texturedef_t *)td;
|
||||
- getTextureDef:(texturedef_t *)td;
|
||||
- (id) setTextureDef: (texturedef_t *)td;
|
||||
- (id) getTextureDef: (texturedef_t *)td;
|
||||
|
||||
// Action methods
|
||||
- searchForTexture:sender;
|
||||
- (id) searchForTexture: sender;
|
||||
|
||||
- clearTexinfo: sender;
|
||||
- (id) clearTexinfo: sender;
|
||||
|
||||
- incXShift:sender;
|
||||
- decXShift:sender;
|
||||
- (id) incXShift: sender;
|
||||
- (id) decXShift: sender;
|
||||
|
||||
- incYShift:sender;
|
||||
- decYShift:sender;
|
||||
- (id) incYShift: sender;
|
||||
- (id) decYShift: sender;
|
||||
|
||||
- incRotate: sender;
|
||||
- decRotate: sender;
|
||||
- (id) incRotate: sender;
|
||||
- (id) decRotate: sender;
|
||||
|
||||
- incXScale:sender;
|
||||
- decXScale:sender;
|
||||
- (id) incXScale: sender;
|
||||
- (id) decXScale: sender;
|
||||
|
||||
- incYScale:sender;
|
||||
- decYScale:sender;
|
||||
- (id) incYScale: sender;
|
||||
- (id) decYScale: sender;
|
||||
|
||||
- texturedefChanged: sender;
|
||||
- onlyShowMapTextures:sender;
|
||||
- (int) searchForTextureInPalette:(char *)texture;
|
||||
- setDisplayFlag:(int)index to:(int)value;
|
||||
- (id) texturedefChanged: sender;
|
||||
- (id) onlyShowMapTextures: sender;
|
||||
- (int) searchForTextureInPalette: (const char *)texture;
|
||||
- (id) setDisplayFlag: (int)index
|
||||
to: (int)value;
|
||||
|
||||
@end
|
||||
#endif // TexturePalette_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,12 +1,16 @@
|
|||
#ifndef TextureView_h
|
||||
#define TextureView_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface TextureView:NSView
|
||||
@interface TextureView: NSView
|
||||
{
|
||||
id parent_i;
|
||||
int deselectIndex;
|
||||
id parent_i;
|
||||
int deselectIndex;
|
||||
}
|
||||
|
||||
- setParent:(id)from;
|
||||
- deselect;
|
||||
- (id) setParent: (id)from;
|
||||
- (id) deselect;
|
||||
|
||||
@end
|
||||
#endif // TextureView_h
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#include "QF/sys.h"
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "KeypairView.h"
|
||||
#include "TextureView.h"
|
||||
#include "TexturePalette.h"
|
||||
|
||||
#include "Storage.h"
|
||||
|
||||
/*
|
||||
|
||||
|
@ -9,143 +14,135 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
|||
|
||||
@implementation TextureView
|
||||
|
||||
- init
|
||||
- (id) init
|
||||
{
|
||||
deselectIndex = -1;
|
||||
return self;
|
||||
}
|
||||
|
||||
- setParent:(id)from
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id) setParent: (id)from
|
||||
{
|
||||
parent_i = from;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstMouse
|
||||
- (BOOL) acceptsFirstMouse
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- drawSelf:(const NSRect *)rects :(int)rectCount
|
||||
- (id) drawRect: (NSRect)rects
|
||||
{
|
||||
int i;
|
||||
int max;
|
||||
id list_i;
|
||||
texpal_t *t;
|
||||
int x;
|
||||
int y;
|
||||
NSPoint p;
|
||||
NSRect r;
|
||||
int selected;
|
||||
|
||||
int i;
|
||||
int max;
|
||||
id list_i;
|
||||
texpal_t *t;
|
||||
int x;
|
||||
int y;
|
||||
NSPoint p;
|
||||
NSRect r;
|
||||
int selected;
|
||||
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
|
||||
|
||||
selected = [parent_i getSelectedTexture];
|
||||
list_i = [parent_i getList];
|
||||
PSselectfont("Helvetica-Medium",FONTSIZE);
|
||||
PSrotate(0);
|
||||
|
||||
PSsetgray(NS_LTGRAY);
|
||||
PSrectfill(rects->origin.x, rects->origin.y,
|
||||
rects->size.width, rects->size.height);
|
||||
[[NSFont systemFontOfSize: FONTSIZE] set];
|
||||
|
||||
if (!list_i) // WADfile didn't init
|
||||
[[NSColor lightGrayColor] set];
|
||||
NSRectFill (rects);
|
||||
|
||||
if (!list_i) // WADfile didn't init
|
||||
return self;
|
||||
|
||||
if (deselectIndex != -1)
|
||||
{
|
||||
t = [list_i elementAt:deselectIndex];
|
||||
if (deselectIndex != -1) {
|
||||
t = [list_i elementAt: deselectIndex];
|
||||
r = t->r;
|
||||
r.origin.x -= TEX_INDENT;
|
||||
r.origin.y -= TEX_INDENT;
|
||||
r.size.width += TEX_INDENT*2;
|
||||
r.size.height += TEX_INDENT*2;
|
||||
|
||||
PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||
PSrectfill(r.origin.x, r.origin.y,
|
||||
r.size.width, r.size.height);
|
||||
r.size.width += TEX_INDENT * 2;
|
||||
r.size.height += TEX_INDENT * 2;
|
||||
|
||||
[[NSColor lightGrayColor] set];
|
||||
NSRectFill (r);
|
||||
p = t->r.origin;
|
||||
p.y += TEX_SPACING;
|
||||
[t->image drawAt:&p];
|
||||
PSsetgray(0);
|
||||
[t->image drawAtPoint: p];
|
||||
[[NSColor blackColor] set];
|
||||
x = t->r.origin.x;
|
||||
y = t->r.origin.y + 7;
|
||||
PSmoveto(x,y);
|
||||
PSshow(t->name);
|
||||
PSstroke();
|
||||
[[NSString stringWithCString: t->name]
|
||||
drawAtPoint: NSMakePoint (x, y) withAttributes: attribs];
|
||||
deselectIndex = -1;
|
||||
}
|
||||
|
||||
max = [list_i count];
|
||||
PSsetgray(0);
|
||||
[[NSColor blackColor] set];
|
||||
|
||||
for (i = 0;i < max; i++)
|
||||
{
|
||||
t = [list_i elementAt:i];
|
||||
for (i = 0; i < max; i++) {
|
||||
t = [list_i elementAt: i];
|
||||
r = t->r;
|
||||
r.origin.x -= TEX_INDENT/2;
|
||||
r.origin.x -= TEX_INDENT / 2;
|
||||
r.size.width += TEX_INDENT;
|
||||
r.origin.y += 4;
|
||||
if (NSIntersectsRect(&rects[0],&r) == YES &&
|
||||
t->display)
|
||||
{
|
||||
if (selected == i)
|
||||
{
|
||||
PSsetgray(1);
|
||||
PSrectfill(r.origin.x,r.origin.y,
|
||||
r.size.width,r.size.height);
|
||||
PSsetrgbcolor(1,0,0);
|
||||
PSrectstroke(r.origin.x, r.origin.y,
|
||||
r.size.width, r.size.height);
|
||||
PSsetgray(0);
|
||||
if (NSIntersectsRect (rects, r) == YES && t->display) {
|
||||
if (selected == i) {
|
||||
[[NSColor whiteColor] set];
|
||||
NSRectFill (r);
|
||||
[[NSColor redColor] set];
|
||||
NSFrameRect (r);
|
||||
[[NSColor blackColor] set];
|
||||
}
|
||||
|
||||
|
||||
p = t->r.origin;
|
||||
p.y += TEX_SPACING;
|
||||
[t->image drawAt:&p];
|
||||
[t->image drawAtPoint: p];
|
||||
x = t->r.origin.x;
|
||||
y = t->r.origin.y + 7;
|
||||
PSmoveto(x,y);
|
||||
PSshow(t->name);
|
||||
[[NSString stringWithCString: t->name]
|
||||
drawAtPoint: NSMakePoint (x, y) withAttributes: attribs];
|
||||
}
|
||||
}
|
||||
PSstroke();
|
||||
return self;
|
||||
}
|
||||
|
||||
- deselect
|
||||
- (id) deselect
|
||||
{
|
||||
deselectIndex = [parent_i getSelectedTexture];
|
||||
return self;
|
||||
}
|
||||
|
||||
- mouseDown:(NSEvent *)theEvent
|
||||
- (id) mouseDown: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint loc;
|
||||
int i;
|
||||
int max;
|
||||
int oldwindowmask;
|
||||
texpal_t *t;
|
||||
id list;
|
||||
NSRect r;
|
||||
NSPoint loc;
|
||||
int i;
|
||||
int max;
|
||||
|
||||
// int oldwindowmask;
|
||||
texpal_t *t;
|
||||
id list;
|
||||
NSRect r;
|
||||
|
||||
// oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
||||
loc = [theEvent locationInWindow];
|
||||
loc = [self convertPoint: loc fromView: NULL];
|
||||
|
||||
oldwindowmask = [window addToEventMask:NS_LMOUSEDRAGGEDMASK];
|
||||
loc = theEvent->location;
|
||||
[self convertPoint:&loc fromView:NULL];
|
||||
|
||||
list = [parent_i getList];
|
||||
max = [list count];
|
||||
for (i = 0;i < max; i++)
|
||||
{
|
||||
t = [list elementAt:i];
|
||||
for (i = 0; i < max; i++) {
|
||||
t = [list elementAt: i];
|
||||
r = t->r;
|
||||
if (NSPointInRect(&loc,&r) == YES)
|
||||
{
|
||||
[self deselect];
|
||||
[parent_i setSelectedTexture:i];
|
||||
if (NSPointInRect (loc, r) == YES) {
|
||||
[self deselect];
|
||||
[parent_i setSelectedTexture: i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[window setEventMask:oldwindowmask];
|
||||
|
||||
// [window setEventMask:oldwindowmask];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,42 +1,46 @@
|
|||
#ifndef Things_h
|
||||
#define Things_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
extern id things_i;
|
||||
#include "Entity.h"
|
||||
|
||||
#define ENTITYNAMEKEY "spawn"
|
||||
extern id things_i;
|
||||
|
||||
@interface Things:Object
|
||||
#define ENTITYNAMEKEY "spawn"
|
||||
|
||||
@interface Things: NSObject
|
||||
{
|
||||
id entity_browser_i; // browser
|
||||
id entity_comment_i; // scrolling text window
|
||||
|
||||
id prog_path_i;
|
||||
|
||||
int lastSelected; // last row selected in browser
|
||||
id entity_browser_i; // browser
|
||||
id entity_comment_i; // scrolling text window
|
||||
|
||||
id keyInput_i;
|
||||
id valueInput_i;
|
||||
id flags_i;
|
||||
id prog_path_i;
|
||||
|
||||
int lastSelected; // last row selected in browser
|
||||
|
||||
id keyInput_i;
|
||||
id valueInput_i;
|
||||
id flags_i;
|
||||
}
|
||||
|
||||
- initEntities;
|
||||
- (id) initEntities;
|
||||
|
||||
- newCurrentEntity;
|
||||
- setSelectedKey:(epair_t *)ep;
|
||||
- (id) newCurrentEntity;
|
||||
- (id) setSelectedKey: (epair_t *)ep;
|
||||
|
||||
- clearInputs;
|
||||
- (char *)spawnName;
|
||||
- (id) clearInputs;
|
||||
- (const char *) spawnName;
|
||||
|
||||
// UI targets
|
||||
- reloadEntityClasses: sender;
|
||||
- selectEntity: sender;
|
||||
- doubleClickEntity: sender;
|
||||
- (id) reloadEntityClasses: sender;
|
||||
- (id) selectEntity: sender;
|
||||
- (id) doubleClickEntity: sender;
|
||||
|
||||
// Action methods
|
||||
- addPair:sender;
|
||||
- delPair:sender;
|
||||
- setAngle:sender;
|
||||
- setFlags:sender;
|
||||
|
||||
- (id) addPair: sender;
|
||||
- (id) delPair: sender;
|
||||
- (id) setAngle: sender;
|
||||
- (id) setFlags: sender;
|
||||
|
||||
@end
|
||||
#endif // Things_h
|
||||
|
|
|
@ -1,222 +1,223 @@
|
|||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
|
||||
#include "qedefs.h"
|
||||
#include "Things.h"
|
||||
#include "QuakeEd.h"
|
||||
#include "Map.h"
|
||||
#include "EntityClass.h"
|
||||
#include "KeypairView.h"
|
||||
#include "Project.h"
|
||||
|
||||
id things_i;
|
||||
id things_i;
|
||||
|
||||
@implementation Things
|
||||
|
||||
- init
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
|
||||
things_i = self;
|
||||
lastSelected = 0;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Load the TEXT object with the entity comment
|
||||
//
|
||||
- loadEntityComment:(id)obj
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
[entity_comment_i selectAll:self];
|
||||
[entity_comment_i replaceSel:[obj comments]];
|
||||
// FIXME this should not be needed (bug in gnustep?)
|
||||
[flags_i selectAll: self];
|
||||
[flags_i deselectAllCells];
|
||||
}
|
||||
|
||||
// Load the TEXT object with the entity comment
|
||||
- (id) loadEntityComment: (id)obj
|
||||
{
|
||||
[entity_comment_i selectAll: self];
|
||||
[entity_comment_i
|
||||
replaceCharactersInRange: [entity_comment_i selectedRange]
|
||||
withString: [NSString stringWithCString: [obj comments]]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- initEntities
|
||||
{
|
||||
char *path;
|
||||
- (id) initEntities
|
||||
{
|
||||
NSString *path;
|
||||
|
||||
path = [project_i getProgDirectory];
|
||||
|
||||
[prog_path_i setStringValue: path];
|
||||
|
||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||
|
||||
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]];
|
||||
[[EntityClassList alloc] initForSourceDirectory: [path cString]];
|
||||
|
||||
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
|
||||
[entity_browser_i loadColumnZero];
|
||||
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0];
|
||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
|
||||
|
||||
[entity_browser_i setDoubleAction: @selector (doubleClickEntity:)];
|
||||
|
||||
[entity_browser_i setDoubleAction: @selector(doubleClickEntity:)];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- selectEntity: sender
|
||||
- (id) selectEntity: sender
|
||||
{
|
||||
id matr;
|
||||
|
||||
id matr;
|
||||
|
||||
matr = [sender matrixInColumn: 0];
|
||||
lastSelected = [matr selectedRow];
|
||||
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]];
|
||||
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- doubleClickEntity: sender
|
||||
- (id) doubleClickEntity: sender
|
||||
{
|
||||
[map_i makeEntity: sender];
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (char *)spawnName
|
||||
- (const char *) spawnName
|
||||
{
|
||||
return [[entity_classes_i objectAt:lastSelected] classname];
|
||||
return [[entity_classes_i objectAtIndex: lastSelected] classname];
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Flush entity classes & reload them!
|
||||
//
|
||||
- reloadEntityClasses: sender
|
||||
// Flush entity classes & reload them!
|
||||
- (id) reloadEntityClasses: sender
|
||||
{
|
||||
EntityClass *ent;
|
||||
char *path;
|
||||
|
||||
path = (char *)[prog_path_i stringValue];
|
||||
if (!path || !path[0])
|
||||
{
|
||||
EntityClass *ent;
|
||||
NSString *path;
|
||||
|
||||
path = [prog_path_i stringValue];
|
||||
if (!path || ![path length]) {
|
||||
path = [project_i getProgDirectory];
|
||||
[prog_path_i setStringValue: path];
|
||||
}
|
||||
|
||||
// Free all entity info in memory...
|
||||
[entity_classes_i freeObjects];
|
||||
[entity_classes_i free];
|
||||
|
||||
// Now, RELOAD!
|
||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||
// Free all entity info in memory...
|
||||
[entity_classes_i removeAllObjects];
|
||||
[entity_classes_i release];
|
||||
|
||||
// Now, RELOAD!
|
||||
[[EntityClassList alloc] initForSourceDirectory: [path cString]];
|
||||
|
||||
lastSelected = 0;
|
||||
ent = [entity_classes_i objectAt:lastSelected];
|
||||
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]];
|
||||
ent = [entity_classes_i objectAtIndex: lastSelected];
|
||||
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
|
||||
|
||||
[entity_browser_i loadColumnZero];
|
||||
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0];
|
||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
|
||||
|
||||
[self newCurrentEntity]; // in case flags changed
|
||||
|
||||
[self newCurrentEntity]; // in case flags changed
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- selectClass: (char *)class
|
||||
- (id) selectClass: (const char *)class
|
||||
{
|
||||
id classent;
|
||||
|
||||
classent = [entity_classes_i classForName:class];
|
||||
id classent;
|
||||
|
||||
classent = [entity_classes_i classForName: class];
|
||||
if (!classent)
|
||||
return self;
|
||||
lastSelected = [entity_classes_i indexOf: classent];
|
||||
|
||||
lastSelected = [entity_classes_i indexOfObject: classent];
|
||||
|
||||
if (lastSelected < 0)
|
||||
lastSelected = 0;
|
||||
|
||||
[self loadEntityComment:classent];
|
||||
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0];
|
||||
[[entity_browser_i matrixInColumn:0] scrollCellToVisible:lastSelected :0];
|
||||
[self loadEntityComment: classent];
|
||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
|
||||
[[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected
|
||||
column: 0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- newCurrentEntity
|
||||
- (id) newCurrentEntity
|
||||
{
|
||||
id ent, classent, cell;
|
||||
char *classname;
|
||||
int r, c;
|
||||
char *flagname;
|
||||
int flags;
|
||||
|
||||
id ent, classent, cell;
|
||||
const char *classname;
|
||||
int r, c;
|
||||
const char *flagname;
|
||||
int flags;
|
||||
|
||||
ent = [map_i currentEntity];
|
||||
classname = [ent valueForQKey: "classname"];
|
||||
if (ent != [map_i objectAt: 0])
|
||||
[self selectClass: classname]; // don't reset for world
|
||||
classent = [entity_classes_i classForName:classname];
|
||||
if (ent != [map_i objectAtIndex: 0])
|
||||
[self selectClass: classname]; // don't reset for world
|
||||
classent = [entity_classes_i classForName: classname];
|
||||
flagname = [ent valueForQKey: "spawnflags"];
|
||||
if (!flagname)
|
||||
flags = 0;
|
||||
else
|
||||
flags = atoi(flagname);
|
||||
|
||||
[flags_i setAutodisplay: NO];
|
||||
for (r=0 ; r<4 ; r++)
|
||||
for (c=0 ; c<3 ; c++)
|
||||
{
|
||||
cell = [flags_i cellAt: r : c];
|
||||
if (c < 2)
|
||||
{
|
||||
flagname = [classent flagName: c*4 + r];
|
||||
[cell setTitle: flagname];
|
||||
flags = atoi (flagname);
|
||||
|
||||
// [flags_i setAutodisplay:NO];
|
||||
for (r = 0; r < 4; r++) {
|
||||
for (c = 0; c < 3; c++) {
|
||||
cell = [flags_i cellAtRow: r column: c];
|
||||
if (c < 2) {
|
||||
flagname = [classent flagName: c * 4 + r];
|
||||
[cell setTitle: [NSString stringWithCString: flagname]];
|
||||
}
|
||||
[cell setIntValue: (flags & (1<< ((c*4)+r)) ) > 0];
|
||||
[cell setIntValue: (flags & (1 << ((c * 4) + r))) > 0];
|
||||
}
|
||||
[flags_i setAutodisplay: YES];
|
||||
}
|
||||
// [flags_i setAutodisplay:YES];
|
||||
[flags_i display];
|
||||
|
||||
// [keyInput_i setStringValue: ""];
|
||||
// [valueInput_i setStringValue: ""];
|
||||
|
||||
// [keyInput_i setStringValue: ""];
|
||||
// [valueInput_i setStringValue: ""];
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
[keypairview_i display];
|
||||
|
||||
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Clicked in the Keypair view - set as selected
|
||||
//
|
||||
- setSelectedKey:(epair_t *)ep;
|
||||
// Clicked in the Keypair view - set as selected
|
||||
- (id) setSelectedKey: (epair_t *)ep;
|
||||
{
|
||||
[keyInput_i setStringValue:ep->key];
|
||||
[valueInput_i setStringValue:ep->value];
|
||||
[valueInput_i selectText:self];
|
||||
[keyInput_i setStringValue: [NSString stringWithCString: ep->key]];
|
||||
[valueInput_i setStringValue: [NSString stringWithCString: ep->value]];
|
||||
[valueInput_i selectText: self];
|
||||
return self;
|
||||
}
|
||||
|
||||
- clearInputs
|
||||
- (id) clearInputs
|
||||
{
|
||||
// [keyInput_i setStringValue: ""];
|
||||
// [valueInput_i setStringValue: ""];
|
||||
|
||||
// [keyInput_i setStringValue: ""];
|
||||
// [valueInput_i setStringValue: ""];
|
||||
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Action methods
|
||||
//
|
||||
// Action methods
|
||||
|
||||
-addPair:sender
|
||||
- (id) addPair: sender
|
||||
{
|
||||
char *key, *value;
|
||||
|
||||
key = (char *)[keyInput_i stringValue];
|
||||
value = (char *)[valueInput_i stringValue];
|
||||
|
||||
[ [map_i currentEntity] setKey: key toValue: value ];
|
||||
const char *key, *value;
|
||||
|
||||
key = [[keyInput_i stringValue] cString];
|
||||
value = [[valueInput_i stringValue] cString];
|
||||
|
||||
[[map_i currentEntity] setKey: key toValue: value];
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
[keypairview_i display];
|
||||
|
||||
[self clearInputs];
|
||||
[quakeed_i updateXY];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-delPair:sender
|
||||
- (id) delPair: sender
|
||||
{
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
|
||||
[ [map_i currentEntity] removeKeyPair: (char *)[keyInput_i stringValue] ];
|
||||
[[map_i currentEntity] removeKeyPair: [[keyInput_i stringValue] cString]];
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
[keypairview_i display];
|
||||
|
@ -228,90 +229,78 @@ id things_i;
|
|||
return self;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Set the key/value fields to "angle <button value>"
|
||||
//
|
||||
- setAngle:sender
|
||||
// Set the key/value fields to "angle <button value>"
|
||||
- (id) setAngle: sender
|
||||
{
|
||||
const char *title;
|
||||
char value[10];
|
||||
|
||||
title = [[sender selectedCell] title];
|
||||
if (!strcmp(title,"Up"))
|
||||
strcpy (value, "-1");
|
||||
else if (!strcmp(title,"Dn"))
|
||||
strcpy (value, "-2");
|
||||
else
|
||||
strcpy (value, title);
|
||||
|
||||
[keyInput_i setStringValue:"angle"];
|
||||
[valueInput_i setStringValue:value];
|
||||
[self addPair:NULL];
|
||||
|
||||
NSString *value;
|
||||
|
||||
value = [[sender selectedCell] title];
|
||||
if (![value compare: @"Up"])
|
||||
value = @"-1";
|
||||
else if (![value compare: @"Dn"])
|
||||
value = @"-2";
|
||||
|
||||
[keyInput_i setStringValue: @"angle"];
|
||||
[valueInput_i setStringValue: value];
|
||||
[self addPair: NULL];
|
||||
|
||||
[self clearInputs];
|
||||
|
||||
[quakeed_i updateXY];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- setFlags:sender
|
||||
- (id) setFlags: sender
|
||||
{
|
||||
int flags;
|
||||
int r, c, i;
|
||||
id cell;
|
||||
char str[20];
|
||||
|
||||
int flags;
|
||||
int r, c, i;
|
||||
id cell;
|
||||
|
||||
[self clearInputs];
|
||||
flags = 0;
|
||||
|
||||
for (r=0 ; r<4 ; r++)
|
||||
for (c=0 ; c<3 ; c++)
|
||||
{
|
||||
cell = [flags_i cellAt: r : c];
|
||||
for (r = 0; r < 4; r++) {
|
||||
for (c = 0; c < 3; c++) {
|
||||
cell = [flags_i cellAtRow: r column: c];
|
||||
i = ([cell intValue] > 0);
|
||||
flags |= (i<< ((c*4)+r));
|
||||
flags |= (i << ((c * 4) + r));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!flags)
|
||||
[[map_i currentEntity] removeKeyPair: "spawnflags"];
|
||||
else
|
||||
{
|
||||
sprintf (str, "%i", flags);
|
||||
[[map_i currentEntity] setKey: "spawnflags" toValue: str];
|
||||
}
|
||||
|
||||
[[map_i currentEntity] setKey: "spawnflags" toValue: va ("%i", flags)];
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
[keypairview_i display];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Fill the Entity browser
|
||||
// (Delegate method - delegated in Interface Builder)
|
||||
//
|
||||
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
|
||||
// Fill the Entity browser
|
||||
// (Delegate method - delegated in Interface Builder)
|
||||
- (void) browser: sender
|
||||
createRowsForColumn: (int)column
|
||||
inMatrix: matrix
|
||||
{
|
||||
id cell;
|
||||
int max;
|
||||
int i;
|
||||
id object;
|
||||
|
||||
id cell;
|
||||
int max;
|
||||
int i;
|
||||
id object;
|
||||
|
||||
max = [entity_classes_i count];
|
||||
i = 0;
|
||||
while(max--)
|
||||
{
|
||||
object = [entity_classes_i objectAt:i];
|
||||
while (max--) {
|
||||
object = [entity_classes_i objectAtIndex: i];
|
||||
[matrix addRow];
|
||||
cell = [matrix cellAt:i++ :0];
|
||||
[cell setStringValue:[object classname]];
|
||||
[cell setLeaf:YES];
|
||||
[cell setLoaded:YES];
|
||||
cell = [matrix cellAtRow: i++ column: 0];
|
||||
[cell setStringValue: [NSString
|
||||
stringWithCString: [object classname]]];
|
||||
[cell setLeaf: YES];
|
||||
[cell setLoaded: YES];
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* UserPath.h by Bruce Blumberg, NeXT Computer, Inc.
|
||||
*
|
||||
* You may freely copy,distribute and re-use the code in this example. NeXT
|
||||
* disclaims any warranty of any kind, expressed or implied, as to its fitness
|
||||
* for any particular purpose
|
||||
*
|
||||
* This file and its associated .m file define a data structure and set of
|
||||
* functions aimed at facilitating the use of user paths. Here is a simple
|
||||
* example:
|
||||
*
|
||||
* UserPath *arect;
|
||||
* arect = newUserPath(); // creates an empty user path
|
||||
* beginUserPath(arect,YES); // initialize user path and cache
|
||||
* UPmoveto(arect,0.0,0.0); // add moveto to userpath; update bounding box
|
||||
* UPrlineto(arect,0.0,100.0); // add rlineto to path; update bounding box
|
||||
* UPrlineto(arect,100.0,0.0); // add rlineto to path; update bounding box
|
||||
* UPrlineto(arect,0.0,-100.0); // add rlineto to path; update bounding box
|
||||
* closePath(arect); // close path
|
||||
* endUserPath(arect,dps_stroke); // close user path and specify operator
|
||||
* sendUserPath(arect);
|
||||
*
|
||||
* As you will note, the set of routines manage the allocation and growth of
|
||||
* the operator and operand arrays, as well as the calculation of the bounding
|
||||
* box. A user path created via these functions may be optionally cached down
|
||||
* at the window server, or repeatedly sent down. The user paths created by
|
||||
* this set of functions are all allocated in a unique zone.
|
||||
*
|
||||
* Note: the associated file is a .m file because it pulls in some .h files
|
||||
* which reference objective C methods.
|
||||
*/
|
||||
|
||||
#include <objc/objc.h>
|
||||
#include <AppKit/NSGraphicsContext.h>
|
||||
|
||||
typedef struct _UP {
|
||||
float *points;
|
||||
int numberOfPoints;
|
||||
char *ops;
|
||||
NSPoint cp;
|
||||
int numberOfOps;
|
||||
int max;
|
||||
float bbox[4];
|
||||
int opForUserPath;
|
||||
BOOL ping;
|
||||
} UserPath;
|
||||
|
||||
/* UserPath functions */
|
||||
NSZone *userPathZone();
|
||||
UserPath *newUserPath();
|
||||
void freeUserPath(UserPath *up);
|
||||
void debugUserPath(UserPath *up, BOOL shouldPing);
|
||||
void growUserPath(UserPath *up);
|
||||
void beginUserPath(UserPath *up, BOOL cache);
|
||||
void endUserPath(UserPath *up, int op);
|
||||
int sendUserPath(UserPath *up);
|
||||
void UPmoveto(UserPath *up, float x, float y);
|
||||
void UPrmoveto(UserPath *up, float x, float y);
|
||||
void UPlineto(UserPath *up, float x, float y);
|
||||
void UPrlineto(UserPath *up, float x, float y);
|
||||
void UPcurveto(UserPath *up, float x1, float y1, float x2, float y2, float x3,
|
||||
float y3);
|
||||
void UPrcurveto(UserPath *up, float dx1, float dy1, float dx2, float dy2,
|
||||
float dx3, float dy3);
|
||||
void UParc(UserPath *up, float x, float y, float r, float ang1, float ang2);
|
||||
void UParcn(UserPath *up, float x, float y, float r, float ang1, float ang2);
|
||||
void UParct(UserPath *up, float x1, float y1, float x2, float y2, float r);
|
||||
void closePath(UserPath *up);
|
||||
void addPts(UserPath *up, float x, float y);
|
||||
void addOp(UserPath *up, int op);
|
||||
void add(UserPath *up, int op, float x, float y);
|
||||
void checkBBox(UserPath *up, float x, float y);
|
|
@ -1,209 +0,0 @@
|
|||
/*
|
||||
* UserPath.m by Bruce Blumberg, NeXT Computer, Inc.
|
||||
*
|
||||
* You may freely copy,distribute and re-use the code in this example. NeXT
|
||||
* disclaims any warranty of any kind, expressed or implied, as to its fitness
|
||||
* for any particular purpose
|
||||
*
|
||||
*/
|
||||
|
||||
#include "UserPath.h"
|
||||
#include <mach/mach_init.h>
|
||||
#include <appkit/graphics.h>
|
||||
#include <appkit/errors.h>
|
||||
#include <math.h>
|
||||
#include <libc.h>
|
||||
|
||||
static NSZone *upZone = NULL;
|
||||
|
||||
NSZone *userPathZone()
|
||||
/* Creates a unique zone for use by all user paths */
|
||||
{
|
||||
if (!upZone) {
|
||||
upZone = NSCreateZone(vm_page_size, vm_page_size, 1);
|
||||
}
|
||||
|
||||
return upZone;
|
||||
}
|
||||
|
||||
UserPath *newUserPath()
|
||||
/* Creates a new User Path in the zone returned by userPathZone */
|
||||
{
|
||||
UserPath *up;
|
||||
|
||||
up = (UserPath *)NSZoneMalloc(userPathZone(), sizeof(UserPath));
|
||||
up->max = 8192; // JDC
|
||||
up->points = (float *)NSZoneMalloc(userPathZone(),
|
||||
sizeof(float) * up->max);
|
||||
up->ops = (char *)NSZoneMalloc(userPathZone(),
|
||||
(2 + (up->max / 2)) * sizeof(char));
|
||||
up->ping = NO;
|
||||
|
||||
return up;
|
||||
}
|
||||
|
||||
void freeUserPath(UserPath *up)
|
||||
/* Frees User Path and its associated buffers */
|
||||
{
|
||||
free(up->points);
|
||||
free(up->ops);
|
||||
free(up);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void growUserPath(UserPath *up)
|
||||
/*
|
||||
* grows the associated buffers as necessary. buffer size doubles on each
|
||||
* call. You never need to call grow directly as it is called as needed by the
|
||||
* methods and functions which add elements into the buffer
|
||||
*/
|
||||
{
|
||||
/* double the size of the internal buffers */
|
||||
printf ("growUserPath\n");
|
||||
up->max *= 2;
|
||||
up->points = (float *)NSZoneRealloc(userPathZone(), up->points,
|
||||
sizeof(float) * up->max);
|
||||
up->ops = (char *)NSZoneRealloc(userPathZone(), up->ops,
|
||||
(2 + (up->max / 2)) * sizeof(char));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void beginUserPath(UserPath *up, BOOL cache)
|
||||
/*
|
||||
* Call this to start generating a user path. The cache argument specifies if
|
||||
* you want the user path cached at the server (i.e. dps_ucache). In either
|
||||
* case, the UserPath object will automatically calculate the bounding box for
|
||||
* the path and add the dps_setbbox operator.
|
||||
*/
|
||||
{
|
||||
up->numberOfPoints = up->numberOfOps = 0;
|
||||
up->cp.x = up->cp.y = 0;
|
||||
up->bbox[0] = up->bbox[1] = 1.0e6;
|
||||
up->bbox[2] = up->bbox[3] = -1.0e6;
|
||||
if (cache) {
|
||||
up->ops[up->numberOfOps++] = dps_ucache;
|
||||
}
|
||||
up->ops[up->numberOfOps++] = dps_setbbox;
|
||||
up->opForUserPath = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void endUserPath(UserPath *up, int op)
|
||||
/*
|
||||
* Call this to stop filling the path. Note this does not send the userpath to
|
||||
* the server -- use sendUserPath. The op argument should be one of the
|
||||
* following:
|
||||
* dps_uappend, dps_ufill ,dps_ueofill, dps_ustroke, dps_ustrokepath,
|
||||
* dps_inufill, dps_inueofill, dps_inustroke, dps_def, dps_put.
|
||||
* These are defined in <dpsclient/dpsNext.h.
|
||||
*/
|
||||
{
|
||||
up->opForUserPath = op;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void UPdebug(UserPath *up, BOOL shouldPing)
|
||||
/*
|
||||
* Sets ping to YES so that after each time a user path is sent down to the
|
||||
* window server, an NSPing() is sent after. The purpose is to catch PostScript
|
||||
* errors that may be generated by the user path. sendUserPath brackets the
|
||||
* download and the NSPing() in an NS_DURING... NS_HANDLER construct. Normally
|
||||
* ping is NO.
|
||||
*/
|
||||
{
|
||||
up->ping = shouldPing;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int sendUserPath(UserPath *up)
|
||||
/*
|
||||
* Call this to send the path down to the server. If ping==YES (set via
|
||||
* debug:), the function will send an NSPing() after the Path. In any event,
|
||||
* code is bracketed by a NS_DURING ... NS_HANDLER construct which will try to
|
||||
* catch postscript errors. If ping==NO (the default) it is unlikely to catch
|
||||
* errors, with ping==YES it will. Whether you can recover or not is another
|
||||
* matter. sendUserPath returns 0 on success and -1 on failure. If no previous
|
||||
* endUserPath: has been sent, will return -2 and will not send the path to the
|
||||
* server.
|
||||
*/
|
||||
{
|
||||
NSHandler exception;
|
||||
|
||||
exception.code = 0;
|
||||
if (up->opForUserPath != 0) {
|
||||
NS_DURING
|
||||
DPSDoUserPath(up->points, up->numberOfPoints, dps_float, up->ops,
|
||||
up->numberOfOps, up->bbox, up->opForUserPath);
|
||||
if (up->ping) {
|
||||
NSPing();
|
||||
}
|
||||
|
||||
NS_HANDLER
|
||||
exception = NSLocalHandler;
|
||||
NS_ENDHANDLER
|
||||
if (exception.code) {
|
||||
NSReportError(&exception);
|
||||
if (exception.code == dps_err_ps) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void UPmoveto(UserPath *up, float x, float y)
|
||||
/* adds <x y moveto> to user path and updates bounding box */
|
||||
{
|
||||
up->ops[up->numberOfOps++] = dps_moveto;
|
||||
up->points[up->numberOfPoints++] = x;
|
||||
up->points[up->numberOfPoints++] = y;
|
||||
|
||||
if (x < up->bbox[0]) {
|
||||
up->bbox[0] = x;
|
||||
}
|
||||
if (y < up->bbox[1]) {
|
||||
up->bbox[1] = y;
|
||||
}
|
||||
if (x > up->bbox[2]) {
|
||||
up->bbox[2] = x;
|
||||
}
|
||||
if (y > up->bbox[3]) {
|
||||
up->bbox[3] = y;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void UPlineto(UserPath *up, float x, float y)
|
||||
/* adds <x y lineto> to user path and updates bounding box */
|
||||
{
|
||||
up->ops[up->numberOfOps++] = dps_lineto;
|
||||
up->points[up->numberOfPoints++] = x;
|
||||
up->points[up->numberOfPoints++] = y;
|
||||
|
||||
if (x < up->bbox[0]) {
|
||||
up->bbox[0] = x;
|
||||
}
|
||||
if (y < up->bbox[1]) {
|
||||
up->bbox[1] = y;
|
||||
}
|
||||
if (x > up->bbox[2]) {
|
||||
up->bbox[2] = x;
|
||||
}
|
||||
if (y > up->bbox[3]) {
|
||||
up->bbox[3] = y;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -1,66 +1,82 @@
|
|||
#ifndef XYView_h
|
||||
#define XYView_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "mathlib.h"
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
#include "SetBrush.h"
|
||||
|
||||
extern id xyview_i;
|
||||
#include "render.h"
|
||||
|
||||
#define MINSCALE 0.125
|
||||
#define MAXSCALE 2.0
|
||||
extern id xyview_i;
|
||||
|
||||
#define MINSCALE 0.125
|
||||
#define MAXSCALE 2.0
|
||||
|
||||
extern vec3_t xy_viewnormal; // v_forward for xy view
|
||||
extern float xy_viewdist; // clip behind this plane
|
||||
extern vec3_t xy_viewnormal; // v_forward for xy view
|
||||
extern float xy_viewdist; // clip behind this plane
|
||||
|
||||
extern NSRect xy_draw_rect;
|
||||
extern NSRect xy_draw_rect;
|
||||
|
||||
void linestart (float r, float g, float b);
|
||||
void lineflush (void);
|
||||
void linecolor (float r, float g, float b);
|
||||
void linestart (float r, float g, float b);
|
||||
void lineflush (void);
|
||||
void linecolor (float r, float g, float b);
|
||||
|
||||
void XYmoveto (vec3_t pt);
|
||||
void XYlineto (vec3_t pt);
|
||||
void XYmoveto (vec3_t pt);
|
||||
void XYlineto (vec3_t pt);
|
||||
|
||||
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
|
||||
|
||||
|
||||
@interface XYView : NSView
|
||||
@interface XYView: NSView
|
||||
{
|
||||
NSRect realbounds, newrect, combinedrect;
|
||||
NSPoint midpoint;
|
||||
int gridsize;
|
||||
float scale;
|
||||
NSRect realbounds, newrect, combinedrect;
|
||||
NSPoint midpoint;
|
||||
int gridsize;
|
||||
float scale;
|
||||
|
||||
//
|
||||
// for textured view
|
||||
int xywidth, xyheight;
|
||||
float *xyzbuffer;
|
||||
unsigned *xypicbuffer;
|
||||
//
|
||||
int xywidth, xyheight;
|
||||
float *xyzbuffer;
|
||||
unsigned *xypicbuffer;
|
||||
|
||||
drawmode_t drawmode;
|
||||
drawmode_t drawmode;
|
||||
|
||||
//
|
||||
// UI links
|
||||
id mode_radio_i;
|
||||
//
|
||||
id mode_radio_i;
|
||||
}
|
||||
|
||||
- (float)currentScale;
|
||||
- (float) currentScale;
|
||||
|
||||
- setModeRadio: m;
|
||||
- (id) setModeRadio: m;
|
||||
|
||||
- drawMode: sender;
|
||||
- setDrawMode: (drawmode_t)mode;
|
||||
- (id) drawMode: sender;
|
||||
- (id) setDrawMode: (drawmode_t)mode;
|
||||
|
||||
- newSuperBounds;
|
||||
- newRealBounds: (NSRect *)nb;
|
||||
- (id) newSuperBounds;
|
||||
- (id) newRealBounds: (NSRect)nb;
|
||||
|
||||
- addToScrollRange: (float)x :(float)y;
|
||||
- setOrigin: (NSPoint *)pt scale: (float)sc;
|
||||
- centerOn: (vec3_t)org;
|
||||
- (id) addToScrollRange: (float)x
|
||||
: (float)y;
|
||||
|
||||
- drawMode: sender;
|
||||
- (id) setOrigin: (NSPoint)pt scale: (float)sc;
|
||||
|
||||
- superviewChanged;
|
||||
- (id) centerOn: (vec3_t)org;
|
||||
|
||||
- (int)gridsize;
|
||||
- (float)snapToGrid: (float)f;
|
||||
- (id) drawMode: sender;
|
||||
|
||||
- (id) superviewChanged;
|
||||
|
||||
- (int) gridsize;
|
||||
- (float) snapToGrid: (float)f;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSView (XYView)
|
||||
- (void) setFrame: (NSRect)frame
|
||||
bounds: (NSRect)bounds
|
||||
scale: (NSSize)scale;
|
||||
@end
|
||||
#endif // XYView_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,17 @@
|
|||
#ifndef ZScrollView_h
|
||||
#define ZScrollView_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
@interface ZScrollView : NSScrollView
|
||||
@interface ZScrollView: NSScrollView
|
||||
{
|
||||
id button1;
|
||||
id button1;
|
||||
}
|
||||
|
||||
- initFrame:(NSRect)frameRect button1: b1;
|
||||
- tile;
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
button1: b1;
|
||||
|
||||
- (id) tile;
|
||||
|
||||
@end
|
||||
#endif // ZScrollView_h
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "qedefs.h"
|
||||
#include "ZScrollView.h"
|
||||
|
||||
@implementation ZScrollView
|
||||
|
||||
/*
|
||||
====================
|
||||
initWithFrame: button:
|
||||
|
@ -9,23 +8,27 @@ initWithFrame: button:
|
|||
Initizes a scroll view with a button at it's lower right corner
|
||||
====================
|
||||
*/
|
||||
|
||||
- initWithFrame:(const NSRect *)frameRect button1:b1
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
button1: b1
|
||||
{
|
||||
[super initWithFrame: frameRect];
|
||||
[super initWithFrame: frameRect];
|
||||
|
||||
[self addSubview: b1];
|
||||
|
||||
button1 = b1;
|
||||
|
||||
[self setHorizScrollerRequired: YES];
|
||||
[self setVertScrollerRequired: YES];
|
||||
[self setHasHorizontalScroller: YES];
|
||||
[self setHasVerticalScroller: YES];
|
||||
|
||||
[self setBorderType: NSBezelBorder];
|
||||
|
||||
[self setBorderType: NS_BEZEL];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -34,38 +37,36 @@ tile
|
|||
Adjust the size for the pop up scale menu
|
||||
=================
|
||||
*/
|
||||
|
||||
- tile
|
||||
- (id) tile
|
||||
{
|
||||
NSRect scrollerframe;
|
||||
|
||||
NSRect scrollerframe;
|
||||
|
||||
[super tile];
|
||||
[_horizScroller getFrame: &scrollerframe];
|
||||
[button1 setFrame: &scrollerframe];
|
||||
|
||||
scrollerframe = [_horizScroller frame];
|
||||
[button1 setFrame: scrollerframe];
|
||||
|
||||
scrollerframe.size.width = 0;
|
||||
[_horizScroller setFrame: &scrollerframe];
|
||||
[_horizScroller setFrame: scrollerframe];
|
||||
[_horizScroller setHidden: YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(BOOL) acceptsFirstResponder
|
||||
- (BOOL) acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- superviewSizeChanged:(const NSSize *)oldSize
|
||||
#if 0
|
||||
- (id) superviewSizeChanged: (const NSSize *)oldSize
|
||||
{
|
||||
[super superviewSizeChanged: oldSize];
|
||||
|
||||
[[self docView] newSuperBounds];
|
||||
|
||||
|
||||
[[self documentView] newSuperBounds];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -1,42 +1,50 @@
|
|||
#ifndef ZView_h
|
||||
#define ZView_h
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "mathlib.h"
|
||||
|
||||
extern id zview_i;
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
#include "render.h"
|
||||
|
||||
extern id zview_i;
|
||||
|
||||
// zplane controls the objects displayed in the xyview
|
||||
extern float zplane;
|
||||
extern float zplanedir;
|
||||
extern float zplane;
|
||||
extern float zplanedir;
|
||||
|
||||
@interface ZView : NSView
|
||||
@interface ZView: NSView
|
||||
{
|
||||
float minheight, maxheight;
|
||||
float oldminheight, oldmaxheight;
|
||||
float topbound, bottombound; // for floor clipping
|
||||
|
||||
float scale;
|
||||
|
||||
vec3_t origin;
|
||||
float minheight, maxheight;
|
||||
float oldminheight, oldmaxheight;
|
||||
float topbound, bottombound; // for floor clipping
|
||||
|
||||
float scale;
|
||||
|
||||
vec3_t origin;
|
||||
|
||||
NSBezierPath *checker;
|
||||
}
|
||||
|
||||
- clearBounds;
|
||||
- getBounds: (float *)top :(float *)bottom;
|
||||
- (id) clearBounds;
|
||||
- (id) getBounds: (float *)top
|
||||
: (float *)bottom;
|
||||
|
||||
- getPoint: (NSPoint *)pt;
|
||||
- setPoint: (NSPoint *)pt;
|
||||
- (id) getPoint: (NSPoint *)pt;
|
||||
- (id) setPoint: (NSPoint *)pt;
|
||||
|
||||
- addToHeightRange: (float)height;
|
||||
- (id) addToHeightRange: (float)height;
|
||||
|
||||
- newRealBounds;
|
||||
- newSuperBounds;
|
||||
- (id) newRealBounds;
|
||||
- (id) newSuperBounds;
|
||||
|
||||
- XYDrawSelf;
|
||||
- (void) XYDrawSelf;
|
||||
|
||||
- (BOOL)XYmouseDown: (NSPoint *)pt;
|
||||
- (BOOL) XYmouseDown: (NSPoint *)pt;
|
||||
|
||||
- setXYOrigin: (NSPoint *)pt;
|
||||
- (id) setXYOrigin: (NSPoint *)pt;
|
||||
|
||||
- setOrigin: (NSPoint *)pt scale: (float)sc;
|
||||
- (id) setOrigin: (NSPoint)pt scale: (float)sc;
|
||||
|
||||
@end
|
||||
|
||||
#endif // ZView_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,611 +0,0 @@
|
|||
// cmdlib.c
|
||||
|
||||
#include "cmdlib.h"
|
||||
|
||||
#define PATHSEPERATOR '/'
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
I_FloatTime
|
||||
================
|
||||
*/
|
||||
double I_FloatTime (void)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday(&tp, &tzp);
|
||||
|
||||
if (!secbase)
|
||||
{
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
|
||||
}
|
||||
|
||||
|
||||
char com_token[1024];
|
||||
boolean com_eof;
|
||||
|
||||
/*
|
||||
==============
|
||||
COM_Parse
|
||||
|
||||
Parse a token out of a string
|
||||
==============
|
||||
*/
|
||||
char *COM_Parse (char *data)
|
||||
{
|
||||
int c;
|
||||
int len;
|
||||
|
||||
com_eof = false;
|
||||
|
||||
len = 0;
|
||||
com_token[0] = 0;
|
||||
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
// skip whitespace
|
||||
skipwhite:
|
||||
while ( (c = *data) <= ' ')
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
com_eof = true;
|
||||
return NULL; // end of file;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
|
||||
// skip // comments
|
||||
if (c=='/' && data[1] == '/')
|
||||
{
|
||||
while (*data && *data != '\n')
|
||||
data++;
|
||||
goto skipwhite;
|
||||
}
|
||||
|
||||
|
||||
// handle quoted strings specially
|
||||
if (c == '\"')
|
||||
{
|
||||
data++;
|
||||
do
|
||||
{
|
||||
c = *data++;
|
||||
if (c=='\"')
|
||||
{
|
||||
com_token[len] = 0;
|
||||
return data;
|
||||
}
|
||||
com_token[len] = c;
|
||||
len++;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
// parse single characters
|
||||
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
|
||||
{
|
||||
com_token[len] = c;
|
||||
len++;
|
||||
com_token[len] = 0;
|
||||
return data+1;
|
||||
}
|
||||
|
||||
// parse a regular word
|
||||
do
|
||||
{
|
||||
com_token[len] = c;
|
||||
data++;
|
||||
len++;
|
||||
c = *data;
|
||||
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
|
||||
break;
|
||||
} while (c>32);
|
||||
|
||||
com_token[len] = 0;
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
=
|
||||
= filelength
|
||||
=
|
||||
================
|
||||
*/
|
||||
|
||||
int filelength (int handle)
|
||||
{
|
||||
struct stat fileinfo;
|
||||
|
||||
if (fstat (handle,&fileinfo) == -1)
|
||||
{
|
||||
fprintf (stderr,"Error fstating");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return fileinfo.st_size;
|
||||
}
|
||||
|
||||
int tell (int handle)
|
||||
{
|
||||
return lseek (handle, 0, L_INCR);
|
||||
}
|
||||
|
||||
char *strupr (char *start)
|
||||
{
|
||||
char *in;
|
||||
in = start;
|
||||
while (*in)
|
||||
{
|
||||
*in = toupper(*in);
|
||||
in++;
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
char *strlower (char *start)
|
||||
{
|
||||
char *in;
|
||||
in = start;
|
||||
while (*in)
|
||||
{
|
||||
*in = tolower(*in);
|
||||
in++;
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
char *getcwd (char *path, int length)
|
||||
{
|
||||
return getwd(path);
|
||||
}
|
||||
|
||||
|
||||
/* globals for command line args */
|
||||
extern int NXArgc;
|
||||
extern char **NXArgv;
|
||||
#define myargc NXArgc
|
||||
#define myargv NXArgv
|
||||
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
MISC FUNCTIONS
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
=
|
||||
= CheckParm
|
||||
=
|
||||
= Checks for the given parameter in the program's command line arguments
|
||||
=
|
||||
= Returns the argument number (1 to argc-1) or 0 if not present
|
||||
=
|
||||
=================
|
||||
*/
|
||||
|
||||
int CheckParm (char *check)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1;i<myargc;i++)
|
||||
{
|
||||
if ( !stricmp(check, myargv[i]) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int SafeOpenWrite (char *filename)
|
||||
{
|
||||
int handle;
|
||||
|
||||
umask (0);
|
||||
|
||||
handle = open(filename,O_RDWR | O_CREAT | O_TRUNC
|
||||
, 0666);
|
||||
|
||||
if (handle == -1)
|
||||
Error ("Error opening %s: %s",filename,strerror(errno));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
int SafeOpenRead (char *filename)
|
||||
{
|
||||
int handle;
|
||||
|
||||
handle = open(filename,O_RDONLY);
|
||||
|
||||
if (handle == -1)
|
||||
Error ("Error opening %s: %s",filename,strerror(errno));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
void SafeRead (int handle, void *buffer, long count)
|
||||
{
|
||||
int iocount;
|
||||
|
||||
iocount = read (handle,buffer,count);
|
||||
if (iocount != count)
|
||||
Error ("File read failure");
|
||||
}
|
||||
|
||||
|
||||
void SafeWrite (int handle, void *buffer, long count)
|
||||
{
|
||||
int iocount;
|
||||
|
||||
iocount = write (handle,buffer,count);
|
||||
if (iocount != count)
|
||||
Error ("File write failure");
|
||||
}
|
||||
|
||||
|
||||
void *SafeMalloc (long size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
ptr = malloc (size);
|
||||
|
||||
if (!ptr)
|
||||
Error ("Malloc failure for %lu bytes",size);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
=
|
||||
= LoadFile
|
||||
=
|
||||
= appends a 0 byte
|
||||
==============
|
||||
*/
|
||||
|
||||
long LoadFile (char *filename, void **bufferptr)
|
||||
{
|
||||
int handle;
|
||||
long length;
|
||||
void *buffer;
|
||||
|
||||
handle = SafeOpenRead (filename);
|
||||
length = filelength (handle);
|
||||
buffer = SafeMalloc (length+1);
|
||||
((char *)buffer)[length] = 0;
|
||||
SafeRead (handle, buffer, length);
|
||||
close (handle);
|
||||
|
||||
*bufferptr = buffer;
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
=
|
||||
= SaveFile
|
||||
=
|
||||
==============
|
||||
*/
|
||||
|
||||
void SaveFile (char *filename, void *buffer, long count)
|
||||
{
|
||||
int handle;
|
||||
|
||||
handle = SafeOpenWrite (filename);
|
||||
SafeWrite (handle, buffer, count);
|
||||
close (handle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DefaultExtension (char *path, char *extension)
|
||||
{
|
||||
char *src;
|
||||
//
|
||||
// if path doesn't have a .EXT, append extension
|
||||
// (extension should include the .)
|
||||
//
|
||||
src = path + strlen(path) - 1;
|
||||
|
||||
while (*src != PATHSEPERATOR && src != path)
|
||||
{
|
||||
if (*src == '.')
|
||||
return; // it has an extension
|
||||
src--;
|
||||
}
|
||||
|
||||
strcat (path, extension);
|
||||
}
|
||||
|
||||
|
||||
void DefaultPath (char *path, char *basepath)
|
||||
{
|
||||
char temp[128];
|
||||
|
||||
if (path[0] == PATHSEPERATOR)
|
||||
return; // absolute path location
|
||||
strcpy (temp,path);
|
||||
strcpy (path,basepath);
|
||||
strcat (path,temp);
|
||||
}
|
||||
|
||||
|
||||
void StripFilename (char *path)
|
||||
{
|
||||
int length;
|
||||
|
||||
length = strlen(path)-1;
|
||||
while (length > 0 && path[length] != PATHSEPERATOR)
|
||||
length--;
|
||||
path[length] = 0;
|
||||
}
|
||||
|
||||
void StripExtension (char *path)
|
||||
{
|
||||
int length;
|
||||
|
||||
length = strlen(path)-1;
|
||||
while (length > 0 && path[length] != '.')
|
||||
length--;
|
||||
if (length)
|
||||
path[length] = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= Extract file parts
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
void ExtractFilePath (char *path, char *dest)
|
||||
{
|
||||
char *src;
|
||||
|
||||
src = path + strlen(path) - 1;
|
||||
|
||||
//
|
||||
// back up until a \ or the start
|
||||
//
|
||||
while (src != path && *(src-1) != PATHSEPERATOR)
|
||||
src--;
|
||||
|
||||
memcpy (dest, path, src-path);
|
||||
dest[src-path] = 0;
|
||||
}
|
||||
|
||||
void ExtractFileBase (char *path, char *dest)
|
||||
{
|
||||
char *src;
|
||||
|
||||
src = path + strlen(path) - 1;
|
||||
|
||||
//
|
||||
// back up until a \ or the start
|
||||
//
|
||||
while (src != path && *(src-1) != PATHSEPERATOR)
|
||||
src--;
|
||||
|
||||
while (*src && *src != '.')
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
void ExtractFileExtension (char *path, char *dest)
|
||||
{
|
||||
char *src;
|
||||
|
||||
src = path + strlen(path) - 1;
|
||||
|
||||
//
|
||||
// back up until a . or the start
|
||||
//
|
||||
while (src != path && *(src-1) != '.')
|
||||
src--;
|
||||
if (src == path)
|
||||
{
|
||||
*dest = 0; // no extension
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy (dest,src);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
=
|
||||
= ParseNum / ParseHex
|
||||
=
|
||||
==============
|
||||
*/
|
||||
|
||||
long ParseHex (char *hex)
|
||||
{
|
||||
char *str;
|
||||
long num;
|
||||
|
||||
num = 0;
|
||||
str = hex;
|
||||
|
||||
while (*str)
|
||||
{
|
||||
num <<= 4;
|
||||
if (*str >= '0' && *str <= '9')
|
||||
num += *str-'0';
|
||||
else if (*str >= 'a' && *str <= 'f')
|
||||
num += 10 + *str-'a';
|
||||
else if (*str >= 'A' && *str <= 'F')
|
||||
num += 10 + *str-'A';
|
||||
else
|
||||
Error ("Bad hex number: %s",hex);
|
||||
str++;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
long ParseNum (char *str)
|
||||
{
|
||||
if (str[0] == '$')
|
||||
return ParseHex (str+1);
|
||||
if (str[0] == '0' && str[1] == 'x')
|
||||
return ParseHex (str+2);
|
||||
return atol (str);
|
||||
}
|
||||
|
||||
|
||||
int GetKey (void)
|
||||
{
|
||||
return getchar ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
||||
BYTE ORDER FUNCTIONS
|
||||
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
|
||||
short LittleShort (short l)
|
||||
{
|
||||
byte b1,b2;
|
||||
|
||||
b1 = l&255;
|
||||
b2 = (l>>8)&255;
|
||||
|
||||
return (b1<<8) + b2;
|
||||
}
|
||||
|
||||
short BigShort (short l)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
long LittleLong (long l)
|
||||
{
|
||||
byte b1,b2,b3,b4;
|
||||
|
||||
b1 = l&255;
|
||||
b2 = (l>>8)&255;
|
||||
b3 = (l>>16)&255;
|
||||
b4 = (l>>24)&255;
|
||||
|
||||
return ((long)b1<<24) + ((long)b2<<16) + ((long)b3<<8) + b4;
|
||||
}
|
||||
|
||||
long BigLong (long l)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
float LittleFloat (float l)
|
||||
{
|
||||
union {byte b[4]; float f;} in, out;
|
||||
|
||||
in.f = l;
|
||||
out.b[0] = in.b[3];
|
||||
out.b[1] = in.b[2];
|
||||
out.b[2] = in.b[1];
|
||||
out.b[3] = in.b[0];
|
||||
|
||||
return out.f;
|
||||
}
|
||||
|
||||
float BigFloat (float l)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
short BigShort (short l)
|
||||
{
|
||||
byte b1,b2;
|
||||
|
||||
b1 = l&255;
|
||||
b2 = (l>>8)&255;
|
||||
|
||||
return (b1<<8) + b2;
|
||||
}
|
||||
|
||||
short LittleShort (short l)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
long BigLong (long l)
|
||||
{
|
||||
byte b1,b2,b3,b4;
|
||||
|
||||
b1 = l&255;
|
||||
b2 = (l>>8)&255;
|
||||
b3 = (l>>16)&255;
|
||||
b4 = (l>>24)&255;
|
||||
|
||||
return ((long)b1<<24) + ((long)b2<<16) + ((long)b3<<8) + b4;
|
||||
}
|
||||
|
||||
long LittleLong (long l)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
float BigFloat (float l)
|
||||
{
|
||||
union {byte b[4]; float f;} in, out;
|
||||
|
||||
in.f = l;
|
||||
out.b[0] = in.b[3];
|
||||
out.b[1] = in.b[2];
|
||||
out.b[2] = in.b[1];
|
||||
out.b[3] = in.b[0];
|
||||
|
||||
return out.f;
|
||||
}
|
||||
|
||||
float LittleFloat (float l)
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
// cmdlib.h
|
||||
|
||||
#ifndef __CMDLIB__
|
||||
#define __CMDLIB__
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define strcmpi strcasecmp
|
||||
#define stricmp strcasecmp
|
||||
char *strupr (char *in);
|
||||
char *strlower (char *in);
|
||||
int filelength (int handle);
|
||||
int tell (int handle);
|
||||
|
||||
#ifndef __BYTEBOOL__
|
||||
#define __BYTEBOOL__
|
||||
typedef enum {false, true} boolean;
|
||||
typedef unsigned char byte;
|
||||
#endif
|
||||
|
||||
double I_FloatTime (void);
|
||||
|
||||
int GetKey (void);
|
||||
|
||||
void Error (char *error, ...);
|
||||
int CheckParm (char *check);
|
||||
|
||||
int SafeOpenWrite (char *filename);
|
||||
int SafeOpenRead (char *filename);
|
||||
void SafeRead (int handle, void *buffer, long count);
|
||||
void SafeWrite (int handle, void *buffer, long count);
|
||||
void *SafeMalloc (long size);
|
||||
|
||||
long LoadFile (char *filename, void **bufferptr);
|
||||
void SaveFile (char *filename, void *buffer, long count);
|
||||
|
||||
void DefaultExtension (char *path, char *extension);
|
||||
void DefaultPath (char *path, char *basepath);
|
||||
void StripFilename (char *path);
|
||||
void StripExtension (char *path);
|
||||
|
||||
void ExtractFilePath (char *path, char *dest);
|
||||
void ExtractFileBase (char *path, char *dest);
|
||||
void ExtractFileExtension (char *path, char *dest);
|
||||
|
||||
long ParseNum (char *str);
|
||||
|
||||
short BigShort (short l);
|
||||
short LittleShort (short l);
|
||||
long BigLong (long l);
|
||||
long LittleLong (long l);
|
||||
float BigFloat (float l);
|
||||
float LittleFloat (float l);
|
||||
|
||||
extern char com_token[1024];
|
||||
extern boolean com_eof;
|
||||
|
||||
char *COM_Parse (char *data);
|
||||
|
||||
#endif
|
|
@ -1,93 +0,0 @@
|
|||
// mathlib.c -- math primitives
|
||||
|
||||
#include "mathlib.h"
|
||||
#include <math.h>
|
||||
|
||||
vec3_t vec3_origin = {0,0,0};
|
||||
|
||||
double VectorLength(vec3_t v)
|
||||
{
|
||||
int i;
|
||||
double length;
|
||||
|
||||
length = 0;
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
length += v[i]*v[i];
|
||||
length = sqrt (length); // FIXME
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc)
|
||||
{
|
||||
vc[0] = va[0] + scale*vb[0];
|
||||
vc[1] = va[1] + scale*vb[1];
|
||||
vc[2] = va[2] + scale*vb[2];
|
||||
}
|
||||
|
||||
boolean VectorCompare (vec3_t v1, vec3_t v2)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
if (v1[i] != v2[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)
|
||||
{
|
||||
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
|
||||
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
|
||||
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
||||
}
|
||||
|
||||
vec_t _DotProduct (vec3_t v1, vec3_t v2)
|
||||
{
|
||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
||||
}
|
||||
|
||||
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)
|
||||
{
|
||||
out[0] = va[0]-vb[0];
|
||||
out[1] = va[1]-vb[1];
|
||||
out[2] = va[2]-vb[2];
|
||||
}
|
||||
|
||||
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)
|
||||
{
|
||||
out[0] = va[0]+vb[0];
|
||||
out[1] = va[1]+vb[1];
|
||||
out[2] = va[2]+vb[2];
|
||||
}
|
||||
|
||||
void _VectorCopy (vec3_t in, vec3_t out)
|
||||
{
|
||||
out[0] = in[0];
|
||||
out[1] = in[1];
|
||||
out[2] = in[2];
|
||||
}
|
||||
|
||||
void VectorNormalize (vec3_t v)
|
||||
{
|
||||
int i;
|
||||
float length;
|
||||
|
||||
length = 0;
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
length += v[i]*v[i];
|
||||
length = sqrt (length);
|
||||
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
v[i] /= length;
|
||||
}
|
||||
|
||||
void VectorScale (vec3_t v, vec_t scale, vec3_t out)
|
||||
{
|
||||
out[0] = v[0] * scale;
|
||||
out[1] = v[1] * scale;
|
||||
out[2] = v[2] * scale;
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
#ifndef __MATHLIB__
|
||||
#define __MATHLIB__
|
||||
|
||||
#include "cmdlib.h"
|
||||
|
||||
// mathlib.h
|
||||
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec3_t[3];
|
||||
|
||||
extern vec3_t vec3_origin;
|
||||
|
||||
boolean VectorCompare (vec3_t v1, vec3_t v2);
|
||||
|
||||
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
|
||||
#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
|
||||
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
|
||||
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
|
||||
|
||||
vec_t _DotProduct (vec3_t v1, vec3_t v2);
|
||||
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
|
||||
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
|
||||
void _VectorCopy (vec3_t in, vec3_t out);
|
||||
|
||||
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
|
||||
void VectorNormalize (vec3_t v);
|
||||
void VectorScale (vec3_t v, vec_t scale, vec3_t out);
|
||||
double VectorLength(vec3_t v);
|
||||
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc);
|
||||
|
||||
#endif
|
|
@ -1,274 +0,0 @@
|
|||
|
||||
#include "qedefs.h"
|
||||
|
||||
|
||||
char token[MAXTOKEN];
|
||||
boolean unget;
|
||||
char *script_p;
|
||||
int scriptline;
|
||||
|
||||
void StartTokenParsing (char *data)
|
||||
{
|
||||
scriptline = 1;
|
||||
script_p = data;
|
||||
unget = false;
|
||||
}
|
||||
|
||||
boolean GetToken (boolean crossline)
|
||||
{
|
||||
char *token_p;
|
||||
|
||||
if (unget) // is a token allready waiting?
|
||||
return true;
|
||||
|
||||
//
|
||||
// skip space
|
||||
//
|
||||
skipspace:
|
||||
while (*script_p <= 32)
|
||||
{
|
||||
if (!*script_p)
|
||||
{
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete",scriptline);
|
||||
return false;
|
||||
}
|
||||
if (*script_p++ == '\n')
|
||||
{
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete",scriptline);
|
||||
scriptline++;
|
||||
}
|
||||
}
|
||||
|
||||
if (script_p[0] == '/' && script_p[1] == '/') // comment field
|
||||
{
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete\n",scriptline);
|
||||
while (*script_p++ != '\n')
|
||||
if (!*script_p)
|
||||
{
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete",scriptline);
|
||||
return false;
|
||||
}
|
||||
goto skipspace;
|
||||
}
|
||||
|
||||
//
|
||||
// copy token
|
||||
//
|
||||
token_p = token;
|
||||
|
||||
if (*script_p == '"')
|
||||
{
|
||||
script_p++;
|
||||
while ( *script_p != '"' )
|
||||
{
|
||||
if (!*script_p)
|
||||
Error ("EOF inside quoted token");
|
||||
*token_p++ = *script_p++;
|
||||
if (token_p == &token[MAXTOKEN])
|
||||
Error ("Token too large on line %i",scriptline);
|
||||
}
|
||||
script_p++;
|
||||
}
|
||||
else while ( *script_p > 32 )
|
||||
{
|
||||
*token_p++ = *script_p++;
|
||||
if (token_p == &token[MAXTOKEN])
|
||||
Error ("Token too large on line %i",scriptline);
|
||||
}
|
||||
|
||||
*token_p = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UngetToken ()
|
||||
{
|
||||
unget = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsprintf (string, fmt,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
[g_cmd_out_i setStringValue: [NSString stringWithCString: string]];
|
||||
//NSPing ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Error
|
||||
|
||||
For abnormal program terminations
|
||||
=================
|
||||
*/
|
||||
BOOL in_error;
|
||||
void Error (char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
if (in_error)
|
||||
[NSApp terminate: NULL];
|
||||
in_error = YES;
|
||||
|
||||
va_start (argptr,error);
|
||||
vsprintf (string,error,argptr);
|
||||
va_end (argptr);
|
||||
|
||||
strcat (string, "\nmap saved to "FN_CRASHSAVE);
|
||||
|
||||
[map_i writeMapFile: FN_CRASHSAVE useRegion: NO];
|
||||
NSRunAlertPanel (@"Error", [NSString stringWithCString: string],NULL,NULL,NULL);
|
||||
|
||||
[NSApp terminate: NULL];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CleanupName (char *in, char *out)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i< 16 ; i++ )
|
||||
{
|
||||
if (!in[i])
|
||||
break;
|
||||
|
||||
out[i] = toupper(in[i]);
|
||||
}
|
||||
|
||||
for ( ; i< 16 ; i++ )
|
||||
out[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
void PrintRect (NSRect *r)
|
||||
{
|
||||
printf ("(%4.0f, %4.0f) + (%4.0f, %4.0f) = (%4.0f,%4.0f)\n"
|
||||
,r->origin.x,r->origin.y,
|
||||
r->size.width, r->size.height, r->origin.x+r->size.width,
|
||||
r->origin.y+r->size.height);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
FileTime
|
||||
|
||||
returns -1 if not present
|
||||
============
|
||||
*/
|
||||
int FileTime (char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (stat (path,&buf) == -1)
|
||||
return -1;
|
||||
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
CreatePath
|
||||
============
|
||||
*/
|
||||
void CreatePath (char *path)
|
||||
{
|
||||
char *ofs;
|
||||
|
||||
for (ofs = path+1 ; *ofs ; ofs++)
|
||||
{
|
||||
if (*ofs == '/')
|
||||
{ // create the directory
|
||||
*ofs = 0;
|
||||
mkdir (path,0777);
|
||||
*ofs = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int I_FileOpenRead (char *path, int *handle)
|
||||
{
|
||||
int h;
|
||||
struct stat fileinfo;
|
||||
|
||||
|
||||
h = open (path, O_RDONLY, 0666);
|
||||
*handle = h;
|
||||
if (h == -1)
|
||||
return -1;
|
||||
|
||||
if (fstat (h,&fileinfo) == -1)
|
||||
Error ("Error fstating %s", path);
|
||||
|
||||
return fileinfo.st_size;
|
||||
}
|
||||
|
||||
int I_FileOpenWrite (char *path)
|
||||
{
|
||||
int handle;
|
||||
|
||||
umask (0);
|
||||
|
||||
handle = open(path,O_RDWR | O_CREAT | O_TRUNC
|
||||
, 0666);
|
||||
|
||||
if (handle == -1)
|
||||
Error ("Error opening %s: %s", path,strerror(errno));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Sys_UpdateFile
|
||||
|
||||
Copies a more recent net file to the local drive
|
||||
============
|
||||
*/
|
||||
void Sys_UpdateFile (char *path, char *netpath)
|
||||
{
|
||||
int ltime, ntime;
|
||||
int in, out, size;
|
||||
char *buf;
|
||||
|
||||
ltime = FileTime (path);
|
||||
ntime = FileTime (netpath);
|
||||
|
||||
if (ntime <= ltime)
|
||||
return; // up to date
|
||||
|
||||
// copy the file
|
||||
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
|
||||
|
||||
size = I_FileOpenRead (netpath, &in);
|
||||
buf = malloc (size);
|
||||
if (read (in, buf, size) != size)
|
||||
Error ("UpdateFile: couldn't read all of %s", netpath);
|
||||
close (in);
|
||||
|
||||
CreatePath (path);
|
||||
out = I_FileOpenWrite (path);
|
||||
write (out, buf, size);
|
||||
close (out);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/dir.h>
|
||||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
#include "UserPath.h"
|
||||
#include "cmdlib.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
#include "EntityClass.h"
|
||||
#include "Project.h"
|
||||
#include "QuakeEd.h"
|
||||
#include "Map.h"
|
||||
#include "TexturePalette.h"
|
||||
#include "SetBrush.h"
|
||||
#include "render.h"
|
||||
#include "Entity.h"
|
||||
|
||||
#include "XYView.h"
|
||||
#include "CameraView.h"
|
||||
#include "ZView.h"
|
||||
#include "ZScrollView.h"
|
||||
#include "Preferences.h"
|
||||
#include "InspectorControl.h"
|
||||
#include "PopScrollView.h"
|
||||
#include "KeypairView.h"
|
||||
#include "Things.h"
|
||||
#include "TextureView.h"
|
||||
#include "Clipper.h"
|
||||
|
||||
|
||||
void PrintRect (NSRect *r);
|
||||
int FileTime (char *path);
|
||||
void Sys_UpdateFile (char *path, char *netpath);
|
||||
void CleanupName (char *in, char *out);
|
||||
|
||||
extern BOOL in_error;
|
||||
void Error (char *error, ...);
|
||||
|
||||
#define MAXTOKEN 128
|
||||
extern char token[MAXTOKEN];
|
||||
extern int scriptline;
|
||||
void StartTokenParsing (char *data);
|
||||
boolean GetToken (boolean crossline); // returns false at eof
|
||||
void UngetToken ();
|
||||
|
||||
|
||||
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
|
||||
#define FN_TEMPSAVE "/qcache/temp.map"
|
||||
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
||||
#define FN_CRASHSAVE "/qcache/ErrorSaveMap.map"
|
||||
#define FN_DEVLOG "/qcache/devlog"
|
||||
|
|
@ -1,13 +1,83 @@
|
|||
{
|
||||
{"basepath" "/raid/quake/id1"}
|
||||
{"maps" "jrbase1 jrbase2 jrbase4 jrwiz1 jrwiz2 jrdungn jrmed1 jrmed2 jrstart tim4 tim5 tim6 tim7 tim9 tboss amtest98 ammap2 amtest1 amdm3 amdem1 ammet2 amlev13 ammech3 schurch smotte sramp2 scath sally spit stemple"}
|
||||
{"desc" "jrbase1 jrbase2 jrbase4 jrwiz1 jrwiz2 jrdungn jrmed1 jrmed2 jrstart tim4 tim5 tim6 tim7 tim9 tboss amtest98 ammap2 amtest1 amdm3 amdem1 ammet2 amlev13 ammech3 schurch smotte sramp2 scath sally spit stemple"}
|
||||
{"wads" "gfx/medieval.wad gfx/base.wad gfx/wizard.wad gfx/metal.wad gfx/tim.wad gfx/items.wad gfx/start.wad"}
|
||||
"basepath" = "/raid/quake/id1";
|
||||
"maps" = (
|
||||
"jrbase1",
|
||||
"jrbase2",
|
||||
"jrbase4",
|
||||
"jrwiz1",
|
||||
"jrwiz2",
|
||||
"jrdungn",
|
||||
"jrmed1",
|
||||
"jrmed2",
|
||||
"jrstart",
|
||||
"tim4",
|
||||
"tim5",
|
||||
"tim6",
|
||||
"tim7",
|
||||
"tim9",
|
||||
"tboss",
|
||||
"amtest98",
|
||||
"ammap2",
|
||||
"amtest1",
|
||||
"amdm3",
|
||||
"amdem1",
|
||||
"ammet2",
|
||||
"amlev13",
|
||||
"ammech3",
|
||||
"schurch",
|
||||
"smotte",
|
||||
"sramp2",
|
||||
"scath",
|
||||
"sally",
|
||||
"spit",
|
||||
"stemple"
|
||||
);
|
||||
"desc" = (
|
||||
"jrbase1",
|
||||
"jrbase2",
|
||||
"jrbase4",
|
||||
"jrwiz1",
|
||||
"jrwiz2",
|
||||
"jrdungn",
|
||||
"jrmed1",
|
||||
"jrmed2",
|
||||
"jrstart",
|
||||
"tim4",
|
||||
"tim5",
|
||||
"tim6",
|
||||
"tim7",
|
||||
"tim9",
|
||||
"tboss",
|
||||
"amtest98",
|
||||
"ammap2",
|
||||
"amtest1",
|
||||
"amdm3",
|
||||
"amdem1",
|
||||
"ammet2",
|
||||
"amlev13",
|
||||
"ammech3",
|
||||
"schurch",
|
||||
"smotte",
|
||||
"sramp2",
|
||||
"scath",
|
||||
"sally",
|
||||
"spit",
|
||||
"stemple"
|
||||
);
|
||||
"wads" = (
|
||||
"gfx/medieval.wad",
|
||||
"gfx/base.wad",
|
||||
"gfx/wizard.wad",
|
||||
"gfx/metal.wad",
|
||||
"gfx/tim.wad",
|
||||
"gfx/items.wad",
|
||||
"gfx/start.wad"
|
||||
);
|
||||
|
||||
{"bspfullvis" "rsh satan @/LocalApps/qbsp $1 $2 ; /LocalApps/light -extra $2 ; /LocalApps/vis $2@"}
|
||||
{"bspfastvis" "rsh satan @/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis -fast $2@"}
|
||||
{"bspnovis" "rsh satan @/LocalApps/qbsp $1 $2 ; /LocalApps/light $2@"}
|
||||
{"bsprelight" "rsh satan @/LocalApps/qbsp -onlyents $1 $2 ; /LocalApps/light -extra $2@"}
|
||||
{"bspleaktest" "rsh satan @/LocalApps/qbsp -mark -notjunc $1 $2 ; /LocalApps/light $2@"}
|
||||
{"bspentities" "rsh satan @/LocalApps/qbsp -onlyents $1 $2@"}
|
||||
"bspfullvis" = "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light -extra $2 ; /LocalApps/vis $2\"";
|
||||
"bspfastvis" = "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis -fast $2\"";
|
||||
"bspnovis" = "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2\"";
|
||||
"bsprelight" = "rsh satan \"/LocalApps/qbsp -onlyents $1 $2 ; /LocalApps/light -extra $2\"";
|
||||
"bspleaktest" = "rsh satan \"/LocalApps/qbsp -mark -notjunc $1 $2 ; /LocalApps/light $2\"";
|
||||
"bspentities" = "rsh satan \"/LocalApps/qbsp -onlyents $1 $2\"";
|
||||
}
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
#ifndef render_h
|
||||
#define render_h
|
||||
|
||||
extern int r_width, r_height;
|
||||
extern unsigned *r_picbuffer;
|
||||
extern float *r_zbuffer;
|
||||
#include "SetBrush.h"
|
||||
|
||||
extern vec3_t r_origin, r_matrix[3];
|
||||
extern BOOL r_drawflat;
|
||||
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
|
||||
|
||||
extern int r_width, r_height;
|
||||
extern unsigned *r_picbuffer;
|
||||
extern float *r_zbuffer;
|
||||
|
||||
extern vec3_t r_origin, r_matrix[3];
|
||||
extern BOOL r_drawflat;
|
||||
|
||||
void REN_ClearBuffers (void);
|
||||
void REN_DrawCameraFace (face_t *idpol);
|
||||
void REN_DrawXYFace (face_t *idpol);
|
||||
void REN_DrawCameraFace (face_t * idpol);
|
||||
void REN_DrawXYFace (face_t * idpol);
|
||||
void REN_BeginCamera (void);
|
||||
void REN_BeginXY (void);
|
||||
|
||||
#endif // render_h
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -204,7 +204,7 @@ static const char rcsid[] =
|
|||
return;
|
||||
}
|
||||
|
||||
[[(id <ForgeBundle>) [aBundle principalClass] alloc] initWithOwner: self];
|
||||
[(id <ForgeBundle>) [[aBundle principalClass] alloc] initWithOwner: self];
|
||||
}
|
||||
|
||||
- (PrefsController *) prefsController;
|
||||
|
|
|
@ -37,6 +37,7 @@ ADDITIONAL_WO_LIBS +=
|
|||
|
||||
# Additional directories to be created during installation
|
||||
ADDITIONAL_INSTALL_DIRS += \
|
||||
$(GNUSTEP_LOCAL_DIR)/Library/Forge \
|
||||
$(GNUSTEP_NETWORK_DIR)/Library/Forge \
|
||||
$(GNUSTEP_SYSTEM_DIR)/Library/Forge
|
||||
$(GNUSTEP_USER_DIR)/$(GNUSTEP_USER_DIR_LIBRARY)/Forge \
|
||||
$(GNUSTEP_LOCAL_LIBRARY)/Forge \
|
||||
$(GNUSTEP_NETWORK_LIBRARY)/Forge \
|
||||
$(GNUSTEP_SYSTEM_LIBRARY)/Forge
|
||||
|
|
|
@ -191,7 +191,8 @@ ParseVerts (int *n_verts)
|
|||
|
||||
if (map_script->token->str[0] != ':')
|
||||
map_error ("parsing brush");
|
||||
*n_verts = atoi (map_script->token->str + 1);
|
||||
Script_GetToken (map_script, false);
|
||||
*n_verts = atoi (map_script->token->str);
|
||||
verts = malloc (sizeof (vec3_t) * *n_verts);
|
||||
|
||||
for (i = 0; i < *n_verts; i++) {
|
||||
|
|
|
@ -834,7 +834,8 @@ progs_src_compile (void)
|
|||
else
|
||||
dsprintf (qc_filename, "%s", script->token->str);
|
||||
if (options.verbosity >= 2)
|
||||
printf ("%s:%d: compiling %s\n", script->file, script->line, qc_filename->str);
|
||||
printf ("%s:%d: compiling %s\n", script->file, script->line,
|
||||
qc_filename->str);
|
||||
|
||||
if (single) {
|
||||
fprintf (single, "$frame_reset\n");
|
||||
|
|
|
@ -186,8 +186,8 @@ LoadEntities (void)
|
|||
// go through all the entities
|
||||
while (Script_GetToken (script, 1)) {
|
||||
// parse the opening brace
|
||||
if (script->token->str[0] != '{')
|
||||
fprintf (stderr, "LoadEntities: found %s when expecting {",
|
||||
if (strcmp (script->token->str, "{"))
|
||||
fprintf (stderr, "LoadEntities: found %s when expecting {\n",
|
||||
script->token->str);
|
||||
|
||||
if (num_entities == max_entities) {
|
||||
|
@ -220,7 +220,7 @@ LoadEntities (void)
|
|||
// FIXME shouldn't cross line
|
||||
if (!Script_GetToken (script, 1))
|
||||
fprintf (stderr, "LoadEntities: EOF without closing brace");
|
||||
if (script->token->str[0] == '}')
|
||||
if (!strcmp (script->token->str, "}"))
|
||||
fprintf (stderr, "LoadEntities: closing brace without data");
|
||||
|
||||
epair = calloc (1, sizeof (epair_t));
|
||||
|
@ -248,8 +248,9 @@ LoadEntities (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (entity->targetname)
|
||||
printf ("%s %d %d\n", entity->targetname, entity->light, entity->style);
|
||||
if (options.verbosity > 1 && entity->targetname)
|
||||
printf ("%s %d %d\n", entity->targetname, entity->light,
|
||||
entity->style);
|
||||
|
||||
// all fields have been parsed
|
||||
if (entity->classname && !strncmp (entity->classname, "light", 5)) {
|
||||
|
|
|
@ -73,8 +73,8 @@ SurfaceBBox (dface_t *s, vec3_t mins, vec3_t maxs)
|
|||
int vi, e, i, j;
|
||||
float *v;
|
||||
|
||||
mins[0] = mins[1] = 999999;
|
||||
maxs[0] = maxs[1] = -99999;
|
||||
mins[0] = mins[1] = mins[2] = 999999;
|
||||
maxs[0] = maxs[1] = maxs[2] = -99999;
|
||||
|
||||
for (i = 0; i < s->numedges; i++) {
|
||||
e = bsp->surfedges[s->firstedge + i];
|
||||
|
|
|
@ -305,7 +305,7 @@ wad_extract (wad_t *wad, lumpinfo_t *pf)
|
|||
width = LittleLong (miptex->width);
|
||||
height = LittleLong (miptex->height);
|
||||
if (width > (unsigned) pf->size || height > (unsigned) pf->size
|
||||
|| (width * height * 3 / 2
|
||||
|| (width * height * 85 / 64
|
||||
+ sizeof (miptex_t)) > (unsigned) pf->size) {
|
||||
if (options.verbosity)
|
||||
fprintf (stderr, "bogus MIPTEX. treating as raw data\n");
|
||||
|
|
Loading…
Reference in a new issue