Make MapEdit (QuakeEd) compile.

It won't work yet as there's no gorm file and there's code that has been
commented out, but it finally compiles.
This commit is contained in:
Bill Currie 2010-09-09 20:46:38 +09:00
parent 7dc1ccdbea
commit 44dd62d369
32 changed files with 785 additions and 686 deletions

View file

@ -2,9 +2,13 @@
#define CameraView_h
#include <AppKit/AppKit.h>
#include "mathlib.h"
#include "QF/mathlib.h"
#include "SetBrush.h"
#include "render.h"
extern id cameraview_i;
extern byte renderlist[1024*1024*4];

View file

@ -1,6 +1,13 @@
#include "qedefs.h"
#include "QF/sys.h"
#include "CameraView.h"
#include "Map.h"
#include "QuakeEd.h"
#include "XYView.h"
#include "ZView.h"
id cameraview_i;
extern NSBezierPath *path;
BOOL timedrawing = 0;
@ -75,10 +82,10 @@ initWithFrame:
[map_i makeAllPerform: @selector(feetToFloor)];
if (sb_floor_dist == 99999)
{
qprintf ("already on top floor");
Sys_Printf ("already on top floor");
return self;
}
qprintf ("up floor");
Sys_Printf ("up floor");
origin[2] += sb_floor_dist;
[quakeed_i updateCamera];
return self;
@ -91,10 +98,10 @@ initWithFrame:
[map_i makeAllPerform: @selector(feetToFloor)];
if (sb_floor_dist == -99999)
{
qprintf ("already on bottom floor");
Sys_Printf ("already on bottom floor");
return self;
}
qprintf ("down floor");
Sys_Printf ("down floor");
origin[2] += sb_floor_dist;
[quakeed_i updateCamera];
return self;
@ -121,7 +128,7 @@ homeView
[quakeed_i updateAll];
qprintf ("homed view angle");
Sys_Printf ("homed view angle");
return self;
}
@ -223,7 +230,7 @@ float mid_x, mid_y;
float topscale = (240.0/3)/160;
float bottomscale = (240.0*2/3)/160;
extern plane_t frustum[5];
extern plane_t rfrustum[5];
void MakeCampt (vec3_t in, campt_t *pt)
{
@ -267,15 +274,16 @@ void CameraMoveto(vec3_t p)
{
campt_t *pt;
if (upath->numberOfPoints > 2048)
if ([path elementCount] > 2048)
lineflush ();
pt = &campts[cam_cur];
cam_cur ^= 1;
MakeCampt (p,pt);
if (!pt->clipflags)
{ // onscreen, so move there immediately
UPmoveto (upath, pt->screen[0], pt->screen[1]);
if (!pt->clipflags) {
// onscreen, so move there immediately
NSPoint point = {pt->screen[0], pt->screen[1]};
[path moveToPoint: point];
}
}
@ -285,22 +293,23 @@ void ClipLine (vec3_t p1, vec3_t p2, int planenum)
vec3_t new;
plane_t *pl;
float scale;
NSPoint point;
if (planenum == 5)
{ // draw it!
if (planenum == 5) {
// draw it!
scale = mid_x/p1[2];
new[0] = mid_x + p1[0]*scale;
new[1] = mid_y + p1[1]*scale;
UPmoveto (upath, new[0], new[1]);
point.x = mid_x + p1[0]*scale;
point.y = mid_y + p1[1]*scale;
[path moveToPoint: point];
scale = mid_x/p2[2];
new[0] = mid_x + p2[0]*scale;
new[1] = mid_y + p2[1]*scale;
UPlineto (upath, new[0], new[1]);
point.x = mid_x + p2[0]*scale;
point.y = mid_y + p2[1]*scale;
[path lineToPoint: point];
return;
}
pl = &frustum[planenum];
pl = &rfrustum[planenum];
d = DotProduct (p1, pl->normal) - pl->dist;
d2 = DotProduct (p2, pl->normal) - pl->dist;
@ -348,9 +357,11 @@ void CameraLineto(vec3_t p)
if (! bits )
{
NSPoint point1 = {p1->screen[0], p1->screen[1]};
NSPoint point2 = {p2->screen[0], p2->screen[1]};
c_on++;
UPmoveto (upath, p1->screen[0], p1->screen[1]);
UPlineto (upath, p2->screen[0], p2->screen[1]);
[path moveToPoint: point1];
[path lineToPoint: point2];
return; // entirely on screen
}
@ -463,10 +474,10 @@ drawSelf
*/
- drawSelf:(NSRect)rects :(int)rectCount
{
static float drawtime; // static to shut up compiler warning
float drawtime = 0;
if (timedrawing)
drawtime = I_FloatTime ();
drawtime = Sys_DoubleTime ();
if (drawmode == dr_texture || drawmode == dr_flat)
[self drawSolid];
@ -476,7 +487,7 @@ drawSelf
if (timedrawing)
{
//XXX NSPing ();
drawtime = I_FloatTime() - drawtime;
drawtime = Sys_DoubleTime () - drawtime;
printf ("CameraView drawtime: %5.3f\n", drawtime);
}
@ -564,7 +575,7 @@ modalMoveLoop
int i;
// vec3_t temp;
qprintf ("moving camera position");
Sys_Printf ("moving camera position");
VectorCopy (origin, originbase);
@ -810,7 +821,7 @@ mouseDown
{
if (drawmode != dr_texture)
{
qprintf ("No texture setting except in texture mode!\n");
Sys_Printf ("No texture setting except in texture mode!\n");
NopSound ();
return;
}
@ -826,7 +837,7 @@ mouseDown
{
if (drawmode != dr_texture)
{
qprintf ("No texture setting except in texture mode!\n");
Sys_Printf ("No texture setting except in texture mode!\n");
NopSound ();
return;
}
@ -836,7 +847,7 @@ mouseDown
}
qprintf ("bad flags for click");
Sys_Printf ("bad flags for click");
NopSound ();
return;
@ -863,13 +874,13 @@ rightMouseDown
//
if (flags == 0)
{
qprintf ("looking");
Sys_Printf ("looking");
[self viewDrag: &pt];
qprintf ("");
Sys_Printf ("%s", "");
return;
}
qprintf ("bad flags for click");
Sys_Printf ("bad flags for click");
NopSound ();
return;

View file

@ -1,6 +1,12 @@
#ifndef Clipper_h
#define Clipper_h
#include <AppKit/AppKit.h>
#include "QF/mathlib.h"
#include "SetBrush.h"
extern id clipper_i;
@interface Clipper : NSObject

View file

@ -1,9 +1,15 @@
#include "qedefs.h"
#include <AppKit/NSGraphics.h>
#include <AppKit/DPSOperators.h>
#include "QF/sys.h"
#include "Clipper.h"
#include "Map.h"
#include "XYView.h"
#include "CameraView.h"
#include "QuakeEd.h"
id clipper_i;
@implementation Clipper
@ -42,7 +48,7 @@ id clipper_i;
}
else
{
qprintf ("no clipplane");
Sys_Printf ("no clipplane");
NSBeep ();
}

View file

@ -1,27 +1,28 @@
#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;
}
- initClass: (char *)classname;
- initFromTokens;
- initFromScript: (struct script_s *) script;
- free;
- (void)dealloc;
- (BOOL)modifiable;
- setModifiable: (BOOL)m;
@ -32,7 +33,7 @@ typedef struct epair_s
- (char *)valueForQKey: (char *)k;
- getVector: (vec3_t)v forKey: (char *)k;
- setKey:(char *)k toValue:(char *)v;
- setKey:(const char *)k toValue:(const char *)v;
- (int)numPairs;
- (epair_t *)epairs;
- removeKeyPair: (char *)key;

View file

@ -1,5 +1,14 @@
#include "qedefs.h"
#include "QF/dstring.h"
#include "QF/script.h"
#include "QF/sys.h"
#include "Entity.h"
#include "EntityClass.h"
#include "TexturePalette.h"
#include "SetBrush.h"
#include "Map.h"
#include "CameraView.h"
@implementation Entity
@ -15,13 +24,10 @@ vec3_t bad_maxs = {8, 8, 8};
// 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;
}
@ -43,31 +49,6 @@ vec3_t bad_maxs = {8, 8, 8};
return self;
}
- copyWithZone:(NSZone *)zone
{
id new, nb;
epair_t *e;
int i;
new = [[Entity alloc] init];
[new setModifiable: modifiable];
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];
[nb setParent: new];
[new addObject: nb];
}
return new;
}
- initClass: (char *)classname
{
id new;
@ -108,16 +89,18 @@ vec3_t bad_maxs = {8, 8, 8};
}
- free
- (void)dealloc
{
epair_t *e, *n;
for (e=epairs ; e ; e=n)
{
n = e->next;
free (e->key);
free (e->value);
free (e);
}
return [super free];
[super dealloc];
}
- (BOOL)modifiable
@ -131,19 +114,17 @@ vec3_t bad_maxs = {8, 8, 8};
return self;
}
- removeObject: o
- (void)removeObject: o
{
o = [super removeObject: o];
if (numElements)
return o;
[super removeObject: o];
if ([self count])
return;
// the entity is empty, so remove the entire thing
if ( self == [map_i objectAt: 0])
return o; // never remove the world
if ( self == [map_i objectAtIndex: 0])
return; // never remove the world
[map_i removeObject: self];
[self free];
return o;
[self release];
}
@ -184,33 +165,27 @@ vec3_t bad_maxs = {8, 8, 8};
return self;
}
- setKey:(char *)k toValue:(char *)v
- setKey:(const char *)k toValue:(const 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);
for (e=epairs ; e ; e=e->next) {
if (!strcmp (k, e->key)) {
free (e->value);
e->value = strdup (v);
return self;
}
}
e = malloc (sizeof(epair_t));
memset (e, 0, sizeof(epair_t));
strcpy (e->key, k);
strcpy (e->value, v);
e->key = strdup (k);
e->value = strdup (v);
e->next = epairs;
epairs = e;
@ -287,7 +262,7 @@ If the entity does not have a "targetname" key, a unique one is generated
maxt = 0;
for (i=1 ; i<count ; i++)
{
ent = [map_i objectAt: i];
ent = [map_i objectAtIndex: i];
t = [ent valueForQKey: "targetname"];
if (!t || t[0] != 't')
continue;
@ -313,9 +288,9 @@ FILE METHODS
int nument;
- initFromTokens
- initFromScript: (script_t *) script
{
char key[MAXTOKEN];
char *key;
id eclass, brush;
char *spawn;
vec3_t emins, emaxs;
@ -327,31 +302,30 @@ int nument;
[self init];
if (!GetToken (true))
if (!Script_GetToken (script, true))
{
[self free];
[self dealloc];
return nil;
}
if (strcmp (token, "{") )
Error ("initFromFileP: { not found");
if (strcmp (Script_Token (script), "{") )
Sys_Error ("initFromFileP: { not found");
do
{
if (!GetToken (true))
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);
@ -368,7 +342,7 @@ int nument;
if ([self count] && esize != esize_model)
{
printf ("WARNING:Entity with brushes and wrong model type\n");
[self empty];
[self removeAllObjects];
}
if (![self count] && esize == esize_model)
@ -397,7 +371,7 @@ int nument;
c = [self count];
for (i=0 ; i<c ; i++)
{
brush = [self objectAt: i];
brush = [self objectAtIndex: i];
[brush setEntityColor: color];
}
@ -412,7 +386,7 @@ int nument;
id new;
char value[80];
vec3_t mins, maxs, org;
float *v;
const vec_t *v;
BOOL temporg;
char oldang[80];
@ -426,8 +400,8 @@ int nument;
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] )
else if ( self != [map_i objectAtIndex: 0]
&& [[self objectAtIndex: 0] regioned] )
return self; // skip the entire entity definition
}
@ -436,7 +410,7 @@ int nument;
// set an origin epair
if (!modifiable)
{
[[self objectAt: 0] getMins: mins maxs: maxs];
[[self objectAtIndex: 0] getMins: mins maxs: maxs];
if (temporg)
{
[cameraview_i getOrigin: mins];
@ -462,8 +436,8 @@ int nument;
// fixed size entities don't save out brushes
if ( modifiable )
{
for (i=0 ; i<numElements ; i++)
[[self objectAt: i] writeToFILE: f region: reg];
for (i = 0 ; i < [self count]; i++)
[[self objectAtIndex: i] writeToFILE: f region: reg];
}
fprintf (f,"}\n");

View file

@ -2,7 +2,8 @@
#define EntityClass_h
#include <AppKit/AppKit.h>
#include "mathlib.h"
#include "QF/mathlib.h"
typedef enum {esize_model, esize_fixed} esize_t;
@ -15,10 +16,10 @@ typedef enum {esize_model, esize_fixed} esize_t;
vec3_t mins, maxs;
vec3_t color;
char *comments;
char flagnames[MAX_FLAGS][32];
char *flagnames[MAX_FLAGS];
}
- initFromText: (char *)text;
- initFromText: (const char *)text source: (const char *)filename;
- (char *)classname;
- (esize_t)esize;
- (float *)mins; // only for esize_fixed

View file

@ -1,8 +1,36 @@
#include <dirent.h>
#include "qedefs.h"
#include "QF/dstring.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->str, "("))
return 0;
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
if (r != 3)
return 0;
while (strcmp (script->token->str, ")")) {
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.
//
@ -13,89 +41,64 @@
//
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
char *debugname;
- initFromText: (char *)text
- 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 ");
script = Script_New ();
Script_Start (script, filename, text);
// grab the name
if (!Script_GetToken (script, 0))
return 0;
if (!strcmp (script->token->str, "*/"))
return 0;
name = strdup (script->token->str);
// grab the color
if (!parse_vector (script, color))
return 0;
// 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
// get the size
if (!strcmp (script->token->str, "(")) {
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->str, "?")) {
// 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->str);
}
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++)
;
for (t = script->p; t[0] && !(t[0] == '*' && t[1] == '/'); t++)
;
// copy the comment block out
len = t-text;
comments = malloc (len+1);
len = t - text;
comments = malloc (len + 1);
memcpy (comments, text, len);
comments[len] = 0;
@ -136,7 +139,7 @@ char *debugname;
- (char *)flagName: (unsigned)flagnum
{
if (flagnum >= MAX_FLAGS)
Error ("EntityClass flagName: bad number");
Sys_Error ("EntityClass flagName: bad number");
return flagnames[flagnum];
}
@ -176,26 +179,36 @@ scanFile
*/
- (void)scanFile: (char *)filename
{
int size;
int size, line;
char *data;
id cl;
int i;
char path[1024];
QFile *file;
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];
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);
}
@ -208,7 +221,7 @@ scanDirectory
- (void)scanDirectory
{
int count, i;
struct direct **namelist, *ent;
struct dirent **namelist, *ent;
[self removeAllObjects];
@ -239,8 +252,9 @@ id entity_classes_i;
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;
}

View file

@ -12,7 +12,7 @@ MapEdit_RESOURCE_FILES= \
MapEdit.gorm
MapEdit_OBJC_FILES= \
CameraView.m Clipper.m EntityClass.m KeypairView.m PopScrollView.m ZView.m misc.m render.m
CameraView.m Clipper.m EntityClass.m KeypairView.m PopScrollView.m ZView.m render.m
MapEdit_HEADERS= \
EntityClass.h

View file

@ -1,6 +1,8 @@
#ifndef KeypairView_h
#define KeypairView_h
#include <AppKit/AppKit.h>
extern id keypairview_i;
@interface KeypairView:NSView

View file

@ -1,5 +1,8 @@
#include "qedefs.h"
#include "KeypairView.h"
#include "Map.h"
#include "Entity.h"
#include "Things.h"
id keypairview_i;

View file

@ -1,6 +1,10 @@
#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;

View file

@ -1,9 +1,22 @@
#include "qedefs.h"
#include <sys/time.h>
#include <time.h>
#include "QF/quakeio.h"
#include "QF/script.h"
#include "QF/sys.h"
#include "Map.h"
#include "Entity.h"
#include "TexturePalette.h"
#include "SetBrush.h"
#include "XYView.h"
#include "CameraView.h"
#include "QuakeEd.h"
#include "Things.h"
#include "InspectorControl.h"
#include "Project.h"
id map_i;
@ -46,7 +59,7 @@ FILE METHODS
else
{
[w removeObjectAtIndex: 0];
[o free];
[o release];
}
}
@ -55,8 +68,8 @@ FILE METHODS
{
o = [self objectAtIndex: 0];
[self removeObjectAtIndex: 0];
[o freeObjects];
[o free];
[o removeAllObjects];
[o release];
}
return self;
@ -169,6 +182,7 @@ FILE METHODS
- writeStats
{
/*XXX
FILE *f;
extern int c_updateall;
struct timeval tp;
@ -180,6 +194,7 @@ FILE METHODS
fprintf (f,"%i %i\n", (int)tp.tv_sec, c_updateall);
c_updateall = 0;
fclose (f);
*/
return self;
}
@ -223,17 +238,26 @@ readMapFile
int i, c;
vec3_t org;
float angle;
QFile *file;
script_t *script;
size_t size;
[self saveSelected];
qprintf ("loading %s\n", fname);
Sys_Printf ("loading %s\n", fname);
LoadFile (fname, (void **)&dat);
StartTokenParsing (dat);
file = Qopen (fname, "rt");
size = Qfilesize (file);
dat = malloc (size + 1);
size = Qread (file, dat, size);
Qclose (file);
dat[size] = 0;
do
{
new = [[Entity alloc] initFromTokens];
script = Script_New ();
Script_Start (script, fname, dat);
do {
new = [[Entity alloc] initFromScript: script];
if (!new)
break;
[self addObject: new];
@ -288,11 +312,11 @@ writeMapFile
FILE *f;
int i;
qprintf ("writeMapFile: %s", fname);
Sys_Printf ("writeMapFile: %s", fname);
f = fopen (fname,"w");
if (!f)
Error ("couldn't write %s", fname);
Sys_Error ("couldn't write %s", fname);
for (i=0 ; i<[self count] ; i++)
[[self objectAtIndex: i] writeToFILE: f region: reg];
@ -353,7 +377,7 @@ make a target connection from the original entity.
oldent = [self currentEntity];
if (oldent == [self objectAtIndex: 0])
{
qprintf ("Must have a non-world entity selected to connect");
Sys_Printf ("Must have a non-world entity selected to connect");
return self;
}
@ -361,13 +385,13 @@ make a target connection from the original entity.
ent = [self currentEntity];
if (ent == oldent)
{
qprintf ("Must click on a different entity to connect");
Sys_Printf ("Must click on a different entity to connect");
return self;
}
if (ent == [self objectAtIndex: 0])
{
qprintf ("Must click on a non-world entity to connect");
Sys_Printf ("Must click on a non-world entity to connect");
return self;
}
@ -422,13 +446,13 @@ to intervening world brushes
if (besttime == 99999)
{
qprintf ("trace missed");
Sys_Printf ("trace missed");
return self;
}
if ( [bestbrush regioned] )
{
qprintf ("WANRING: clicked on regioned brush");
Sys_Printf ("WANRING: clicked on regioned brush");
return self;
}
@ -448,12 +472,12 @@ to intervening world brushes
}
[bestbrush setSelected: YES];
qprintf ("selected entity %i brush %i face %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush], bestface);
Sys_Printf ("selected entity %i brush %i face %i", (int) [self indexOfObject:bestent], (int) [bestent indexOfObject: bestbrush], bestface);
}
else
{
[bestbrush setSelected: NO];
qprintf ("deselected entity %i brush %i face %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush], bestface);
Sys_Printf ("deselected entity %i brush %i face %i", (int) [self indexOfObject:bestent], (int) [bestent indexOfObject: bestbrush], bestface);
}
[quakeed_i enableFlushWindow];
@ -548,14 +572,14 @@ getTextureRay
if ( ![bestent modifiable])
{
qprintf ("can't modify spawned entities");
Sys_Printf ("can't modify spawned entities");
return self;
}
td = [bestbrush texturedefForFace: bestface];
[texturepalette_i setTextureDef: td];
qprintf ("grabbed texturedef and sizes");
Sys_Printf ("grabbed texturedef and sizes");
[bestbrush getMins: mins maxs: maxs];
@ -604,19 +628,19 @@ setTextureRay
if (besttime == 99999)
{
qprintf ("trace missed");
Sys_Printf ("trace missed");
return self;
}
if ( ![bestent modifiable])
{
qprintf ("can't modify spawned entities");
Sys_Printf ("can't modify spawned entities");
return self;
}
if ( [bestbrush regioned] )
{
qprintf ("WANRING: clicked on regioned brush");
Sys_Printf ("WANRING: clicked on regioned brush");
return self;
}
@ -626,12 +650,12 @@ setTextureRay
if (allsides)
{
[bestbrush setTexturedef: &td];
qprintf ("textured entity %i brush %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush]);
Sys_Printf ("textured entity %i brush %i", (int) [self indexOfObject:bestent], (int) [bestent indexOfObject: bestbrush]);
}
else
{
[bestbrush setTexturedef: &td forFace: bestface];
qprintf ("deselected entity %i brush %i face %i", [self indexOfObject:bestent], [bestent indexOfObject: bestbrush], bestface);
Sys_Printf ("deselected entity %i brush %i face %i", (int) [self indexOfObject:bestent], (int) [bestent indexOfObject: bestbrush], bestface);
}
[quakeed_i enableFlushWindow];
@ -669,12 +693,12 @@ OPERATIONS ON SELECTIONS
if ([brush regioned])
continue;
total++;
[brush perform:sel];
[brush performSelector:sel];
}
}
// if (!total)
// qprintf ("nothing selected");
// Sys_Printf ("nothing selected");
return self;
}
@ -696,7 +720,7 @@ OPERATIONS ON SELECTIONS
continue;
if ([brush regioned])
continue;
[brush perform:sel];
[brush performSelector:sel];
}
}
@ -718,7 +742,7 @@ OPERATIONS ON SELECTIONS
brush = [ent objectAtIndex: j];
if ([brush regioned])
continue;
[brush perform:sel];
[brush performSelector:sel];
}
}
@ -738,7 +762,7 @@ OPERATIONS ON SELECTIONS
for (j = c2-1 ; j >=0 ; j--)
{
brush = [ent objectAtIndex: j];
[brush perform:sel];
[brush performSelector:sel];
}
}
@ -757,7 +781,7 @@ void sel_identity (void)
{
if ( ![currentEntity modifiable])
{
qprintf ("can't modify spawned entities");
Sys_Printf ("can't modify spawned entities");
return self;
}
@ -912,14 +936,14 @@ UI operations
o = [self selectedBrush];
if (!o)
{
qprintf ("nothing selected");
Sys_Printf ("nothing selected");
return self;
}
o = [o parent];
c = [o count];
for (i=0 ; i<c ; i++)
[[o objectAtIndex: i] setSelected: YES];
qprintf ("%i brushes selected", c);
Sys_Printf ("%i brushes selected", c);
[quakeed_i updateAll];
@ -930,14 +954,14 @@ UI operations
{
if (currentEntity != [self objectAtIndex: 0])
{
qprintf ("ERROR: can't makeEntity inside an entity");
Sys_Printf ("ERROR: can't makeEntity inside an entity");
NSBeep ();
return self;
}
if ( [self numSelected] == 0)
{
qprintf ("ERROR: must have a seed brush to make an entity");
Sys_Printf ("ERROR: must have a seed brush to make an entity");
NSBeep ();
return self;
}
@ -967,7 +991,7 @@ UI operations
if ([self numSelected] != 1)
{
qprintf ("must have a single brush selected");
Sys_Printf ("must have a single brush selected");
return self;
}
@ -977,7 +1001,7 @@ UI operations
[self makeUnselectedPerform: selector];
qprintf ("identified contents");
Sys_Printf ("identified contents");
[quakeed_i updateAll];
return self;
@ -1002,7 +1026,7 @@ UI operations
if ([self numSelected] != 1)
{
qprintf ("must have a single brush selected");
Sys_Printf ("must have a single brush selected");
return self;
}
@ -1030,7 +1054,7 @@ UI operations
if ([self numSelected] != 1)
{
qprintf ("must have a single brush selected");
Sys_Printf ("must have a single brush selected");
return self;
}
@ -1061,7 +1085,7 @@ subtractSelection
id o, o2;
id sellist, sourcelist;
qprintf ("performing brush subtraction...");
Sys_Printf ("performing brush subtraction...");
sourcelist = [[NSMutableArray alloc] init];
sellist = [[NSMutableArray alloc] init];
@ -1090,32 +1114,32 @@ subtractSelection
{
o2 = [sourcelist objectAtIndex: j];
[o2 carve];
[carve_in freeObjects];
[carve_in removeAllObjects];
}
[sourcelist free]; // the individual have been moved/freed
[sourcelist release]; // the individual have been moved/freed
sourcelist = carve_out;
carve_out = [[NSMutableArray alloc] init];
}
// add the selection back to the remnants
[currentEntity removeAllObjects];
[currentEntity appendList: sourcelist];
[currentEntity appendList: sellist];
[currentEntity addObjectsFromArray: sourcelist];
[currentEntity addObjectsFromArray: sellist];
[sourcelist free];
[sellist free];
[carve_in free];
[carve_out free];
[sourcelist release];
[sellist release];
[carve_in release];
[carve_out release];
if (![currentEntity count])
{
o = currentEntity;
[self removeObject: o];
[o free];
[o release];
}
qprintf ("subtracted selection");
Sys_Printf ("subtracted selection");
[quakeed_i updateAll];
return self;

View file

@ -1,5 +1,5 @@
#include "qedefs.h"
#include "PopScrollView.h"
@implementation PopScrollView

View file

@ -1,13 +1,13 @@
#ifndef QuakeEd_h
#define QuakeEd_h
#include <AppKit/AppKit.h>
extern id quakeed_i;
extern BOOL filter_light, filter_path, filter_entities;
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
extern UserPath *upath;
extern id g_cmd_out_i;
double I_FloatTime (void);

View file

@ -1,5 +1,5 @@
#include "qedefs.h"
#include "QuakeEd.h"
id quakeed_i;
id entclasses_i;
@ -29,8 +29,6 @@ void NopSound (void)
NSBeep ();
}
UserPath *upath;
void My_Malloc_Error (int code)
{

View file

@ -1,9 +1,13 @@
#ifndef SetBrush_h
#define SetBrush_h
#define MAX_FACES 16
#include <AppKit/AppKit.h>
typedef float vec5_t[5];
#include "QF/mathlib.h"
#include "TexturePalette.h"
#define MAX_FACES 16
typedef struct
{
@ -61,7 +65,7 @@ winding_t *NewWinding (int points);
}
- initOwner: own mins:(float *)mins maxs:(float *)maxs texture:(texturedef_t *)tex;
- initFromTokens: own;
- initFromScript: (struct script_s *) script owner: own;
- setMins:(float *)mins maxs:(float *)maxs;
- parent;

View file

@ -1,4 +1,11 @@
#include "qedefs.h"
#include "QF/script.h"
#include "QF/sys.h"
#include "SetBrush.h"
#include "Entity.h"
#include "EntityClass.h"
#include "Map.h"
#include "Preferences.h"
@implementation SetBrush
@ -74,10 +81,10 @@ void CheckFace (face_t *f)
w = f->w;
if (!w)
Error ("CheckFace: no winding");
Sys_Error ("CheckFace: no winding");
if (w->numpoints < 3)
Error ("CheckFace: %i points",w->numpoints);
Sys_Error ("CheckFace: %i points",w->numpoints);
for (i=0 ; i<w->numpoints ; i++)
{
@ -85,21 +92,21 @@ void CheckFace (face_t *f)
for (j=0 ; j<3 ; j++)
if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)
Error ("CheckFace: BUGUS_RANGE: %f",p1[j]);
Sys_Error ("CheckFace: BUGUS_RANGE: %f",p1[j]);
j = i+1 == w->numpoints ? 0 : i+1;
// check the point is on the face plane
d = DotProduct (p1, f->plane.normal) - f->plane.dist;
if (d < -ON_EPSILON || d > ON_EPSILON)
Error ("CheckFace: point off plane");
Sys_Error ("CheckFace: point off plane");
// check the edge isn't degenerate
p2 = w->points[j];
VectorSubtract (p2, p1, dir);
if (VectorLength (dir) < ON_EPSILON)
Error ("CheckFace: degenerate edge");
Sys_Error ("CheckFace: degenerate edge");
CrossProduct (f->plane.normal, dir, edgenormal);
VectorNormalize (edgenormal);
@ -113,7 +120,7 @@ void CheckFace (face_t *f)
continue;
d = DotProduct (w->points[j], edgenormal);
if (d > edgedist)
Error ("CheckFace: non-convex");
Sys_Error ("CheckFace: non-convex");
}
}
}
@ -136,12 +143,12 @@ NewWinding
winding_t *NewWinding (int points)
{
winding_t *w;
int size;
size_t size;
if (points > MAX_POINTS_ON_WINDING)
Error ("NewWinding: %i points", points);
Sys_Error ("NewWinding: %i points", points);
size = (int)((winding_t *)0)->points[points];
size = (size_t)((winding_t *)0)->points[points];
w = malloc (size);
memset (w, 0, size);
@ -156,10 +163,10 @@ CopyWinding
*/
winding_t *CopyWinding (winding_t *w)
{
int size;
size_t size;
winding_t *c;
size = (int)((winding_t *)0)->points[w->numpoints];
size = (size_t)((winding_t *)0)->points[w->numpoints];
c = malloc (size);
memcpy (c, w, size);
return c;
@ -263,7 +270,7 @@ winding_t *ClipWinding (winding_t *in, plane_t *split)
}
if (neww->numpoints > maxpts)
Error ("ClipWinding: points exceeded estimate");
Sys_Error ("ClipWinding: points exceeded estimate");
// free the original winding
free (in);
@ -306,7 +313,7 @@ winding_t *BasePolyForPlane (face_t *f)
}
}
if (x==-1)
Error ("BasePolyForPlane: no axis found");
Sys_Error ("BasePolyForPlane: no axis found");
VectorCopy (vec3_origin, vup);
switch (x)
@ -321,7 +328,7 @@ winding_t *BasePolyForPlane (face_t *f)
}
v = DotProduct (vup, p->normal);
VectorMA (vup, -v, p->normal, vup);
VectorMultAdd (vup, -v, p->normal, vup);
VectorNormalize (vup);
VectorScale (p->normal, p->dist, org);
@ -621,23 +628,10 @@ initOwner:::
return self;
}
- copyFromZone:(NSZone *)zone
{
id new;
[self freeWindings];
new = [super copyFromZone: zone];
[self calcWindings];
[new calcWindings];
return new;
}
- free
- (void)dealloc
{
[self freeWindings];
return [super free];
return [super dealloc];
}
/*
@ -646,7 +640,7 @@ initOwner: fromTokens
===========
*/
int numsb;
- initFromTokens: own
- initFromScript: (script_t *) script owner: own
{
face_t *f;
int i,j;
@ -659,44 +653,44 @@ int numsb;
numfaces = 0;
do
{
if (!GetToken (true))
if (!Script_GetToken (script, true))
break;
if (!strcmp (token, "}") )
if (!strcmp (Script_Token (script), "}") )
break;
for (i=0 ; i<3 ; i++)
{
if (i != 0)
GetToken (true);
if (strcmp (token, "(") )
Error ("parsing map file");
Script_GetToken (script, true);
if (strcmp (Script_Token (script), "(") )
Sys_Error ("parsing map file");
for (j=0 ; j<3 ; j++)
{
GetToken (false);
f->planepts[i][j] = atoi(token);
Script_GetToken (script, false);
f->planepts[i][j] = atoi(Script_Token (script));
}
GetToken (false);
if (strcmp (token, ")") )
Error ("parsing map file");
Script_GetToken (script, false);
if (strcmp (Script_Token (script), ")") )
Sys_Error ("parsing map file");
}
GetToken (false);
strcpy (f->texture.texture, token);
GetToken (false);
f->texture.shift[0] = atof(token);
GetToken (false);
f->texture.shift[1] = atof(token);
GetToken (false);
f->texture.rotate = atof(token);
GetToken (false);
f->texture.scale[0] = atof(token);
GetToken (false);
f->texture.scale[1] = atof(token);
Script_GetToken (script, false);
strcpy (f->texture.texture, Script_Token (script));
Script_GetToken (script, false);
f->texture.shift[0] = atof(Script_Token (script));
Script_GetToken (script, false);
f->texture.shift[1] = atof(Script_Token (script));
Script_GetToken (script, false);
f->texture.rotate = atof(Script_Token (script));
Script_GetToken (script, false);
f->texture.scale[0] = atof(Script_Token (script));
Script_GetToken (script, false);
f->texture.scale[1] = atof(Script_Token (script));
#if 0
flags = atoi(token);
flags = atoi(Script_Token (script));
flags &= 7;
@ -827,7 +821,7 @@ setTexturedef
- setTexturedef: (texturedef_t *)tex forFace:(int)f
{
if ( (unsigned)f > numfaces)
Error ("setTexturedef:forFace: bad face number %i",f);
Sys_Error ("setTexturedef:forFace: bad face number %i",f);
faces[f].texture = *tex;
faces[f].qtexture = NULL; // recache next render
@ -1000,7 +994,7 @@ hitByRay
*time = DotProduct (frontpoint, dir);
if (*time < 0)
Error ("hitByRay: negative t");
Sys_Error ("hitByRay: negative t");
*face = frontface;
@ -1027,9 +1021,9 @@ BOOL fakebrush;
vec3_t forward, right;
char *targname;
vec3_t min, max, temp;
char targ[64];
char *targ;
strcpy (targ, [parent valueForQKey: "target"]);
targ = [parent valueForQKey: "target"];
if (!targ || !targ[0])
return self;
@ -1040,12 +1034,12 @@ BOOL fakebrush;
c = [map_i count];
for (i=0 ; i<c ; i++)
{
obj = [map_i objectAt: i];
obj = [map_i objectAtIndex: i];
targname = [obj valueForQKey: "targetname"];
if (strcmp (targ, targname))
continue;
[[obj objectAt:0] getMins: min maxs: max];
[[obj objectAtIndex:0] getMins: min maxs: max];
dest[0] = (min[0] + max[0]) /2;
dest[1] = (min[1] + max[1]) /2;
@ -1098,7 +1092,7 @@ BOOL fakebrush;
if (copy)
{
[copy perform:call];
[copy free];
[copy dealloc];
}
fakebrush = NO;
return YES;
@ -1125,10 +1119,10 @@ XYDrawSelf
[xyview_i addToScrollRange: bmins[0] : bmins[1]];
[xyview_i addToScrollRange: bmaxs[0] : bmaxs[1]];
worldent = [map_i objectAt: 0];
worldent = [map_i objectAtIndex: 0];
currentent = [map_i currentEntity];
if (parent != worldent && self == [parent objectAt: 0])
if (parent != worldent && self == [parent objectAtIndex: 0])
keybrush = YES;
else
keybrush = NO;
@ -1283,7 +1277,7 @@ CameraDrawSelf
if ([self fakeBrush: @selector(CameraDrawSelf)])
return self;
worldent = [map_i objectAt: 0];
worldent = [map_i objectAtIndex: 0];
currentent = [map_i currentEntity];
if (parent != worldent && worldent == currentent)
@ -1587,7 +1581,7 @@ float *controlpoints[MAX_FACES*3];
if (k != 3)
{
// Error ("getXYShearPoints: didn't get three points on plane");
// Sys_Error ("getXYShearPoints: didn't get three points on plane");
numcontrolpoints = 0;
return self;
}
@ -1623,7 +1617,7 @@ Set the regioned flag based on if the object is containted in region_min/max
char *name;
// filter away entities
if (parent != [map_i objectAt: 0])
if (parent != [map_i objectAtIndex: 0])
{
if (filter_entities)
{
@ -1816,7 +1810,7 @@ vec3_t sb_mins, sb_maxs;
}
[parent removeObject: self];
[self free];
[self dealloc];
return nil;
}
@ -1940,7 +1934,7 @@ id carve_in, carve_out;
- addFace: (face_t *)f
{
if (numfaces == MAX_FACES)
Error ("addFace: numfaces == MAX_FACES");
Sys_Error ("addFace: numfaces == MAX_FACES");
faces[numfaces] = *f;
faces[numfaces].texture = faces[0].texture;
@ -1980,7 +1974,7 @@ id carve_in, carve_out;
#if 0
if ( (i = NSMallocCheck()) )
Error ("MallocCheck failure");
Sys_Error ("MallocCheck failure");
#endif
// check bboxes

View file

@ -1,6 +1,10 @@
#ifndef TexturePalette_h
#define TexturePalette_h
#include <AppKit/AppKit.h>
#include "QF/qtypes.h"
typedef union
{
byte chan[4];

View file

@ -1,5 +1,6 @@
#include "QF/qendian.h"
#include "qedefs.h"
#include "TexturePalette.h"
id texturepalette_i;
@ -55,7 +56,7 @@ unsigned badtex_d[] =
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff
};
qtexture_t badtex = {"notexture",16,16,NULL, badtex_d, {0,0,255,255}};
qtexture_t badtex = {"notexture",16,16,NULL, badtex_d, {{0,0,255,255}}};
/*
==============

View file

@ -3,6 +3,8 @@
#include <AppKit/AppKit.h>
#include "Entity.h"
extern id things_i;
#define ENTITYNAMEKEY "spawn"

View file

@ -1,5 +1,10 @@
#include "qedefs.h"
#include "Things.h"
#include "QuakeEd.h"
#include "Map.h"
#include "EntityClass.h"
#include "KeypairView.h"
#include "Project.h"
id things_i;
@ -21,7 +26,7 @@ id things_i;
- loadEntityComment:(id)obj
{
[entity_comment_i selectAll:self];
[entity_comment_i replaceSel:[obj comments]];
[entity_comment_i replaceCharactersInRange:[entity_comment_i selectedRange] withString:[NSString stringWithCString:[obj comments]]];
return self;
}
@ -33,13 +38,13 @@ id things_i;
path = [project_i getProgDirectory];
[prog_path_i setStringValue: path];
[prog_path_i setStringValue: [NSString stringWithCString:path]];
[[EntityClassList alloc] initForSourceDirectory: path];
[self loadEntityComment:[entity_classes_i objectAt: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];
[entity_browser_i setDoubleAction: @selector(doubleClickEntity:)];
@ -52,7 +57,7 @@ id things_i;
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;
@ -67,7 +72,7 @@ id things_i;
- (char *)spawnName
{
return [[entity_classes_i objectAt:lastSelected] classname];
return [[entity_classes_i objectAtIndex:lastSelected] classname];
}
@ -83,22 +88,22 @@ id things_i;
if (!path || !path[0])
{
path = [project_i getProgDirectory];
[prog_path_i setStringValue: path];
[prog_path_i setStringValue: [NSString stringWithCString:path]];
}
// Free all entity info in memory...
[entity_classes_i freeObjects];
[entity_classes_i free];
[entity_classes_i removeAllObjects];
[entity_classes_i release];
// Now, RELOAD!
[[EntityClassList alloc] initForSourceDirectory: path];
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
@ -113,14 +118,14 @@ id things_i;
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];
[[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
[[entity_browser_i matrixInColumn:0] scrollCellToVisibleAtRow:lastSelected column:0];
return self;
}
@ -136,7 +141,7 @@ id things_i;
ent = [map_i currentEntity];
classname = [ent valueForQKey: "classname"];
if (ent != [map_i objectAt: 0])
if (ent != [map_i objectAtIndex: 0])
[self selectClass: classname]; // don't reset for world
classent = [entity_classes_i classForName:classname];
flagname = [ent valueForQKey: "spawnflags"];
@ -149,11 +154,11 @@ id things_i;
for (r=0 ; r<4 ; r++)
for (c=0 ; c<3 ; c++)
{
cell = [flags_i cellAt: r : c];
cell = [flags_i cellAtRow: r column: c];
if (c < 2)
{
flagname = [classent flagName: c*4 + r];
[cell setTitle: flagname];
[cell setTitle: [NSString stringWithCString:flagname]];
}
[cell setIntValue: (flags & (1<< ((c*4)+r)) ) > 0];
}
@ -175,8 +180,8 @@ id things_i;
//
- setSelectedKey:(epair_t *)ep;
{
[keyInput_i setStringValue:ep->key];
[valueInput_i setStringValue:ep->value];
[keyInput_i setStringValue:[NSString stringWithCString:ep->key]];
[valueInput_i setStringValue:[NSString stringWithCString:ep->value]];
[valueInput_i selectText:self];
return self;
}
@ -237,7 +242,7 @@ id things_i;
const char *title;
char value[10];
title = [[sender selectedCell] title];
title = [[[sender selectedCell] title] cString];
if (!strcmp(title,"Up"))
strcpy (value, "-1");
else if (!strcmp(title,"Dn"))
@ -245,8 +250,8 @@ id things_i;
else
strcpy (value, title);
[keyInput_i setStringValue:"angle"];
[valueInput_i setStringValue:value];
[keyInput_i setStringValue:@"angle"];
[valueInput_i setStringValue:[NSString stringWithCString:value]];
[self addPair:NULL];
[self clearInputs];
@ -269,7 +274,7 @@ id things_i;
for (r=0 ; r<4 ; r++)
for (c=0 ; c<3 ; c++)
{
cell = [flags_i cellAt: r : c];
cell = [flags_i cellAtRow: r column: c];
i = ([cell intValue] > 0);
flags |= (i<< ((c*4)+r));
}
@ -304,10 +309,10 @@ id things_i;
i = 0;
while(max--)
{
object = [entity_classes_i objectAt:i];
object = [entity_classes_i objectAtIndex:i];
[matrix addRow];
cell = [matrix cellAt:i++ :0];
[cell setStringValue:[object classname]];
cell = [matrix cellAtRow:i++ column:0];
[cell setStringValue:[NSString stringWithCString:[object classname]]];
[cell setLeaf:YES];
[cell setLoaded:YES];
}

View file

@ -8,9 +8,9 @@
*/
#include "UserPath.h"
#include <mach/mach_init.h>
#include <appkit/graphics.h>
#include <appkit/errors.h>
//#include <mach/mach_init.h>
//#include <appkit/graphics.h>
//#include <appkit/errors.h>
#include <math.h>
#include <libc.h>
@ -137,16 +137,16 @@ int sendUserPath(UserPath *up)
exception.code = 0;
if (up->opForUserPath != 0) {
NS_DURING
//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
//NS_HANDLER
// exception = NSLocalHandler;
//NS_ENDHANDLER
if (exception.code) {
NSReportError(&exception);
if (exception.code == dps_err_ps) {

View file

@ -2,9 +2,13 @@
#define XYView_h
#include <AppKit/AppKit.h>
#include "mathlib.h"
#include "QF/mathlib.h"
#include "SetBrush.h"
#include "render.h"
extern id xyview_i;
#define MINSCALE 0.125
@ -23,7 +27,6 @@ void linecolor (float r, float g, float b);
void XYmoveto (vec3_t pt);
void XYlineto (vec3_t pt);
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
@interface XYView : NSView

View file

@ -1,8 +1,15 @@
#include "qedefs.h"
#include "XYView.h"
#include "ZView.h"
#include "CameraView.h"
#include "Clipper.h"
#include "QuakeEd.h"
#include "Map.h"
#include "Entity.h"
#include "PopScrollView.h"
id xyview_i;
id scalemenu_i, gridmenu_i, scrollview_i, gridbutton_i, scalebutton_i;
id scrollview_i, gridbutton_i, scalebutton_i;
vec3_t xy_viewnormal; // v_forward for xy view
float xy_viewdist; // clip behind this plane
@ -14,12 +21,12 @@ float xy_viewdist; // clip behind this plane
initWithFrame:
==================
*/
- initWithFrame:(const NSRect *)frameRect
- initWithFrame:(NSRect)frameRect
{
[super initWithFrame:frameRect];
[self allocateGState];
NSSetRect (&realbounds, 0,0,0,0);
realbounds = NSMakeRect (0,0,0,0);
gridsize = 16;
scale = 1.0;
@ -31,50 +38,45 @@ initWithFrame:
//
// initialize the pop up menus
//
scalemenu_i = [[PopUpList alloc] init];
[scalemenu_i setTarget: self];
[scalemenu_i setAction: @selector(scaleMenuTarget:)];
scalebutton_i = [[NSPopUpButton alloc] init];
[scalebutton_i setTarget: self];
[scalebutton_i setAction: @selector(scaleMenuTarget:)];
[scalebutton_i addItemWithTitle: @"12.5%"];
[scalebutton_i addItemWithTitle: @"25%"];
[scalebutton_i addItemWithTitle: @"50%"];
[scalebutton_i addItemWithTitle: @"75%"];
[scalebutton_i addItemWithTitle: @"100%"];
[scalebutton_i addItemWithTitle: @"200%"];
[scalebutton_i addItemWithTitle: @"300%"];
[scalebutton_i selectItemAtIndex: 4];
[scalemenu_i addItem: "12.5%"];
[scalemenu_i addItem: "25%"];
[scalemenu_i addItem: "50%"];
[scalemenu_i addItem: "75%"];
[scalemenu_i addItem: "100%"];
[scalemenu_i addItem: "200%"];
[scalemenu_i addItem: "300%"];
[[scalemenu_i itemList] selectCellAt: 4 : 0];
gridbutton_i = [[NSPopUpButton alloc] init];
[gridbutton_i setTarget: self];
[gridbutton_i setAction: @selector(gridMenuTarget:)];
[gridbutton_i addItemWithTitle: @"grid 1"];
[gridbutton_i addItemWithTitle: @"grid 2"];
[gridbutton_i addItemWithTitle: @"grid 4"];
[gridbutton_i addItemWithTitle: @"grid 8"];
[gridbutton_i addItemWithTitle: @"grid 16"];
[gridbutton_i addItemWithTitle: @"grid 32"];
[gridbutton_i addItemWithTitle: @"grid 64"];
scalebutton_i = NSCreatePopUpListButton(scalemenu_i);
gridmenu_i = [[PopUpList alloc] init];
[gridmenu_i setTarget: self];
[gridmenu_i setAction: @selector(gridMenuTarget:)];
[gridmenu_i addItem: "grid 1"];
[gridmenu_i addItem: "grid 2"];
[gridmenu_i addItem: "grid 4"];
[gridmenu_i addItem: "grid 8"];
[gridmenu_i addItem: "grid 16"];
[gridmenu_i addItem: "grid 32"];
[gridmenu_i addItem: "grid 64"];
[gridbutton_i selectItemAtIndex: 4];
[[gridmenu_i itemList] selectCellAt: 4 : 0];
gridbutton_i = NSCreatePopUpListButton(gridmenu_i);
// initialize the scroll view
scrollview_i = [[PopScrollView alloc]
initWithFrame: frameRect
button1: scalebutton_i
button2: gridbutton_i
initWithFrame: frameRect
button1: scalebutton_i
button2: gridbutton_i
];
[scrollview_i setLineScroll: 64];
[scrollview_i setAutosizing: NS_WIDTHSIZABLE | NS_HEIGHTSIZABLE];
[scrollview_i setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
// link objects together
[[scrollview_i setDocView: self] free];
[scrollview_i setDocumentView: self];
RELEASE (scrollview_i);
return scrollview_i;
}
@ -95,7 +97,7 @@ initWithFrame:
- drawMode: sender
{
drawmode = [sender selectedCol];
drawmode = [sender selectedColumn];
[quakeed_i updateXY];
return self;
}
@ -103,7 +105,7 @@ initWithFrame:
- setDrawMode: (drawmode_t)mode
{
drawmode = mode;
[mode_radio_i selectCellAt:0: mode];
[mode_radio_i selectCellAtRow:0 column: mode];
[quakeed_i updateXY];
return self;
}
@ -115,9 +117,7 @@ initWithFrame:
}
/*
===================
setOrigin:scale:
===================
v
*/
- setOrigin: (NSPoint *)pt scale: (float)sc
{
@ -129,38 +129,38 @@ setOrigin:scale:
//
scale = sc;
[superview getFrame: &sframe];
[superview getFrame: &newbounds];
sframe = [[self superview] frame];
newbounds = [[self superview] frame];
newbounds.origin = *pt;
newbounds.size.width /= scale;
newbounds.size.height /= scale;
sframe.size.width /= scale;
sframe.size.height /= scale;
//
// union with the realbounds
//
NSUnionRect (&realbounds, &newbounds);
newbounds = NSUnionRect (realbounds, newbounds);
//
// redisplay everything
//
[quakeed_i disableDisplay];
//XXX[quakeed_i disableDisplay];
//
// size this view
//
[self sizeTo: newbounds.size.width : newbounds.size.height];
[self setDrawOrigin: newbounds.origin.x : newbounds.origin.y];
[self moveTo: newbounds.origin.x : newbounds.origin.y];
[self setBoundsSize: newbounds.size];
[self setBoundsOrigin: newbounds.origin];
//XXX[self moveTo: newbounds.origin.x : newbounds.origin.y];
//
// scroll and scale the clip view
//
[superview setDrawSize
: sframe.size.width/scale
: sframe.size.height/scale];
[superview setDrawOrigin: pt->x : pt->y];
[[self superview] setBoundsSize: sframe.size];
[[self superview] setBoundsOrigin: *pt];
[quakeed_i reenableDisplay];
//XXX[quakeed_i reenableDisplay];
[scrollview_i display];
return self;
@ -171,7 +171,7 @@ setOrigin:scale:
NSRect sbounds;
NSPoint mid, delta;
[[xyview_i superview] getBounds: &sbounds];
sbounds = [[xyview_i superview] bounds];
mid.x = sbounds.origin.x + sbounds.size.width/2;
mid.y = sbounds.origin.y + sbounds.size.height/2;
@ -197,7 +197,7 @@ When superview is resized
{
NSRect r;
[superview getBounds: &r];
r = [[self superview] bounds];
[self newRealBounds: &r];
return self;
@ -221,25 +221,25 @@ If realbounds has shrunk, nothing will change.
//
// calculate the area visible in the cliprect
//
[superview getBounds: &sbounds];
NSUnionRect (nb, &sbounds);
sbounds = [[self superview] bounds];
sbounds = NSUnionRect (*nb, sbounds);
//
// size this view
//
[quakeed_i disableDisplay];
//XXX[quakeed_i disableDisplay];
[self suspendNotifyAncestorWhenFrameChanged:YES];
[self sizeTo: sbounds.size.width : sbounds.size.height];
[self setDrawOrigin: sbounds.origin.x : sbounds.origin.y];
[self moveTo: sbounds.origin.x : sbounds.origin.y];
[self suspendNotifyAncestorWhenFrameChanged:NO];
[self setPostsBoundsChangedNotifications:NO];
[self setBoundsSize: sbounds.size];
[self setBoundsOrigin: sbounds.origin];
//XXX[self moveTo: sbounds.origin.x : sbounds.origin.y];
[self setPostsBoundsChangedNotifications:YES];
[scrollview_i reflectScroll: superview];
[quakeed_i reenableDisplay];
[scrollview_i reflectScrolledClipView: [scrollview_i contentView]];
//XXX[quakeed_i reenableDisplay];
[[scrollview_i horizScroller] display];
[[scrollview_i vertScroller] display];
[[scrollview_i horizontalScroller] display];
[[scrollview_i verticalScroller] display];
return self;
}
@ -259,7 +259,7 @@ Called when the scaler popup on the window is used
NSRect visrect, sframe;
float nscale;
item = [[sender selectedCell] title];
item = [[[sender selectedCell] title] cString];
sscanf (item,"%f",&nscale);
nscale /= 100;
@ -267,8 +267,8 @@ Called when the scaler popup on the window is used
return NULL;
// keep the center of the view constant
[superview getBounds: &visrect];
[superview getFrame: &sframe];
visrect = [[self superview] bounds];
sframe = [[self superview] frame];
visrect.origin.x += visrect.size.width/2;
visrect.origin.y += visrect.size.height/2;
@ -287,8 +287,8 @@ zoomIn
*/
- zoomIn: (NSPoint *)constant
{
id itemlist;
int selected, numrows, numcollumns;
id itemlist, selectedItem;
int selected, numrows;
NSRect visrect;
NSPoint ofs, new;
@ -296,20 +296,20 @@ zoomIn
//
// set the popup
//
itemlist = [scalemenu_i itemList];
[itemlist getNumRows: &numrows numCols:&numcollumns];
selected = [itemlist selectedRow] + 1;
itemlist = [scalebutton_i itemArray];
numrows = [itemlist count];
selectedItem = [scalebutton_i selectedItem];
selected = [itemlist indexOfObject: selectedItem] + 1;
if (selected >= numrows)
return NULL;
[itemlist selectCellAt: selected : 0];
[scalebutton_i setTitle: [[itemlist selectedCell] title]];
[scalebutton_i selectItemAtIndex: selected];
//
// zoom the view
//
[superview getBounds: &visrect];
visrect = [[self superview] bounds];
ofs.x = constant->x - visrect.origin.x;
ofs.y = constant->y - visrect.origin.y;
@ -329,29 +329,28 @@ zoomOut
*/
- zoomOut: (NSPoint *)constant
{
id itemlist;
int selected, numrows, numcollumns;
id itemlist, selectedItem;
int selected;
NSRect visrect;
NSPoint ofs, new;
//
// set the popup
//
itemlist = [scalemenu_i itemList];
[itemlist getNumRows: &numrows numCols:&numcollumns];
selected = [itemlist selectedRow] - 1;
itemlist = [scalebutton_i itemArray];
selectedItem = [scalebutton_i selectedItem];
selected = [itemlist indexOfObject: selectedItem] - 1;
if (selected < 0)
return NULL;
[itemlist selectCellAt: selected : 0];
[scalebutton_i setTitle: [[itemlist selectedCell] title]];
[scalebutton_i selectItemAtIndex: selected];
//
// zoom the view
//
[superview getBounds: &visrect];
visrect = [[self superview] bounds];
ofs.x = constant->x - visrect.origin.x;
ofs.y = constant->y - visrect.origin.y;
@ -377,7 +376,7 @@ Called when the scaler popup on the window is used
char const *item;
int grid;
item = [[sender selectedCell] title];
item = [[[sender selectedCell] title] cString];
sscanf (item,"grid %d",&grid);
if (grid == gridsize)
@ -460,24 +459,23 @@ superviewChanged
===============================================================================
*/
vec3_t cur_linecolor;
vec3_t cur_linecolor;
NSBezierPath *path;
void linestart (float r, float g, float b)
{
beginUserPath (upath,NO);
cur_linecolor[0] = r;
cur_linecolor[1] = g;
cur_linecolor[2] = b;
[path removeAllPoints];
VectorSet (r, g, b, cur_linecolor);
}
void lineflush (void)
{
if (!upath->numberOfPoints)
if ([path isEmpty])
return;
endUserPath (upath, dps_ustroke);
//endUserPath (upath, dps_ustroke);
PSsetrgbcolor (cur_linecolor[0], cur_linecolor[1], cur_linecolor[2]);
sendUserPath (upath);
beginUserPath (upath,NO);
[path stroke];
[path removeAllPoints];
}
void linecolor (float r, float g, float b)
@ -485,21 +483,21 @@ void linecolor (float r, float g, float b)
if (cur_linecolor[0] == r && cur_linecolor[1] == g && cur_linecolor[2] == b)
return; // do nothing
lineflush ();
cur_linecolor[0] = r;
cur_linecolor[1] = g;
cur_linecolor[2] = b;
VectorSet (r, g, b, cur_linecolor);
}
void XYmoveto (vec3_t pt)
{
if (upath->numberOfPoints > 2048)
NSPoint point = {pt[0], pt[1]};
if ([path elementCount] > 2048)
lineflush ();
UPmoveto (upath, pt[0], pt[1]);
[path moveToPoint: point];
}
void XYlineto (vec3_t pt)
{
UPlineto (upath, pt[0], pt[1]);
NSPoint point = {pt[0], pt[1]};
[path lineToPoint: point];
}
/*
@ -513,19 +511,20 @@ Rect is in global world (unscaled) coordinates
============
*/
- drawGrid: (const NSRect *)rect
- drawGrid: (NSRect)rect
{
int x,y, stopx, stopy;
float top,bottom,right,left;
char text[10];
BOOL showcoords;
NSPoint point;
showcoords = [quakeed_i showCoordinates];
left = rect->origin.x-1;
bottom = rect->origin.y-1;
right = rect->origin.x+rect->size.width+2;
top = rect->origin.y+rect->size.height+2;
left = rect.origin.x-1;
bottom = rect.origin.y-1;
right = rect.origin.x+rect.size.width+2;
top = rect.origin.y+rect.size.height+2;
PSsetlinewidth (0.15);
@ -555,24 +554,30 @@ Rect is in global world (unscaled) coordinates
if (stopy >= top)
stopy -= gridsize;
beginUserPath (upath,NO);
[path removeAllPoints];
for ( ; y<=stopy ; y+= gridsize)
if (y&63)
{
UPmoveto (upath, left, y);
UPlineto (upath, right, y);
point.x = left;
point.y = y;
[path moveToPoint: point];
point.x = right;
[path lineToPoint: point];
}
for ( ; x<=stopx ; x+= gridsize)
if (x&63)
{
UPmoveto (upath, x, top);
UPlineto (upath, x, bottom);
point.x = x;
point.y = top;
[path moveToPoint: point];
point.y = bottom;
[path lineToPoint: point];
}
endUserPath (upath, dps_ustroke);
//endUserPath (upath, dps_ustroke);
PSsetrgbcolor (0.8,0.8,1.0); // thin grid color
sendUserPath (upath);
[path stroke];
}
@ -601,18 +606,19 @@ PSsetrgbcolor (0.8,0.8,1.0); // thin grid color
if (stopy >= top)
stopy -= 64;
beginUserPath (upath,NO);
[path removeAllPoints];
for ( ; y<=stopy ; y+= 64)
{
if (showcoords)
{
sprintf (text, "%i",y);
PSmoveto(left,y);
PSshow(text);
PSmoveto (left, y);
PSshow (text);
}
UPmoveto (upath, left, y);
UPlineto (upath, right, y);
[path moveToPoint: point];
point.x = right;
[path lineToPoint: point];
}
for ( ; x<=stopx ; x+= 64)
@ -620,16 +626,19 @@ PSsetrgbcolor (0.8,0.8,1.0); // thin grid color
if (showcoords)
{
sprintf (text, "%i",x);
PSmoveto(x,bottom+2);
PSshow(text);
PSmoveto (x, bottom + 2);
PSshow (text);
}
UPmoveto (upath, x, top);
UPlineto (upath, x, bottom);
point.x = x;
point.y = top;
[path moveToPoint: point];
point.y = bottom;
[path lineToPoint: point];
}
endUserPath (upath, dps_ustroke);
//endUserPath (upath, dps_ustroke);
PSsetgray (12.0/16);
sendUserPath (upath);
[path stroke];
}
return self;
@ -640,7 +649,7 @@ PSsetrgbcolor (0.8,0.8,1.0); // thin grid color
drawWire
==================
*/
- drawWire: (const NSRect *)rects
- drawWire: (NSRect)rects
{
NSRect visRect;
int i,j, c, c2;
@ -652,9 +661,9 @@ drawWire
if ([quakeed_i showCoordinates]) // if coords are showing, update everything
{
[self getVisibleRect:&visRect];
rects = &visRect;
xy_draw_rect = *rects;
visRect = [self visibleRect];
rects = visRect;
xy_draw_rect = rects;
}
@ -672,11 +681,11 @@ drawWire
c = [map_i count];
for (i=0 ; i<c ; i++)
{
ent = [map_i objectAt: i];
ent = [map_i objectAtIndex: i];
c2 = [ent count];
for (j = c2-1 ; j >=0 ; j--)
{
brush = [ent objectAt: j];
brush = [ent objectAtIndex: j];
if ( [brush selected] )
continue;
if ([brush regioned])
@ -685,7 +694,7 @@ drawWire
}
if (i > 0 && drawnames)
{ // draw entity names
brush = [ent objectAt: 0];
brush = [ent objectAtIndex: 0];
if (![brush regioned])
{
[brush getMins: mins maxs: maxs];
@ -703,7 +712,7 @@ drawWire
newrect.origin.y -= gridsize;
newrect.size.width += 2*gridsize;
newrect.size.height += 2*gridsize;
if (!NSEqualRect (&newrect, &realbounds))
if (!NSEqualRects (newrect, realbounds))
[self newRealBounds: &newrect];
return self;
@ -717,10 +726,10 @@ drawSolid
*/
- drawSolid
{
unsigned char *planes[5];
const unsigned char *planes[5];
NSRect visRect;
[self getVisibleRect:&visRect];
visRect = [self visibleRect];
//
// draw the image into imagebuffer
@ -762,11 +771,11 @@ drawSolid
// display the output
//
[self lockFocus];
[[self window] setBackingType:NS_RETAINED];
[[self window] setBackingType:NSBackingStoreRetained];
planes[0] = (unsigned char *)r_picbuffer;
NSDrawBitmap(
&visRect,
visRect,
r_width,
r_height,
8,
@ -775,12 +784,12 @@ drawSolid
r_width*4,
NO,
NO,
NS_RGBColorSpace,
NSCalibratedRGBColorSpace,
planes
);
NSPing ();
[[self window] setBackingType:NS_BUFFERED];
//NSPing ();
[[self window] setBackingType:NSBackingStoreBuffered];
[self unlockFocus];
return self;
@ -792,19 +801,20 @@ drawSelf
===================
*/
NSRect xy_draw_rect;
- drawSelf:(const NSRect *)rects :(int)rectCount
- drawSelf:(NSRect)rects :(int)rectCount
{
static float drawtime; // static to shut up compiler warning
if (timedrawing)
drawtime = I_FloatTime ();
xy_draw_rect = *rects;
xy_draw_rect = rects;
newrect.origin.x = newrect.origin.y = 99999;
newrect.size.width = newrect.size.height = -2*99999;
// setup for text
PSselectfont("Helvetica-Medium",10/scale);
//PSselectfont("Helvetica-Medium",10/scale);
GSSetFont (DEFCTXT, [NSFont fontWithName:@"Helvetica-Medium" size: 10/scale]);
PSrotate(0);
if (drawmode == dr_texture || drawmode == dr_flat)
@ -814,7 +824,7 @@ NSRect xy_draw_rect;
if (timedrawing)
{
NSPing ();
//NSPing ();
drawtime = I_FloatTime() - drawtime;
printf ("CameraView drawtime: %5.3f\n", drawtime);
}
@ -846,8 +856,8 @@ static NSPoint oldreletive;
NSPoint startpt, newpt;
NSPoint reletive, delta;
startpt = startevent->location;
[self convertPoint:&startpt fromView:NULL];
startpt = [startevent locationInWindow];
startpt = [self convertPoint:startpt fromView:NULL];
oldreletive.x = oldreletive.y = 0;
@ -859,19 +869,25 @@ static NSPoint oldreletive;
while (1)
{
event = [NSApp getNextEvent: NS_LMOUSEUPMASK | NS_LMOUSEDRAGGEDMASK
| NS_RMOUSEUPMASK | NS_RMOUSEDRAGGEDMASK | NS_APPDEFINEDMASK];
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
| NSRightMouseUpMask | NSRightMouseDraggedMask
| NSApplicationDefinedMask;
event = [NSApp nextEventMatchingMask: eventMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
if (event->type == NS_LMOUSEUP || event->type == NS_RMOUSEUP)
if ([event type] == NSLeftMouseUp || [event type] == NSRightMouseUp)
break;
if (event->type == NS_APPDEFINED)
if ([event type] == NSApplicationDefined)
{ // doesn't work. grrr.
[quakeed_i applicationDefined:event];
//[quakeed_i applicationDefined:event];
continue;
}
newpt = event->location;
[self convertPoint:&newpt fromView:NULL];
newpt = [event locationInWindow];
newpt = [self convertPoint:newpt fromView:NULL];
if (ug)
{
@ -929,8 +945,8 @@ void ScrollCallback (float dx, float dy)
NSPoint neworg;
float scale;
[ [xyview_i superview] getBounds: &basebounds];
[xyview_i convertRectFromSuperview: &basebounds];
basebounds = [[xyview_i superview] bounds];
[xyview_i convertRect: basebounds fromView: [xyview_i superview]];
neworg.x = basebounds.origin.x - dx;
neworg.y = basebounds.origin.y - dy;
@ -983,8 +999,8 @@ void DirectionCallback (float dx, float dy)
qprintf ("changing camera direction");
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
direction[0] = pt.x;
direction[1] = pt.y;
@ -1038,8 +1054,8 @@ void NewCallback (float dx, float dy)
qprintf ("sizing new brush");
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
neworg[0] = [self snapToGrid: pt.x];
neworg[1] = [self snapToGrid: pt.y];
@ -1095,8 +1111,8 @@ void ControlCallback (float dx, float dy)
if ([map_i numSelected] != 1)
return NO;
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
dragpoint[0] = pt.x;
dragpoint[1] = pt.y;
@ -1108,8 +1124,8 @@ void ControlCallback (float dx, float dy)
qprintf ("dragging brush plane");
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
[self dragFrom: theEvent
useGrid: YES
@ -1136,8 +1152,8 @@ void ControlCallback (float dx, float dy)
return NO;
br = [map_i selectedBrush];
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
// if the XY point is inside the brush, make the point on top
p1[0] = pt.x;
@ -1167,8 +1183,8 @@ void ControlCallback (float dx, float dy)
qprintf ("dragging brush plane");
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
[self dragFrom: theEvent
useGrid: YES
@ -1203,20 +1219,20 @@ mouseDown
vec3_t p1, p2;
int flags;
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
p1[0] = p2[0] = pt.x;
p1[1] = p2[1] = pt.y;
p1[2] = xy_viewnormal[2] * -4096;
p2[2] = xy_viewnormal[2] * 4096;
flags = theEvent->flags & (NS_SHIFTMASK | NS_CONTROLMASK | NS_ALTERNATEMASK | NS_COMMANDMASK);
flags = [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
//
// shift click to select / deselect a brush from the world
//
if (flags == NS_SHIFTMASK)
if (flags == NSShiftKeyMask)
{
[map_i selectRay: p1 : p2 : YES];
return self;
@ -1225,7 +1241,7 @@ mouseDown
//
// cmd-shift click to set a target/targetname entity connection
//
if (flags == (NS_SHIFTMASK|NS_COMMANDMASK) )
if (flags == (NSShiftKeyMask|NSCommandKeyMask) )
{
[map_i entityConnect: p1 : p2];
return self;
@ -1237,7 +1253,7 @@ mouseDown
if ( flags == 0 )
{
// if double click, position Z checker
if (theEvent->data.mouse.click > 1)
if ([theEvent clickCount] > 1)
{
qprintf ("positioned Z checker");
[zview_i setPoint: &pt];
@ -1247,7 +1263,7 @@ mouseDown
}
// check eye
if ( [cameraview_i XYmouseDown: &pt flags: theEvent->flags] )
if ( [cameraview_i XYmouseDown: &pt flags: [theEvent modifierFlags]] )
return self; // camera move
// check z post
@ -1279,12 +1295,12 @@ mouseDown
//
// control click = position and drag camera
//
if (flags == NS_CONTROLMASK)
if (flags == NSControlKeyMask)
{
[cameraview_i setXYOrigin: &pt];
[quakeed_i newinstance];
[cameraview_i display];
[cameraview_i XYmouseDown: &pt flags: theEvent->flags];
[cameraview_i XYmouseDown: &pt flags: [theEvent modifierFlags]];
qprintf ("");
return self;
}
@ -1292,7 +1308,7 @@ mouseDown
//
// command click = drag Z checker
//
if (flags == NS_COMMANDMASK)
if (flags == NSCommandKeyMask)
{
// check single plane dragging
[self shearDragFrom: theEvent];
@ -1309,7 +1325,7 @@ return self;
//
// alt click = set entire brush texture
//
if (flags == NS_ALTERNATEMASK)
if (flags == NSAlternateKeyMask)
{
if (drawmode != dr_texture)
{
@ -1325,7 +1341,7 @@ return self;
//
// ctrl-alt click = set single face texture
//
if (flags == (NS_CONTROLMASK | NS_ALTERNATEMASK) )
if (flags == (NSControlKeyMask | NSAlternateKeyMask) )
{
if (drawmode != dr_texture)
{
@ -1353,22 +1369,22 @@ rightMouseDown
NSPoint pt;
int flags;
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
flags = theEvent->flags & (NS_SHIFTMASK | NS_CONTROLMASK | NS_ALTERNATEMASK | NS_COMMANDMASK);
flags = [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
if (flags == NS_COMMANDMASK)
if (flags == NSCommandKeyMask)
{
return [self scrollDragFrom: theEvent];
}
if (flags == NS_ALTERNATEMASK)
if (flags == NSAlternateKeyMask)
{
return [clipper_i XYClick: pt];
}
if (flags == 0 || flags == NS_CONTROLMASK)
if (flags == 0 || flags == NSControlKeyMask)
{
return [self directionDragFrom: theEvent];
}

View file

@ -8,7 +8,7 @@
id button1;
}
- initFrame:(NSRect)frameRect button1: b1;
- initWithFrame:(NSRect)frameRect button1: b1;
- tile;
@end

View file

@ -1,4 +1,4 @@
#include "qedefs.h"
#include "ZScrollView.h"
@implementation ZScrollView
@ -10,7 +10,7 @@ Initizes a scroll view with a button at it's lower right corner
====================
*/
- initWithFrame:(const NSRect *)frameRect button1:b1
- initWithFrame:(NSRect)frameRect button1:b1
{
[super initWithFrame: frameRect];
@ -18,10 +18,10 @@ Initizes a scroll view with a button at it's lower right corner
button1 = b1;
[self setHorizScrollerRequired: YES];
[self setVertScrollerRequired: YES];
[self setHasHorizontalScroller: YES];
[self setHasVerticalScroller: YES];
[self setBorderType: NS_BEZEL];
[self setBorderType: NSBezelBorder];
return self;
}
@ -40,11 +40,11 @@ Adjust the size for the pop up scale menu
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];
return self;
}
@ -55,16 +55,16 @@ Adjust the size for the pop up scale menu
{
return YES;
}
/*
- superviewSizeChanged:(const NSSize *)oldSize
{
[super superviewSizeChanged: oldSize];
[[self docView] newSuperBounds];
[[self documentView] newSuperBounds];
return self;
}
*/
@end

View file

@ -2,7 +2,10 @@
#define ZView_h
#include <AppKit/AppKit.h>
#include "mathlib.h"
#include "QF/mathlib.h"
#include "render.h"
extern id zview_i;

View file

@ -1,5 +1,10 @@
#include "qedefs.h"
#include "ZView.h"
#include "ZScrollView.h"
#include "QuakeEd.h"
#include "Map.h"
#include "XYView.h"
#include "CameraView.h"
id zview_i;
@ -8,6 +13,8 @@ id zscrollview_i, zscalemenu_i, zscalebutton_i;
float zplane;
float zplanedir;
extern NSBezierPath *path;
@implementation ZView
/*
@ -48,7 +55,7 @@ initWithFrame:
// initialize the scroll view
zscrollview_i = [[ZScrollView alloc]
initFrame: frameRect
initWithFrame: frameRect
button1: zscalebutton_i
];
[zscrollview_i setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
@ -335,18 +342,18 @@ Rect is in global world (unscaled) coordinates
if (y<bottom)
y+= gridsize;
beginUserPath (upath,NO);
[path removeAllPoints];
for ( ; y<=stopy ; y+= gridsize)
if (y&31)
{
UPmoveto (upath, left, y);
UPlineto (upath, right, y);
[path moveToPoint: NSMakePoint (left, y)];
[path lineToPoint: NSMakePoint (right, y)];
}
endUserPath (upath, dps_ustroke);
//endUserPath (upath, dps_ustroke);
PSsetrgbcolor (0.8,0.8,1.0); // thin grid color
sendUserPath (upath);
[path stroke];
}
//
@ -362,17 +369,17 @@ Rect is in global world (unscaled) coordinates
if (stopy >= top)
stopy -= 32;
beginUserPath (upath,NO);
[path removeAllPoints];
for ( ; y<=stopy ; y+= 64)
{
UPmoveto (upath, left, y);
UPlineto (upath, right, y);
[path moveToPoint: NSMakePoint (left, y)];
[path lineToPoint: NSMakePoint (right, y)];
}
endUserPath (upath, dps_ustroke);
//endUserPath (upath, dps_ustroke);
PSsetgray (12.0/16.0);
sendUserPath (upath);
[path stroke];
//
// tiles
@ -387,9 +394,9 @@ Rect is in global world (unscaled) coordinates
if (stopy >= top)
stopy -= 64;
beginUserPath (upath,NO);
[path removeAllPoints];
PSsetgray (0); // for text
PSselectfont("Helvetica-Medium",10/scale);
GSSetFont (DEFCTXT, [NSFont fontWithName:@"Helvetica-Medium" size: 10/scale]);
PSrotate(0);
for ( ; y<=stopy ; y+= 64)
@ -400,17 +407,17 @@ Rect is in global world (unscaled) coordinates
PSmoveto(left,y);
PSshow(text);
}
UPmoveto (upath, left+24, y);
UPlineto (upath, right, y);
[path moveToPoint: NSMakePoint (left + 24, y)];
[path lineToPoint: NSMakePoint (right, y)];
}
// divider
UPmoveto (upath, 0, _bounds.origin.y);
UPlineto (upath, 0, _bounds.origin.y + _bounds.size.height);
[path moveToPoint: NSMakePoint (0, _bounds.origin.y)];
[path lineToPoint: NSMakePoint (0, _bounds.origin.y + _bounds.size.height)];
endUserPath (upath, dps_ustroke);
//endUserPath (upath, dps_ustroke);
PSsetgray (10.0/16.0);
sendUserPath (upath);
[path stroke];
//
// origin
@ -448,11 +455,11 @@ drawSelf
maxheight = -999999;
// allways draw the entire bar
[self getVisibleRect:&visRect];
visRect = [self visibleRect];
rects = &visRect;
// erase window
NSEraseRect (&rects[0]);
NSEraseRect (rects[0]);
// draw grid
[self drawGrid: &rects[0]];
@ -534,21 +541,27 @@ static NSPoint oldreletive;
gridsize = [xyview_i gridsize];
startpt = startevent->location;
[self convertPoint:&startpt fromView:NULL];
startpt = [startevent locationInWindow];
startpt = [self convertPoint:startpt fromView:NULL];
oldreletive.x = oldreletive.y = 0;
reletive.x = 0;
while (1)
{
event = [NSApp getNextEvent:
NSLeftMouseUpMask | NSLeftMouseDraggedMask
| NSRightMouseUpMask | NSRightMouseDraggedMask];
if (event->type == NSLeftMouseUp || event->type == NSRightMouseUp)
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
| NSRightMouseUpMask | NSRightMouseDraggedMask
| NSApplicationDefinedMask;
event = [NSApp nextEventMatchingMask: eventMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
if ([event type] == NSLeftMouseUp || [event type] == NSRightMouseUp)
break;
newpt = event->location;
[self convertPoint:&newpt fromView:NULL];
newpt = [event locationInWindow];
newpt = [self convertPoint:newpt fromView:NULL];
reletive.y = newpt.y - startpt.y;
@ -602,8 +615,8 @@ void ZScrollCallback (float dy)
NSPoint neworg;
float scale;
[ [zview_i _super_view] getBounds: &basebounds];
[zview_i convertRectFromSuperview: &basebounds];
basebounds = [[zview_i superview] bounds];
basebounds = [zview_i convertRect: basebounds fromView: [zview_i superview]];
neworg.y = basebounds.origin.y - dy;
@ -644,8 +657,8 @@ void ZControlCallback (float dy)
if ([map_i numSelected] != 1)
return NO;
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
dragpoint[0] = origin[0];
dragpoint[1] = origin[1];
@ -657,8 +670,8 @@ void ZControlCallback (float dy)
qprintf ("dragging brush plane");
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
[self dragFrom: theEvent
useGrid: YES
@ -685,14 +698,14 @@ mouseDown
int flags;
vec3_t p1;
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
p1[0] = origin[0];
p1[1] = origin[1];
p1[2] = pt.y;
flags = theEvent->flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
flags = [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
//
// shift click to select / deselect a brush from the world
@ -719,7 +732,7 @@ mouseDown
{
[cameraview_i setZOrigin: pt.y];
[quakeed_i updateAll];
[cameraview_i ZmouseDown: &pt flags:theEvent->flags];
[cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]];
return;
}
@ -729,7 +742,7 @@ mouseDown
if ( flags == 0 )
{
// check eye
if ( [cameraview_i ZmouseDown: &pt flags:theEvent->flags] )
if ( [cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]] )
return;
if ([map_i numSelected])
@ -760,10 +773,10 @@ rightMouseDown
NSPoint pt;
int flags;
pt= theEvent->location;
[self convertPoint:&pt fromView:NULL];
pt= [theEvent locationInWindow];
pt = [self convertPoint:pt fromView:NULL];
flags = theEvent->flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
flags = [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
//
@ -808,13 +821,13 @@ modalMoveLoop
//
goto drawentry;
while (event->type != NSLeftMouseUp)
while ([event type] != NSLeftMouseUp)
{
//
// calculate new point
//
newpt = event->location;
[converter convertPoint:&newpt fromView:NULL];
newpt = [event locationInWindow];
newpt = [converter convertPoint:newpt fromView:NULL];
delta[0] = newpt.x-basept->x;
delta[1] = newpt.y-basept->y;
@ -830,10 +843,12 @@ drawentry:
//
[quakeed_i newinstance];
[self display];
NSPing ();
event = [NSApp getNextEvent:
NSLeftMouseUpMask | NSLeftMouseDraggedMask];
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
event = [NSApp nextEventMatchingMask: eventMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
}
//

View file

@ -1,5 +1,4 @@
#include "qedefs.h"
char token[MAXTOKEN];

View file

@ -1,6 +1,10 @@
#ifndef render_h
#define render_h
#include "SetBrush.h"
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
extern int r_width, r_height;
extern unsigned *r_picbuffer;
extern float *r_zbuffer;

View file

@ -1,6 +1,7 @@
#include "qedefs.h"
#include "render.h"
extern vec3_t xy_viewnormal;
//define NOLIGHT
@ -511,7 +512,7 @@ REN_BeginCamera
===================
*/
float r_width_2, r_height_3;
plane_t frustum[5];
plane_t rfrustum[5];
void REN_BeginCamera (void)
{
@ -520,58 +521,58 @@ void REN_BeginCamera (void)
// clip to right side
frustum[0].normal[0] = -1;
frustum[0].normal[1] = 0;
frustum[0].normal[2] = 1;
frustum[0].dist = 0;
rfrustum[0].normal[0] = -1;
rfrustum[0].normal[1] = 0;
rfrustum[0].normal[2] = 1;
rfrustum[0].dist = 0;
// clip to left side
frustum[1].normal[0] = 1;
frustum[1].normal[1] = 0;
frustum[1].normal[2] = 1;
frustum[1].dist = 0;
rfrustum[1].normal[0] = 1;
rfrustum[1].normal[1] = 0;
rfrustum[1].normal[2] = 1;
rfrustum[1].dist = 0;
// clip to top side
frustum[2].normal[0] = 0;
frustum[2].normal[1] = -1;
frustum[2].normal[2] = r_height_3 / r_width_2;
frustum[2].dist = 0;
rfrustum[2].normal[0] = 0;
rfrustum[2].normal[1] = -1;
rfrustum[2].normal[2] = r_height_3 / r_width_2;
rfrustum[2].dist = 0;
// clip to bottom side
frustum[3].normal[0] = 0;
frustum[3].normal[1] = 1;
frustum[3].normal[2] = 2*r_height_3 / r_width_2;
frustum[3].dist = 0;
rfrustum[3].normal[0] = 0;
rfrustum[3].normal[1] = 1;
rfrustum[3].normal[2] = 2*r_height_3 / r_width_2;
rfrustum[3].dist = 0;
// near Z
frustum[4].normal[0] = 0;
frustum[4].normal[1] = 0;
frustum[4].normal[2] = 1;
frustum[4].dist = 1;
rfrustum[4].normal[0] = 0;
rfrustum[4].normal[1] = 0;
rfrustum[4].normal[2] = 1;
rfrustum[4].dist = 1;
}
void REN_BeginXY (void)
{
frustum[0].normal[0] = 1;
frustum[0].normal[1] = 0;
frustum[0].normal[2] = 0;
frustum[0].dist = 0;
rfrustum[0].normal[0] = 1;
rfrustum[0].normal[1] = 0;
rfrustum[0].normal[2] = 0;
rfrustum[0].dist = 0;
frustum[1].normal[0] = -1;
frustum[1].normal[1] = 0;
frustum[1].normal[2] = 0;
frustum[1].dist = -r_width;
rfrustum[1].normal[0] = -1;
rfrustum[1].normal[1] = 0;
rfrustum[1].normal[2] = 0;
rfrustum[1].dist = -r_width;
frustum[2].normal[0] = 0;
frustum[2].normal[1] = 1;
frustum[2].normal[2] = 0;
frustum[2].dist = 0;
rfrustum[2].normal[0] = 0;
rfrustum[2].normal[1] = 1;
rfrustum[2].normal[2] = 0;
rfrustum[2].dist = 0;
frustum[3].normal[0] = 0;
frustum[3].normal[1] = -1;
frustum[3].normal[2] = 0;
frustum[3].dist = -r_height;
rfrustum[3].normal[0] = 0;
rfrustum[3].normal[1] = -1;
rfrustum[3].normal[2] = 0;
rfrustum[3].dist = -r_height;
}
/*
@ -623,7 +624,7 @@ void REN_DrawCameraFace (face_t *idpol)
//
for (i=0 ; i<4 ; i++)
{
w = ClipWinding (w, &frustum[i]);
w = ClipWinding (w, &rfrustum[i]);
if (!w)
return;
}
@ -698,7 +699,7 @@ void REN_DrawXYFace (face_t *idpol)
//
for (i=0 ; i<4 ; i++)
{
w = ClipWinding (w, &frustum[i]);
w = ClipWinding (w, &rfrustum[i]);
if (!w)
return;
}