mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
Pass .m files through indent.
The result isn't perfect, but it cleans up the whitespace and makes the code more consistent with the rest of the project.
This commit is contained in:
parent
d3a12ee727
commit
d23300d58b
25 changed files with 5481 additions and 5886 deletions
File diff suppressed because it is too large
Load diff
|
@ -10,44 +10,39 @@
|
|||
#include "CameraView.h"
|
||||
#include "QuakeEd.h"
|
||||
|
||||
id clipper_i;
|
||||
id clipper_i;
|
||||
|
||||
@implementation Clipper
|
||||
|
||||
- init
|
||||
-init
|
||||
{
|
||||
[super init];
|
||||
clipper_i = self;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)hide
|
||||
-(BOOL) hide
|
||||
{
|
||||
int oldnum;
|
||||
int oldnum;
|
||||
|
||||
oldnum = num;
|
||||
num = 0;
|
||||
return (oldnum > 0);
|
||||
}
|
||||
|
||||
- flipNormal
|
||||
-flipNormal
|
||||
{
|
||||
vec3_t temp;
|
||||
vec3_t temp;
|
||||
|
||||
if (num == 2)
|
||||
{
|
||||
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
|
||||
{
|
||||
} else {
|
||||
Sys_Printf ("no clipplane");
|
||||
NSBeep ();
|
||||
}
|
||||
|
@ -55,22 +50,21 @@ id clipper_i;
|
|||
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);
|
||||
|
@ -79,10 +73,10 @@ id clipper_i;
|
|||
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];
|
||||
[texturepalette_i getTextureDef:&f->texture];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
@ -92,24 +86,22 @@ id clipper_i;
|
|||
XYClick
|
||||
================
|
||||
*/
|
||||
- XYClick: (NSPoint)pt
|
||||
-XYClick:(NSPoint) pt
|
||||
{
|
||||
int i;
|
||||
vec3_t new;
|
||||
int i;
|
||||
vec3_t new;
|
||||
|
||||
new[0] = [xyview_i snapToGrid: pt.x];
|
||||
new[1] = [xyview_i snapToGrid: pt.y];
|
||||
new[2] = [map_i currentMinZ];
|
||||
new[0] =[xyview_i snapToGrid:pt.x];
|
||||
new[1] =[xyview_i snapToGrid:pt.y];
|
||||
new[2] =[map_i currentMinZ];
|
||||
|
||||
// see if a point is allready there
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
if (new[0] == pos[i][0] && new[1] == pos[i][1])
|
||||
{
|
||||
if (pos[i][2] == [map_i currentMinZ])
|
||||
pos[i][2] = [map_i currentMaxZ];
|
||||
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
|
||||
pos[i][2] = [map_i currentMinZ];
|
||||
pos[i][2] =[map_i currentMinZ];
|
||||
[quakeed_i updateAll];
|
||||
return self;
|
||||
}
|
||||
|
@ -132,45 +124,43 @@ XYClick
|
|||
XYDrag
|
||||
================
|
||||
*/
|
||||
- (BOOL)XYDrag: (NSPoint *)pt
|
||||
-(BOOL) XYDrag:(NSPoint *) pt
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
if (fabs(pt->x - pos[i][0] > 10) || fabs(pt->y - pos[i][1] > 10) )
|
||||
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
|
||||
// drag this point
|
||||
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- ZClick: (NSPoint)pt
|
||||
-ZClick:(NSPoint) pt
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
- carve
|
||||
-carve
|
||||
{
|
||||
[map_i makeSelectedPerform: @selector(carveByClipper)];
|
||||
[map_i makeSelectedPerform:@selector (carveByClipper)];
|
||||
num = 0;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- cameraDrawSelf
|
||||
-cameraDrawSelf
|
||||
{
|
||||
vec3_t mid;
|
||||
int i;
|
||||
vec3_t mid;
|
||||
int i;
|
||||
|
||||
linecolor (1,0.5,0);
|
||||
linecolor (1, 0.5, 0);
|
||||
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
for (i = 0; i < num; i++) {
|
||||
VectorCopy (pos[i], mid);
|
||||
mid[0] -= 8;
|
||||
mid[1] -= 8;
|
||||
|
@ -191,43 +181,41 @@ XYDrag
|
|||
return self;
|
||||
}
|
||||
|
||||
- XYDrawSelf
|
||||
-XYDrawSelf
|
||||
{
|
||||
int i;
|
||||
char text[8];
|
||||
int i;
|
||||
char text[8];
|
||||
|
||||
PSsetrgbcolor (1,0.5,0);
|
||||
//XXX PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]);
|
||||
PSrotate(0);
|
||||
PSsetrgbcolor (1, 0.5, 0);
|
||||
// XXX PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]);
|
||||
PSrotate (0);
|
||||
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
PSmoveto (pos[i][0]-4, pos[i][1]-4);
|
||||
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);
|
||||
PSarc (pos[i][0], pos[i][1], 10, 0, 360);
|
||||
PSstroke ();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- ZDrawSelf
|
||||
-ZDrawSelf
|
||||
{
|
||||
int i;
|
||||
char text[8];
|
||||
int i;
|
||||
char text[8];
|
||||
|
||||
PSsetrgbcolor (1,0.5,0);
|
||||
//XXX PSselectfont("Helvetica-Medium",10/[zview_i currentScale]);
|
||||
PSrotate(0);
|
||||
PSsetrgbcolor (1, 0.5, 0);
|
||||
// XXX PSselectfont("Helvetica-Medium",10/[zview_i currentScale]);
|
||||
PSrotate (0);
|
||||
|
||||
for (i=0 ; i<num ; i++)
|
||||
{
|
||||
PSmoveto (-28+i*8 - 4, pos[i][2]-4);
|
||||
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);
|
||||
PSarc (-28 + i * 8, pos[i][2], 10, 0, 360);
|
||||
PSstroke ();
|
||||
}
|
||||
return self;
|
||||
|
|
|
@ -3,23 +3,21 @@
|
|||
|
||||
@implementation Dict
|
||||
|
||||
- init
|
||||
-init
|
||||
{
|
||||
[super initCount:0
|
||||
elementSize:sizeof(dict_t)
|
||||
description:NULL];
|
||||
[super initCount: 0 elementSize:sizeof (dict_t)
|
||||
description:NULL];
|
||||
return self;
|
||||
}
|
||||
|
||||
- print
|
||||
-print
|
||||
{
|
||||
int i;
|
||||
dict_t *d;
|
||||
int i;
|
||||
dict_t *d;
|
||||
|
||||
for (i=0 ; i<numElements ; i++)
|
||||
{
|
||||
d = [self elementAt: i];
|
||||
printf ("%s : %s\n",d->key, d->value);
|
||||
for (i = 0; i < numElements; i++) {
|
||||
d =[self elementAt:i];
|
||||
printf ("%s : %s\n", d->key, d->value);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -31,80 +29,75 @@ copyFromZone
|
|||
JDC
|
||||
===========
|
||||
*/
|
||||
- copy
|
||||
-copy
|
||||
{
|
||||
id new;
|
||||
int i;
|
||||
dict_t *d;
|
||||
char *old;
|
||||
id new;
|
||||
int i;
|
||||
dict_t *d;
|
||||
char *old;
|
||||
|
||||
new = [super copy];
|
||||
for (i=0 ; i<numElements ; i++)
|
||||
{
|
||||
d = [self elementAt: i];
|
||||
new =[super copy];
|
||||
for (i = 0; i < numElements; i++) {
|
||||
d =[self elementAt:i];
|
||||
old = d->key;
|
||||
d->key = malloc(strlen(old)+1);
|
||||
d->key = malloc (strlen (old) + 1);
|
||||
strcpy (d->key, old);
|
||||
|
||||
old = d->value;
|
||||
d->value = malloc(strlen(old)+1);
|
||||
d->value = malloc (strlen (old) + 1);
|
||||
strcpy (d->value, old);
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
- initFromFile:(FILE *)fp
|
||||
-initFromFile:(FILE *) fp
|
||||
{
|
||||
[self init];
|
||||
return [self parseBraceBlock:fp];
|
||||
return[self parseBraceBlock:fp];
|
||||
}
|
||||
|
||||
//===============================================
|
||||
//
|
||||
// Dictionary pair functions
|
||||
// Dictionary pair functions
|
||||
//
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// Write a { } block out to a FILE*
|
||||
// Write a { } block out to a FILE*
|
||||
//
|
||||
- writeBlockTo:(FILE *)fp
|
||||
-writeBlockTo:(FILE *) fp
|
||||
{
|
||||
int max;
|
||||
int i;
|
||||
dict_t *d;
|
||||
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");
|
||||
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");
|
||||
fprintf (fp, "}\n");
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Write a single { } block out
|
||||
// Write a single { } block out
|
||||
//
|
||||
- writeFile:(char *)path
|
||||
-writeFile:(char *) path
|
||||
{
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(path,"w+t");
|
||||
if (fp != NULL)
|
||||
{
|
||||
printf("Writing dictionary file %s.\n",path);
|
||||
fprintf(fp,"// QE_Project file %s\n",path);
|
||||
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);
|
||||
fclose (fp);
|
||||
} else {
|
||||
printf ("Error writing %s!\n", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -113,25 +106,24 @@ JDC
|
|||
|
||||
//===============================================
|
||||
//
|
||||
// Utility methods
|
||||
// Utility methods
|
||||
//
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// Find a keyword in storage
|
||||
// Returns * to dict_t, otherwise NULL
|
||||
// Find a keyword in storage
|
||||
// Returns * to dict_t, otherwise NULL
|
||||
//
|
||||
- (dict_t *) findKeyword:(char *)key
|
||||
-(dict_t *) findKeyword:(char *) key
|
||||
{
|
||||
int max;
|
||||
int i;
|
||||
dict_t *d;
|
||||
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))
|
||||
max =[super count];
|
||||
for (i = 0; i < max; i++) {
|
||||
d =[super elementAt:i];
|
||||
if (!strcmp (d->key, key))
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -139,39 +131,37 @@ JDC
|
|||
}
|
||||
|
||||
//
|
||||
// Change a keyword's string
|
||||
// Change a keyword's string
|
||||
//
|
||||
- changeStringFor:(char *)key to:(char *)value
|
||||
-changeStringFor:(char *)
|
||||
key to:(char *) value
|
||||
{
|
||||
dict_t *d;
|
||||
dict_t newd;
|
||||
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);
|
||||
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 *
|
||||
// Search for keyword, return the string *
|
||||
//
|
||||
- (char *)getStringFor:(char *)name
|
||||
-(char *) getStringFor:(char *) name
|
||||
{
|
||||
dict_t *d;
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:name];
|
||||
d =[self findKeyword:name];
|
||||
if (d != NULL)
|
||||
return d->value;
|
||||
|
||||
|
@ -179,55 +169,54 @@ JDC
|
|||
}
|
||||
|
||||
//
|
||||
// Search for keyword, return the value
|
||||
// Search for keyword, return the value
|
||||
//
|
||||
- (unsigned int)getValueFor:(char *)name
|
||||
-(unsigned int) getValueFor:(char *) name
|
||||
{
|
||||
dict_t *d;
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:name];
|
||||
d =[self findKeyword:name];
|
||||
if (d != NULL)
|
||||
return atol(d->value);
|
||||
return atol (d->value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Return # of units in keyword's value
|
||||
// Return # of units in keyword's value
|
||||
//
|
||||
- (int) getValueUnits:(char *)key
|
||||
-(int) getValueUnits:(char *) key
|
||||
{
|
||||
id temp;
|
||||
int count;
|
||||
id temp;
|
||||
int count;
|
||||
|
||||
temp = [self parseMultipleFrom:key];
|
||||
count = [temp count];
|
||||
temp =[self parseMultipleFrom:key];
|
||||
count =[temp count];
|
||||
[temp release];
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
//
|
||||
// Convert List to string
|
||||
// Convert List to string
|
||||
//
|
||||
- (char *)convertListToString:(id)list
|
||||
-(char *) convertListToString:(id) list
|
||||
{
|
||||
int i;
|
||||
int max;
|
||||
char tempstr[4096];
|
||||
char *s;
|
||||
char *newstr;
|
||||
int i;
|
||||
int max;
|
||||
char tempstr[4096];
|
||||
char *s;
|
||||
char *newstr;
|
||||
|
||||
max = [list count];
|
||||
max =[list count];
|
||||
tempstr[0] = 0;
|
||||
for (i = 0;i < max;i++)
|
||||
{
|
||||
s = [list elementAt:i];
|
||||
strcat(tempstr,s);
|
||||
strcat(tempstr," ");
|
||||
for (i = 0; i < max; i++) {
|
||||
s =[list elementAt:i];
|
||||
strcat (tempstr, s);
|
||||
strcat (tempstr, " ");
|
||||
}
|
||||
newstr = malloc(strlen(tempstr)+1);
|
||||
strcpy(newstr,tempstr);
|
||||
newstr = malloc (strlen (tempstr) + 1);
|
||||
strcpy (newstr, tempstr);
|
||||
|
||||
return newstr;
|
||||
}
|
||||
|
@ -235,41 +224,40 @@ JDC
|
|||
//
|
||||
// JDC: I wrote this to simplify removing vectors
|
||||
//
|
||||
- removeKeyword:(char *)key
|
||||
-removeKeyword:(char *) key
|
||||
{
|
||||
dict_t *d;
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:key];
|
||||
d =[self findKeyword:key];
|
||||
if (d == NULL)
|
||||
return self;
|
||||
[self removeElementAt:d - (dict_t*)dataPtr];
|
||||
[self removeElementAt:d - (dict_t *) dataPtr];
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Delete string from keyword's value
|
||||
// Delete string from keyword's value
|
||||
//
|
||||
- delString:(char *)string fromValue:(char *)key
|
||||
-delString:(char *)
|
||||
string fromValue:(char *) key
|
||||
{
|
||||
id temp;
|
||||
int count;
|
||||
int i;
|
||||
char *s;
|
||||
dict_t *d;
|
||||
id temp;
|
||||
int count;
|
||||
int i;
|
||||
char *s;
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:key];
|
||||
d =[self findKeyword:key];
|
||||
if (d == NULL)
|
||||
return NULL;
|
||||
temp = [self parseMultipleFrom:key];
|
||||
count = [temp count];
|
||||
for (i = 0;i < count;i++)
|
||||
{
|
||||
s = [temp elementAt:i];
|
||||
if (!strcmp(s,string))
|
||||
{
|
||||
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];
|
||||
free (d->value);
|
||||
d->value =[self convertListToString:temp];
|
||||
[temp release];
|
||||
|
||||
break;
|
||||
|
@ -279,22 +267,24 @@ JDC
|
|||
}
|
||||
|
||||
//
|
||||
// Add string to keyword's value
|
||||
// Add string to keyword's value
|
||||
//
|
||||
- addString:(char *)string toValue:(char *)key
|
||||
-addString:(char *)
|
||||
string toValue:(char *) key
|
||||
{
|
||||
char *newstr;
|
||||
char spacing[] = "\t";
|
||||
dict_t *d;
|
||||
char *newstr;
|
||||
char spacing[] = "\t";
|
||||
dict_t *d;
|
||||
|
||||
d = [self findKeyword:key];
|
||||
d =[self findKeyword:key];
|
||||
if (d == NULL)
|
||||
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);
|
||||
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;
|
||||
|
@ -302,60 +292,56 @@ JDC
|
|||
|
||||
//===============================================
|
||||
//
|
||||
// Use these for multiple parameters in a keyword value
|
||||
// Use these for multiple parameters in a keyword value
|
||||
//
|
||||
//===============================================
|
||||
char *searchStr;
|
||||
char item[4096];
|
||||
char *searchStr;
|
||||
char item[4096];
|
||||
|
||||
- setupMultiple:(char *)value
|
||||
-setupMultiple:(char *) value
|
||||
{
|
||||
searchStr = value;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (char *)getNextParameter
|
||||
-(char *) getNextParameter
|
||||
{
|
||||
char *s;
|
||||
char *s;
|
||||
|
||||
if (!searchStr)
|
||||
return NULL;
|
||||
strcpy(item,searchStr);
|
||||
s = FindWhitespcInBuffer(item);
|
||||
strcpy (item, searchStr);
|
||||
s = FindWhitespcInBuffer (item);
|
||||
if (!*s)
|
||||
searchStr = NULL;
|
||||
else
|
||||
{
|
||||
else {
|
||||
*s = 0;
|
||||
searchStr = FindNonwhitespcInBuffer(s+1);
|
||||
searchStr = FindNonwhitespcInBuffer (s + 1);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
//
|
||||
// Parses a keyvalue string & returns a Storage full of those items
|
||||
// Parses a keyvalue string & returns a Storage full of those items
|
||||
//
|
||||
- (id) parseMultipleFrom:(char *)key
|
||||
-(id) parseMultipleFrom:(char *) key
|
||||
{
|
||||
#define ITEMSIZE 128
|
||||
id stuff;
|
||||
char string[ITEMSIZE];
|
||||
char *s;
|
||||
#define ITEMSIZE 128
|
||||
id stuff;
|
||||
char string[ITEMSIZE];
|
||||
char *s;
|
||||
|
||||
s = [self getStringFor:key];
|
||||
s =[self getStringFor:key];
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
stuff = [[Storage alloc]
|
||||
initCount:0
|
||||
elementSize:ITEMSIZE
|
||||
description:NULL];
|
||||
stuff =[[Storage alloc]
|
||||
initCount: 0 elementSize: ITEMSIZE description:NULL];
|
||||
|
||||
[self setupMultiple:s];
|
||||
while((s = [self getNextParameter]))
|
||||
{
|
||||
bzero(string,ITEMSIZE);
|
||||
strcpy(string,s);
|
||||
while ((s =[self getNextParameter])) {
|
||||
bzero (string, ITEMSIZE);
|
||||
strcpy (string, s);
|
||||
[stuff addElement:string];
|
||||
}
|
||||
|
||||
|
@ -364,101 +350,96 @@ char item[4096];
|
|||
|
||||
//===============================================
|
||||
//
|
||||
// Dictionary pair parsing
|
||||
// Dictionary pair parsing
|
||||
//
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// parse all keyword/value pairs within { } 's
|
||||
// parse all keyword/value pairs within { } 's
|
||||
//
|
||||
- (id) parseBraceBlock:(FILE *)fp
|
||||
-(id) parseBraceBlock:(FILE *) fp
|
||||
{
|
||||
int c;
|
||||
dict_t pair;
|
||||
char string[1024];
|
||||
int c;
|
||||
dict_t pair;
|
||||
char string[1024];
|
||||
|
||||
c = FindBrace(fp);
|
||||
c = FindBrace (fp);
|
||||
if (c == -1)
|
||||
return NULL;
|
||||
|
||||
while((c = FindBrace(fp)) != '}')
|
||||
{
|
||||
while ((c = FindBrace (fp)) != '}') {
|
||||
if (c == -1)
|
||||
return NULL;
|
||||
// c = FindNonwhitespc(fp);
|
||||
// if (c == -1)
|
||||
// return NULL;
|
||||
// CopyUntilWhitespc(fp,string);
|
||||
// c = FindNonwhitespc(fp);
|
||||
// if (c == -1)
|
||||
// return NULL;
|
||||
// CopyUntilWhitespc(fp,string);
|
||||
|
||||
// JDC: fixed to allow quoted keys
|
||||
c = FindNonwhitespc(fp);
|
||||
c = FindNonwhitespc (fp);
|
||||
if (c == -1)
|
||||
return NULL;
|
||||
c = fgetc(fp);
|
||||
if ( c == '\"')
|
||||
CopyUntilQuote(fp,string);
|
||||
else
|
||||
{
|
||||
ungetc (c,fp);
|
||||
CopyUntilWhitespc(fp,string);
|
||||
c = fgetc (fp);
|
||||
if (c == '\"')
|
||||
CopyUntilQuote (fp, string);
|
||||
else {
|
||||
ungetc (c, fp);
|
||||
CopyUntilWhitespc (fp, string);
|
||||
}
|
||||
|
||||
pair.key = malloc(strlen(string)+1);
|
||||
strcpy(pair.key,string);
|
||||
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);
|
||||
c = FindQuote (fp);
|
||||
CopyUntilQuote (fp, string);
|
||||
pair.value = malloc (strlen (string) + 1);
|
||||
strcpy (pair.value, string);
|
||||
|
||||
[super addElement:&pair];
|
||||
c = FindBrace(fp);
|
||||
c = FindBrace (fp);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//===============================================
|
||||
//
|
||||
// C routines for string parsing
|
||||
// C routines for string parsing
|
||||
//
|
||||
//===============================================
|
||||
int GetNextChar(FILE *fp)
|
||||
int
|
||||
GetNextChar (FILE * fp)
|
||||
{
|
||||
int c;
|
||||
int c2;
|
||||
int c;
|
||||
int c2;
|
||||
|
||||
c = getc(fp);
|
||||
c = getc (fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c == '/') // parse comments
|
||||
if (c == '/') // parse comments
|
||||
{
|
||||
c2 = getc(fp);
|
||||
if (c2 == '/')
|
||||
{
|
||||
while((c2 = getc(fp)) != '\n');
|
||||
c = getc(fp);
|
||||
}
|
||||
else
|
||||
ungetc(c2,fp);
|
||||
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)
|
||||
void
|
||||
CopyUntilWhitespc (FILE * fp, char *buffer)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
while (count--) {
|
||||
c = GetNextChar (fp);
|
||||
if (c == EOF)
|
||||
return;
|
||||
if (c <= ' ')
|
||||
{
|
||||
if (c <= ' ') {
|
||||
*buffer = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -466,18 +447,17 @@ void CopyUntilWhitespc(FILE *fp,char *buffer)
|
|||
}
|
||||
}
|
||||
|
||||
void CopyUntilQuote(FILE *fp,char *buffer)
|
||||
void
|
||||
CopyUntilQuote (FILE * fp, char *buffer)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
while (count--) {
|
||||
c = GetNextChar (fp);
|
||||
if (c == EOF)
|
||||
return;
|
||||
if (c == '\"')
|
||||
{
|
||||
if (c == '\"') {
|
||||
*buffer = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -485,31 +465,30 @@ void CopyUntilQuote(FILE *fp,char *buffer)
|
|||
}
|
||||
}
|
||||
|
||||
int FindBrace(FILE *fp)
|
||||
int
|
||||
FindBrace (FILE * fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
while (count--) {
|
||||
c = GetNextChar (fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c == '{' ||
|
||||
c == '}')
|
||||
if (c == '{' || c == '}')
|
||||
return c;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FindQuote(FILE *fp)
|
||||
int
|
||||
FindQuote (FILE * fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
while (count--) {
|
||||
c = GetNextChar (fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c == '\"')
|
||||
|
@ -518,50 +497,49 @@ int FindQuote(FILE *fp)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int FindWhitespc(FILE *fp)
|
||||
int
|
||||
FindWhitespc (FILE * fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
while (count--) {
|
||||
c = GetNextChar (fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c <= ' ')
|
||||
{
|
||||
ungetc(c,fp);
|
||||
if (c <= ' ') {
|
||||
ungetc (c, fp);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int FindNonwhitespc(FILE *fp)
|
||||
int
|
||||
FindNonwhitespc (FILE * fp)
|
||||
{
|
||||
int count = 800;
|
||||
int c;
|
||||
int count = 800;
|
||||
int c;
|
||||
|
||||
while(count--)
|
||||
{
|
||||
c = GetNextChar(fp);
|
||||
while (count--) {
|
||||
c = GetNextChar (fp);
|
||||
if (c == EOF)
|
||||
return -1;
|
||||
if (c > ' ')
|
||||
{
|
||||
ungetc(c,fp);
|
||||
if (c > ' ') {
|
||||
ungetc (c, fp);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *FindWhitespcInBuffer(char *buffer)
|
||||
char *
|
||||
FindWhitespcInBuffer (char *buffer)
|
||||
{
|
||||
int count = 1000;
|
||||
char *b = buffer;
|
||||
int count = 1000;
|
||||
char *b = buffer;
|
||||
|
||||
while(count--)
|
||||
while (count--)
|
||||
if (*b <= ' ')
|
||||
return b;
|
||||
else
|
||||
|
@ -569,12 +547,13 @@ char *FindWhitespcInBuffer(char *buffer)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *FindNonwhitespcInBuffer(char *buffer)
|
||||
char *
|
||||
FindNonwhitespcInBuffer (char *buffer)
|
||||
{
|
||||
int count = 1000;
|
||||
char *b = buffer;
|
||||
int count = 1000;
|
||||
char *b = buffer;
|
||||
|
||||
while(count--)
|
||||
while (count--)
|
||||
if (*b > ' ')
|
||||
return b;
|
||||
else
|
||||
|
|
|
@ -3,64 +3,60 @@
|
|||
#include "Dict.h"
|
||||
|
||||
@implementation DictList
|
||||
|
||||
//
|
||||
// Read in variable # of objects from FILE *
|
||||
// Read in variable # of objects from FILE *
|
||||
//
|
||||
- initListFromFile:(FILE *)fp
|
||||
- initListFromFile:(FILE *) fp
|
||||
{
|
||||
id d;
|
||||
id d;
|
||||
|
||||
[super init];
|
||||
do
|
||||
{
|
||||
d = [(Dict *)[Dict alloc] initFromFile:fp];
|
||||
do {
|
||||
d =[(Dict *)[Dict alloc] initFromFile:fp];
|
||||
if (d != NULL)
|
||||
[self addObject:d];
|
||||
} while(d != NULL);
|
||||
} while (d != NULL);
|
||||
[d release];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Write out list file
|
||||
// Write out list file
|
||||
//
|
||||
- writeListFile:(char *)filename
|
||||
-writeListFile:(char *) filename
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
id obj;
|
||||
FILE *fp;
|
||||
int i;
|
||||
id obj;
|
||||
|
||||
fp = fopen(filename,"w+t");
|
||||
fp = fopen (filename, "w+t");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
fprintf(fp,"// Object List written by QuakeEd\n");
|
||||
fprintf (fp, "// Object List written by QuakeEd\n");
|
||||
|
||||
for (i = 0;i < [self count];i++)
|
||||
{
|
||||
obj = [self objectAtIndex:i];
|
||||
for (i = 0; i <[self count]; i++) {
|
||||
obj =[self objectAtIndex:i];
|
||||
[obj writeBlockTo:fp];
|
||||
}
|
||||
fclose(fp);
|
||||
fclose (fp);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Find the keyword in all the Dict objects
|
||||
// Find the keyword in all the Dict objects
|
||||
//
|
||||
- (id) findDictKeyword:(char *)key
|
||||
-(id) findDictKeyword:(char *) key
|
||||
{
|
||||
int i;
|
||||
dict_t *d;
|
||||
id dict;
|
||||
int i;
|
||||
dict_t *d;
|
||||
id dict;
|
||||
|
||||
for (i = 0;i < [self count];i++)
|
||||
{
|
||||
dict = [self objectAtIndex:i];
|
||||
d = [(Dict *)dict findKeyword:key];
|
||||
for (i = 0; i <[self count]; i++) {
|
||||
dict =[self objectAtIndex:i];
|
||||
d =[(Dict *) dict findKeyword:key];
|
||||
if (d != NULL)
|
||||
return dict;
|
||||
}
|
||||
|
|
|
@ -12,50 +12,49 @@
|
|||
|
||||
@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
|
||||
-createFixedBrush:(vec3_t) org
|
||||
{
|
||||
vec3_t emins, emaxs;
|
||||
float *v, *v2, *color;
|
||||
id new;
|
||||
texturedef_t td;
|
||||
vec3_t emins, emaxs;
|
||||
float *v, *v2, *color;
|
||||
id new;
|
||||
texturedef_t td;
|
||||
|
||||
// get class
|
||||
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
||||
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
|
||||
if (new) {
|
||||
v = [new mins];
|
||||
v2 = [new maxs];
|
||||
v =[new mins];
|
||||
v2 =[new maxs];
|
||||
} else {
|
||||
v = bad_mins;
|
||||
v2 = bad_maxs;
|
||||
}
|
||||
|
||||
color = [new drawColor];
|
||||
color =[new drawColor];
|
||||
|
||||
modifiable = NO;
|
||||
memset(&td,0,sizeof(td));
|
||||
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 setEntityColor: color];
|
||||
new =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
||||
[new setEntityColor:color];
|
||||
|
||||
[self addObject: new];
|
||||
[self addObject:new];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- initClass: (char *)classname
|
||||
-initClass:(char *) classname
|
||||
{
|
||||
id new;
|
||||
esize_t esize;
|
||||
char value[80];
|
||||
vec3_t min, max;
|
||||
float *v;
|
||||
id new;
|
||||
esize_t esize;
|
||||
char value[80];
|
||||
vec3_t min, max;
|
||||
float *v;
|
||||
|
||||
[super init];
|
||||
|
||||
|
@ -64,37 +63,34 @@ vec3_t bad_maxs = {8, 8, 8};
|
|||
[self setKey: "classname" toValue:classname];
|
||||
|
||||
// get class
|
||||
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
||||
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
|
||||
if (!new)
|
||||
esize = esize_model;
|
||||
else
|
||||
esize = [new esize];
|
||||
esize =[new esize];
|
||||
|
||||
// create a brush if needed
|
||||
if (esize == esize_fixed)
|
||||
{
|
||||
v = [new mins];
|
||||
[[map_i selectedBrush] getMins: min maxs: max];
|
||||
if (esize == esize_fixed) {
|
||||
v =[new mins];
|
||||
[[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];
|
||||
sprintf (value, "%i %i %i", (int) min[0], (int) min[1], (int) min[2]);
|
||||
[self setKey: "origin" toValue:value];
|
||||
|
||||
[self createFixedBrush: min];
|
||||
}
|
||||
else
|
||||
[self createFixedBrush:min];
|
||||
} else
|
||||
modifiable = YES;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
-(void) dealloc
|
||||
{
|
||||
epair_t *e, *n;
|
||||
epair_t *e, *n;
|
||||
|
||||
for (e=epairs ; e ; e=n)
|
||||
{
|
||||
for (e = epairs; e; e = n) {
|
||||
n = e->next;
|
||||
free (e->key);
|
||||
free (e->value);
|
||||
|
@ -103,50 +99,50 @@ vec3_t bad_maxs = {8, 8, 8};
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)modifiable
|
||||
-(BOOL) modifiable
|
||||
{
|
||||
return modifiable;
|
||||
}
|
||||
|
||||
- setModifiable: (BOOL)m
|
||||
-setModifiable:(BOOL) m
|
||||
{
|
||||
modifiable = m;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)removeObject: o
|
||||
-(void) removeObject:o
|
||||
{
|
||||
[super removeObject: o];
|
||||
[super removeObject:o];
|
||||
if ([self count])
|
||||
return;
|
||||
// the entity is empty, so remove the entire thing
|
||||
if ( self == [map_i objectAtIndex: 0])
|
||||
return; // never remove the world
|
||||
if (self ==[map_i objectAtIndex:0])
|
||||
return; // never remove the world
|
||||
|
||||
[map_i removeObject: self];
|
||||
[map_i removeObject:self];
|
||||
[self release];
|
||||
}
|
||||
|
||||
|
||||
- (char *)valueForQKey: (char *)k
|
||||
-(char *) valueForQKey:(char *) k
|
||||
{
|
||||
epair_t *e;
|
||||
static char ret[64];
|
||||
epair_t *e;
|
||||
static char ret[64];
|
||||
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
if (!strcmp(k,e->key))
|
||||
{
|
||||
for (e = epairs; e; e = e->next)
|
||||
if (!strcmp (k, e->key)) {
|
||||
strcpy (ret, e->value);
|
||||
return ret;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
- getVector: (vec3_t)v forKey: (char *)k
|
||||
-getVector:(vec3_t)
|
||||
v forKey:(char *) k
|
||||
{
|
||||
char *c;
|
||||
char *c;
|
||||
|
||||
c = [self valueForQKey: k];
|
||||
c =[self valueForQKey:k];
|
||||
|
||||
v[0] = v[1] = v[2] = 0;
|
||||
|
||||
|
@ -155,26 +151,27 @@ vec3_t bad_maxs = {8, 8, 8};
|
|||
return self;
|
||||
}
|
||||
|
||||
- print
|
||||
-print
|
||||
{
|
||||
epair_t *e;
|
||||
epair_t *e;
|
||||
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
printf ("%20s : %20s\n",e->key, e->value);
|
||||
for (e = epairs; e; e = e->next)
|
||||
printf ("%20s : %20s\n", e->key, e->value);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- setKey:(const char *)k toValue:(const char *)v
|
||||
-setKey:(const char *)
|
||||
k toValue:(const char *) v
|
||||
{
|
||||
epair_t *e;
|
||||
epair_t *e;
|
||||
|
||||
while (*k && *k <= ' ')
|
||||
k++;
|
||||
if (!*k)
|
||||
return self; // don't set NULL values
|
||||
return self; // don't set NULL values
|
||||
|
||||
for (e=epairs ; e ; e=e->next) {
|
||||
for (e = epairs; e; e = e->next) {
|
||||
if (!strcmp (k, e->key)) {
|
||||
free (e->value);
|
||||
e->value = strdup (v);
|
||||
|
@ -182,7 +179,7 @@ vec3_t bad_maxs = {8, 8, 8};
|
|||
}
|
||||
}
|
||||
|
||||
e = malloc (sizeof(epair_t));
|
||||
e = malloc (sizeof (epair_t));
|
||||
|
||||
e->key = strdup (k);
|
||||
e->value = strdup (v);
|
||||
|
@ -192,40 +189,37 @@ vec3_t bad_maxs = {8, 8, 8};
|
|||
return self;
|
||||
}
|
||||
|
||||
- (int)numPairs
|
||||
-(int) numPairs
|
||||
{
|
||||
int i;
|
||||
epair_t *e;
|
||||
int i;
|
||||
epair_t *e;
|
||||
|
||||
i=0;
|
||||
for (e=epairs ; e ; e=e->next)
|
||||
i = 0;
|
||||
for (e = epairs; e; e = e->next)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
- (epair_t *)epairs
|
||||
-(epair_t *) epairs
|
||||
{
|
||||
return epairs;
|
||||
}
|
||||
|
||||
- removeKeyPair: (char *)key
|
||||
-removeKeyPair:(char *) key
|
||||
{
|
||||
epair_t *e, *e2;
|
||||
epair_t *e, *e2;
|
||||
|
||||
if (!epairs)
|
||||
return self;
|
||||
e = epairs;
|
||||
if (!strcmp(e->key, key))
|
||||
{
|
||||
if (!strcmp (e->key, key)) {
|
||||
epairs = e->next;
|
||||
free (e);
|
||||
return self;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -245,37 +239,37 @@ targetname
|
|||
If the entity does not have a "targetname" key, a unique one is generated
|
||||
=============
|
||||
*/
|
||||
- (char *)targetname
|
||||
-(char *) targetname
|
||||
{
|
||||
char *t;
|
||||
int i, count;
|
||||
id ent;
|
||||
int tval, maxt;
|
||||
char name[20];
|
||||
char *t;
|
||||
int i, count;
|
||||
id ent;
|
||||
int tval, maxt;
|
||||
char name[20];
|
||||
|
||||
t = [self valueForQKey: "targetname"];
|
||||
t =[self valueForQKey:"targetname"];
|
||||
if (t && t[0])
|
||||
return t;
|
||||
|
||||
// make a unique name of the form t<number>
|
||||
count = [map_i count];
|
||||
count =[map_i count];
|
||||
maxt = 0;
|
||||
for (i=1 ; i<count ; i++)
|
||||
{
|
||||
ent = [map_i objectAtIndex: i];
|
||||
t = [ent valueForQKey: "targetname"];
|
||||
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);
|
||||
sprintf (name, "t%i", maxt + 1);
|
||||
|
||||
[self setKey: "targetname" toValue: name];
|
||||
[self setKey: "targetname" toValue:name];
|
||||
|
||||
return [self valueForQKey: "targetname"]; // so it's not on the stack
|
||||
return[self valueForQKey:"targetname"];
|
||||
// so it's not on the stack
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -286,40 +280,39 @@ FILE METHODS
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
int nument;
|
||||
int nument;
|
||||
|
||||
- initFromScript: (script_t *) script
|
||||
-initFromScript:(script_t *) script
|
||||
{
|
||||
char *key;
|
||||
id eclass, brush;
|
||||
char *spawn;
|
||||
vec3_t emins, emaxs;
|
||||
vec3_t org;
|
||||
texturedef_t td;
|
||||
esize_t esize;
|
||||
int i, c;
|
||||
float *color;
|
||||
char *key;
|
||||
id eclass, brush;
|
||||
char *spawn;
|
||||
vec3_t emins, emaxs;
|
||||
vec3_t org;
|
||||
texturedef_t td;
|
||||
esize_t esize;
|
||||
int i, c;
|
||||
float *color;
|
||||
|
||||
[self init];
|
||||
|
||||
if (!Script_GetToken (script, true))
|
||||
{
|
||||
if (!Script_GetToken (script, true)) {
|
||||
[self dealloc];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (strcmp (Script_Token (script), "{") )
|
||||
if (strcmp (Script_Token (script), "{"))
|
||||
Sys_Error ("initFromFileP: { not found");
|
||||
|
||||
do {
|
||||
if (!Script_GetToken (script, true))
|
||||
break;
|
||||
if (!strcmp (Script_Token (script), "}") )
|
||||
if (!strcmp (Script_Token (script), "}"))
|
||||
break;
|
||||
if (!strcmp (Script_Token (script), "{") ) {
|
||||
if (!strcmp (Script_Token (script), "{")) {
|
||||
// read a brush
|
||||
brush = [[SetBrush alloc] initFromScript: script owner:self];
|
||||
[self addObject: brush];
|
||||
brush =[[SetBrush alloc] initFromScript: script owner:self];
|
||||
[self addObject:brush];
|
||||
} else {
|
||||
// read a key / value pair
|
||||
key = strdup (Script_Token (script));
|
||||
|
@ -332,118 +325,110 @@ int nument;
|
|||
nument++;
|
||||
|
||||
// get class
|
||||
spawn = [self valueForQKey: "classname"];
|
||||
eclass = [entity_classes_i classForName: spawn];
|
||||
spawn =[self valueForQKey:"classname"];
|
||||
eclass =[entity_classes_i classForName:spawn];
|
||||
|
||||
esize = [eclass esize];
|
||||
esize =[eclass esize];
|
||||
|
||||
[self getVector: org forKey: "origin"];
|
||||
[self getVector: org forKey:"origin"];
|
||||
|
||||
if ([self count] && esize != esize_model)
|
||||
{
|
||||
if ([self count] && esize != esize_model) {
|
||||
printf ("WARNING:Entity with brushes and wrong model type\n");
|
||||
[self removeAllObjects];
|
||||
}
|
||||
|
||||
if (![self count] && esize == esize_model)
|
||||
{
|
||||
if (![self count] && esize == esize_model) {
|
||||
printf ("WARNING:Entity with no brushes and esize_model\n");
|
||||
[texturepalette_i getTextureDef: &td];
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
[texturepalette_i getTextureDef:&td];
|
||||
for (i = 0; i < 3; i++) {
|
||||
emins[i] = org[i] - 8;
|
||||
emaxs[i] = org[i] + 8;
|
||||
}
|
||||
brush = [[SetBrush alloc] initOwner: self mins:emins maxs:emaxs
|
||||
texture: &td];
|
||||
[self addObject: brush];
|
||||
brush =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
||||
[self addObject:brush];
|
||||
}
|
||||
|
||||
// create a brush if needed
|
||||
if (esize == esize_fixed)
|
||||
[self createFixedBrush: org];
|
||||
[self createFixedBrush:org];
|
||||
else
|
||||
modifiable = YES;
|
||||
|
||||
// set all the brush colors
|
||||
color = [eclass drawColor];
|
||||
color =[eclass drawColor];
|
||||
|
||||
c = [self count];
|
||||
for (i=0 ; i<c ; i++)
|
||||
{
|
||||
brush = [self objectAtIndex: i];
|
||||
[brush setEntityColor: color];
|
||||
c =[self count];
|
||||
for (i = 0; i < c; i++) {
|
||||
brush =[self objectAtIndex:i];
|
||||
[brush setEntityColor:color];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- writeToFILE: (FILE *)f region:(BOOL)reg;
|
||||
-writeToFILE:(FILE *)
|
||||
f region:(BOOL) reg;
|
||||
{
|
||||
epair_t *e;
|
||||
int i;
|
||||
id new;
|
||||
char value[80];
|
||||
vec3_t mins, maxs, org;
|
||||
epair_t *e;
|
||||
int i;
|
||||
id new;
|
||||
char value[80];
|
||||
vec3_t mins, maxs, org;
|
||||
const vec_t *v;
|
||||
BOOL temporg;
|
||||
char oldang[80];
|
||||
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
|
||||
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 objectAtIndex: 0]
|
||||
&& [[self objectAtIndex: 0] regioned] )
|
||||
return self; // skip the entire entity definition
|
||||
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 objectAtIndex:0]
|
||||
&&[[self objectAtIndex:0] regioned])
|
||||
return self; // skip the entire entity definition
|
||||
}
|
||||
|
||||
fprintf (f,"{\n");
|
||||
fprintf (f, "{\n");
|
||||
|
||||
// set an origin epair
|
||||
if (!modifiable)
|
||||
{
|
||||
[[self objectAtIndex: 0] getMins: mins maxs: maxs];
|
||||
if (temporg)
|
||||
{
|
||||
[cameraview_i getOrigin: mins];
|
||||
if (!modifiable) {
|
||||
[[self objectAtIndex: 0] getMins: mins maxs:maxs];
|
||||
if (temporg) {
|
||||
[cameraview_i getOrigin:mins];
|
||||
mins[0] -= 16;
|
||||
mins[1] -= 16;
|
||||
mins[2] -= 48;
|
||||
}
|
||||
new = [entity_classes_i classForName:
|
||||
[self valueForQKey: "classname"]];
|
||||
new =[entity_classes_i classForName:
|
||||
[self valueForQKey:"classname"]];
|
||||
if (new)
|
||||
v = [new mins];
|
||||
v =[new mins];
|
||||
else
|
||||
v = vec3_origin;
|
||||
|
||||
VectorSubtract (mins, v, org);
|
||||
sprintf (value, "%i %i %i",(int)org[0], (int)org[1], (int)org[2]);
|
||||
[self setKey:"origin" toValue: value];
|
||||
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);
|
||||
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];
|
||||
if (modifiable) {
|
||||
for (i = 0; i <[self count]; i++)
|
||||
[[self objectAtIndex: i] writeToFILE: f region:reg];
|
||||
}
|
||||
|
||||
fprintf (f,"}\n");
|
||||
fprintf (f, "}\n");
|
||||
|
||||
if (temporg)
|
||||
[self setKey: "angle" toValue: oldang];
|
||||
[self setKey: "angle" toValue:oldang];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
@implementation EntityClass
|
||||
|
||||
static int
|
||||
parse_vector (script_t *script, vec3_t vec)
|
||||
parse_vector (script_t * script, vec3_t vec)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -41,7 +41,8 @@ parse_vector (script_t *script, vec3_t vec)
|
|||
//
|
||||
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
|
||||
|
||||
- initFromText: (const char *)text source: (const char *)filename
|
||||
-initFromText:(const char *)
|
||||
text source:(const char *) filename
|
||||
{
|
||||
const char *t;
|
||||
size_t len;
|
||||
|
@ -50,7 +51,7 @@ parse_vector (script_t *script, vec3_t vec)
|
|||
|
||||
[super init];
|
||||
|
||||
text += strlen("/*QUAKED ");
|
||||
text += strlen ("/*QUAKED ");
|
||||
|
||||
script = Script_New ();
|
||||
Script_Start (script, filename, text);
|
||||
|
@ -93,8 +94,7 @@ parse_vector (script_t *script, vec3_t vec)
|
|||
Script_GetToken (script, 0);
|
||||
|
||||
// find the length until close comment
|
||||
for (t = script->p; 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;
|
||||
|
@ -105,38 +105,38 @@ parse_vector (script_t *script, vec3_t vec)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (esize_t)esize
|
||||
-(esize_t) esize
|
||||
{
|
||||
return esize;
|
||||
}
|
||||
|
||||
- (char *)classname
|
||||
-(char *) classname
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
- (float *)mins
|
||||
-(float *) mins
|
||||
{
|
||||
return mins;
|
||||
}
|
||||
|
||||
- (float *)maxs
|
||||
-(float *) maxs
|
||||
{
|
||||
return maxs;
|
||||
}
|
||||
|
||||
- (float *)drawColor
|
||||
-(float *) drawColor
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
- (char *)comments
|
||||
-(char *) comments
|
||||
{
|
||||
return comments;
|
||||
}
|
||||
|
||||
|
||||
- (char *)flagName: (unsigned)flagnum
|
||||
-(char *) flagName:(unsigned) flagnum
|
||||
{
|
||||
if (flagnum >= MAX_FLAGS)
|
||||
Sys_Error ("EntityClass flagName: bad number");
|
||||
|
@ -144,31 +144,27 @@ parse_vector (script_t *script, vec3_t vec)
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@implementation EntityClassList
|
||||
|
||||
/*
|
||||
=================
|
||||
insertEC:
|
||||
=================
|
||||
*/
|
||||
- (void)insertEC: ec
|
||||
- (void) insertEC:ec
|
||||
{
|
||||
char *name;
|
||||
int i;
|
||||
char *name;
|
||||
int i;
|
||||
|
||||
name = [ec classname];
|
||||
for (i=0 ; i<[self count] ; i++)
|
||||
{
|
||||
if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0)
|
||||
{
|
||||
name =[ec classname];
|
||||
for (i = 0; i <[self count]; i++) {
|
||||
if (strcasecmp (name,[[self objectAtIndex:i] classname]) < 0) {
|
||||
[self insertObject: ec atIndex:i];
|
||||
return;
|
||||
}
|
||||
}
|
||||
[self addObject: ec];
|
||||
[self addObject:ec];
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,16 +173,16 @@ insertEC:
|
|||
scanFile
|
||||
=================
|
||||
*/
|
||||
- (void)scanFile: (char *)filename
|
||||
-(void) scanFile:(char *) filename
|
||||
{
|
||||
int size, line;
|
||||
char *data;
|
||||
id cl;
|
||||
int i;
|
||||
char path[1024];
|
||||
QFile *file;
|
||||
int size, line;
|
||||
char *data;
|
||||
id cl;
|
||||
int i;
|
||||
char path[1024];
|
||||
QFile *file;
|
||||
|
||||
sprintf (path,"%s/%s", source_path, filename);
|
||||
sprintf (path, "%s/%s", source_path, filename);
|
||||
|
||||
file = Qopen (path, "rt");
|
||||
if (!file)
|
||||
|
@ -198,12 +194,12 @@ scanFile
|
|||
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)];
|
||||
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];
|
||||
[self insertEC:cl];
|
||||
} else if (data[i] == '\n') {
|
||||
line++;
|
||||
}
|
||||
|
@ -218,32 +214,32 @@ scanFile
|
|||
scanDirectory
|
||||
=================
|
||||
*/
|
||||
- (void)scanDirectory
|
||||
-(void) scanDirectory
|
||||
{
|
||||
int count, i;
|
||||
int count, i;
|
||||
struct dirent **namelist, *ent;
|
||||
|
||||
[self removeAllObjects];
|
||||
|
||||
count = scandir(source_path, &namelist, NULL, NULL);
|
||||
count = scandir (source_path, &namelist, NULL, NULL);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
int len;
|
||||
|
||||
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"))
|
||||
[self scanFile: ent->d_name];
|
||||
if (!strcmp (ent->d_name + len - 3, ".qc"))
|
||||
[self scanFile:ent->d_name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
id entity_classes_i;
|
||||
id entity_classes_i;
|
||||
|
||||
|
||||
- initForSourceDirectory: (char *)path
|
||||
-initForSourceDirectory:(char *) path
|
||||
{
|
||||
[super init];
|
||||
|
||||
|
@ -252,22 +248,22 @@ id entity_classes_i;
|
|||
|
||||
entity_classes_i = self;
|
||||
|
||||
nullclass = [[EntityClass alloc]
|
||||
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/"
|
||||
source: va ("%s:%d", __FILE__, __LINE__ - 1)];
|
||||
nullclass =[[EntityClass alloc]
|
||||
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/" source:va ("%s:%d", __FILE__,
|
||||
__LINE__ -
|
||||
1)];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)classForName: (char *)name
|
||||
-(id) classForName:(char *) name
|
||||
{
|
||||
int i;
|
||||
id o;
|
||||
int i;
|
||||
id o;
|
||||
|
||||
for (i=0 ; i<[self count] ; i++)
|
||||
{
|
||||
o = [self objectAtIndex: i];
|
||||
if (!strcmp (name,[o classname]) )
|
||||
for (i = 0; i <[self count]; i++) {
|
||||
o =[self objectAtIndex:i];
|
||||
if (!strcmp (name,[o classname]))
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -276,4 +272,3 @@ id entity_classes_i;
|
|||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -6,19 +6,18 @@
|
|||
#include "TexturePalette.h"
|
||||
#include "Preferences.h"
|
||||
|
||||
id inspcontrol_i;
|
||||
id inspcontrol_i;
|
||||
|
||||
@implementation InspectorControl
|
||||
|
||||
- awakeFromNib
|
||||
{
|
||||
-awakeFromNib {
|
||||
inspcontrol_i = self;
|
||||
|
||||
currentInspectorType = -1;
|
||||
|
||||
contentList = [[NSArray alloc] init];
|
||||
windowList = [[NSArray alloc] init];
|
||||
itemList = [[NSArray alloc] init];
|
||||
contentList =[[NSArray alloc] init];
|
||||
windowList =[[NSArray alloc] init];
|
||||
itemList =[[NSArray alloc] init];
|
||||
|
||||
// ADD NEW INSPECTORS HERE...
|
||||
|
||||
|
@ -61,7 +60,7 @@ id inspcontrol_i;
|
|||
|
||||
[inspectorView_i setAutoresizesSubviews:YES];
|
||||
|
||||
inspectorSubview_i = [contentList objectAtIndex:i_project];
|
||||
inspectorSubview_i =[contentList objectAtIndex:i_project];
|
||||
[inspectorView_i addSubview:inspectorSubview_i];
|
||||
|
||||
currentInspectorType = -1;
|
||||
|
@ -72,56 +71,57 @@ id inspcontrol_i;
|
|||
|
||||
|
||||
//
|
||||
// Sent by the PopUpList in the Inspector
|
||||
// Each cell in the PopUpList must have the correct tag
|
||||
// Sent by the PopUpList in the Inspector
|
||||
// Each cell in the PopUpList must have the correct tag
|
||||
//
|
||||
- changeInspector:sender
|
||||
-changeInspector:sender
|
||||
{
|
||||
id cell;
|
||||
id cell;
|
||||
|
||||
cell = [sender selectedCell];
|
||||
cell =[sender selectedCell];
|
||||
[self changeInspectorTo:[cell tag]];
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Change to specific Inspector
|
||||
// Change to specific Inspector
|
||||
//
|
||||
- changeInspectorTo:(insp_e)which
|
||||
-changeInspectorTo:(insp_e) which
|
||||
{
|
||||
id newView;
|
||||
NSRect r;
|
||||
id cell;
|
||||
NSRect f;
|
||||
id newView;
|
||||
NSRect r;
|
||||
id cell;
|
||||
NSRect f;
|
||||
|
||||
if (which == currentInspectorType)
|
||||
return self;
|
||||
|
||||
currentInspectorType = which;
|
||||
newView = [contentList objectAtIndex:which];
|
||||
newView =[contentList objectAtIndex:which];
|
||||
|
||||
cell = [itemList objectAtIndex:which]; // set PopUpButton title
|
||||
cell =[itemList objectAtIndex:which];// set PopUpButton title
|
||||
[popUpButton_i setTitle:[cell title]];
|
||||
|
||||
[inspectorView_i replaceSubview:inspectorSubview_i with:newView];
|
||||
r = [inspectorView_i frame];
|
||||
[inspectorView_i replaceSubview: inspectorSubview_i with:newView];
|
||||
r =[inspectorView_i frame];
|
||||
inspectorSubview_i = newView;
|
||||
[inspectorSubview_i setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
[inspectorSubview_i setAutoresizingMask:NSViewWidthSizable |
|
||||
NSViewHeightSizable];
|
||||
r.size.width -= 4;
|
||||
r.size.height -= 4;
|
||||
[inspectorSubview_i setFrameSize:r.size];
|
||||
|
||||
[inspectorSubview_i lockFocus];
|
||||
f = [inspectorSubview_i bounds];
|
||||
PSsetgray(NSLightGray);
|
||||
NSRectFill(f);
|
||||
f =[inspectorSubview_i bounds];
|
||||
PSsetgray (NSLightGray);
|
||||
NSRectFill (f);
|
||||
[inspectorSubview_i unlockFocus];
|
||||
[inspectorView_i display];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (insp_e)getCurrentInspector
|
||||
-(insp_e) getCurrentInspector
|
||||
{
|
||||
return currentInspectorType;
|
||||
}
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
#include "Entity.h"
|
||||
#include "Things.h"
|
||||
|
||||
id keypairview_i;
|
||||
id keypairview_i;
|
||||
|
||||
@implementation KeypairView
|
||||
|
||||
/*
|
||||
==================
|
||||
initWithFrame:
|
||||
==================
|
||||
*/
|
||||
- initWithFrame:(NSRect)frameRect
|
||||
- initWithFrame:(NSRect) frameRect
|
||||
{
|
||||
[super initWithFrame:frameRect];
|
||||
keypairview_i = self;
|
||||
|
@ -21,74 +20,72 @@ initWithFrame:
|
|||
}
|
||||
|
||||
|
||||
- calcViewSize
|
||||
-calcViewSize
|
||||
{
|
||||
NSRect b;
|
||||
NSPoint pt;
|
||||
int count;
|
||||
id ent;
|
||||
NSRect b;
|
||||
NSPoint pt;
|
||||
int count;
|
||||
id ent;
|
||||
|
||||
ent = [map_i currentEntity];
|
||||
count = [ent numPairs];
|
||||
ent =[map_i currentEntity];
|
||||
count =[ent numPairs];
|
||||
|
||||
//XXX[_super_view setFlipped: YES];
|
||||
// XXX[_super_view setFlipped: YES];
|
||||
|
||||
b = [_super_view bounds];
|
||||
b.size.height = LINEHEIGHT*count + SPACING;
|
||||
[self setBounds: b];
|
||||
b =[_super_view bounds];
|
||||
b.size.height = LINEHEIGHT * count + SPACING;
|
||||
[self setBounds:b];
|
||||
pt.x = pt.y = 0;
|
||||
[self scrollPoint: pt];
|
||||
[self scrollPoint:pt];
|
||||
return self;
|
||||
}
|
||||
|
||||
- drawSelf:(const NSRect *)rects :(int)rectCount
|
||||
-drawSelf: (const NSRect *) rects:(int) rectCount
|
||||
{
|
||||
epair_t *pair;
|
||||
int y;
|
||||
epair_t *pair;
|
||||
int y;
|
||||
|
||||
//XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||
PSrectfill(0,0,_bounds.size.width,_bounds.size.height);
|
||||
// XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||
PSrectfill (0, 0, _bounds.size.width, _bounds.size.height);
|
||||
|
||||
//XXX PSselectfont("Helvetica-Bold",FONTSIZE);
|
||||
PSrotate(0);
|
||||
PSsetgray(0);
|
||||
// XXX PSselectfont("Helvetica-Bold",FONTSIZE);
|
||||
PSrotate (0);
|
||||
PSsetgray (0);
|
||||
|
||||
pair = [[map_i currentEntity] epairs];
|
||||
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) {
|
||||
PSmoveto (SPACING, y);
|
||||
PSshow (pair->key);
|
||||
PSmoveto (100, y);
|
||||
PSshow (pair->value);
|
||||
y -= LINEHEIGHT;
|
||||
}
|
||||
PSstroke();
|
||||
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 =[theEvent locationInWindow];
|
||||
loc =[self convertPoint: loc fromView:NULL];
|
||||
|
||||
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
|
||||
|
||||
p = [[map_i currentEntity] epairs];
|
||||
while ( i )
|
||||
{
|
||||
p=p->next;
|
||||
p =[[map_i currentEntity] epairs];
|
||||
while (i) {
|
||||
p = p->next;
|
||||
if (!p)
|
||||
return;
|
||||
i--;
|
||||
}
|
||||
if (p)
|
||||
[things_i setSelectedKey: p];
|
||||
[things_i setSelectedKey:p];
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,6 @@
|
|||
#include "PopScrollView.h"
|
||||
|
||||
@implementation PopScrollView
|
||||
|
||||
/*
|
||||
====================
|
||||
initWithFrame: button:
|
||||
|
@ -10,57 +9,52 @@ initWithFrame: button:
|
|||
Initizes a scroll view with a button at it's lower right corner
|
||||
====================
|
||||
*/
|
||||
- initWithFrame:(NSRect)
|
||||
frameRect button1:b1 button2:b2 {
|
||||
[super initWithFrame:frameRect];
|
||||
|
||||
- initWithFrame:(NSRect)frameRect button1:b1 button2:b2
|
||||
{
|
||||
[super initWithFrame: frameRect];
|
||||
|
||||
[self addSubview: b1];
|
||||
[self addSubview: b2];
|
||||
[self addSubview:b1];
|
||||
[self addSubview:b2];
|
||||
|
||||
button1 = b1;
|
||||
button2 = b2;
|
||||
|
||||
[self setHasHorizontalScroller: YES];
|
||||
[self setHasVerticalScroller: YES];
|
||||
[self setHasHorizontalScroller:YES];
|
||||
[self setHasVerticalScroller:YES];
|
||||
|
||||
[self setBorderType: NSBezelBorder];
|
||||
[self setBorderType:NSBezelBorder];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
tile
|
||||
|
||||
Adjust the size for the pop up scale menu
|
||||
=================
|
||||
*/
|
||||
|
||||
- tile
|
||||
*/ -tile
|
||||
{
|
||||
NSRect scrollerframe;
|
||||
NSRect buttonframe, buttonframe2;
|
||||
NSRect newframe;
|
||||
NSRect scrollerframe;
|
||||
NSRect buttonframe, buttonframe2;
|
||||
NSRect newframe;
|
||||
|
||||
[super tile];
|
||||
buttonframe = [button1 frame];
|
||||
buttonframe2 = [button2 frame];
|
||||
scrollerframe = [_horizScroller frame];
|
||||
buttonframe =[button1 frame];
|
||||
buttonframe2 =[button2 frame];
|
||||
scrollerframe =[_horizScroller frame];
|
||||
|
||||
newframe.origin.y = scrollerframe.origin.y;
|
||||
newframe.origin.x = scrollerframe.size.width - buttonframe.size.width;
|
||||
newframe.size.width = buttonframe.size.width;
|
||||
newframe.size.height = scrollerframe.size.height;
|
||||
scrollerframe.size.width -= newframe.size.width;
|
||||
[button1 setFrame: newframe];
|
||||
[button1 setFrame:newframe];
|
||||
newframe.size.width = buttonframe2.size.width;
|
||||
newframe.origin.x -= newframe.size.width;
|
||||
[button2 setFrame: newframe];
|
||||
[button2 setFrame:newframe];
|
||||
scrollerframe.size.width -= newframe.size.width;
|
||||
|
||||
[_horizScroller setFrame: scrollerframe];
|
||||
[_horizScroller setFrame:scrollerframe];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -78,10 +72,9 @@ Adjust the size for the pop up scale menu
|
|||
|
||||
-(BOOL) acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -4,84 +4,90 @@
|
|||
#include "QuakeEd.h"
|
||||
#include "Project.h"
|
||||
|
||||
id preferences_i;
|
||||
id preferences_i;
|
||||
|
||||
#define DEFOWNER "QuakeEd2"
|
||||
|
||||
float lightaxis[3] = {1, 0.6, 0.75};
|
||||
float lightaxis[3] = { 1, 0.6, 0.75 };
|
||||
|
||||
@implementation Preferences
|
||||
|
||||
- init
|
||||
-init
|
||||
{
|
||||
[super init];
|
||||
preferences_i = self;
|
||||
return self;
|
||||
}
|
||||
|
||||
int _atoi (char *c)
|
||||
int
|
||||
_atoi (char *c)
|
||||
{
|
||||
if (!c)
|
||||
return 0;
|
||||
return atoi(c);
|
||||
return atoi (c);
|
||||
}
|
||||
|
||||
int _atof (char *c)
|
||||
int
|
||||
_atof (char *c)
|
||||
{
|
||||
if (!c)
|
||||
return 0;
|
||||
return atof(c);
|
||||
return atof (c);
|
||||
}
|
||||
|
||||
void WriteNumericDefault (char *name, float value)
|
||||
void
|
||||
WriteNumericDefault (char *name, float value)
|
||||
{
|
||||
char str[128];
|
||||
char str[128];
|
||||
|
||||
sprintf (str,"%f", value);
|
||||
//XXX NSWriteDefault (DEFOWNER, name, str);
|
||||
sprintf (str, "%f", value);
|
||||
// XXX NSWriteDefault (DEFOWNER, name, str);
|
||||
}
|
||||
void WriteStringDefault (char *name, char *value)
|
||||
|
||||
void
|
||||
WriteStringDefault (char *name, char *value)
|
||||
{
|
||||
//XXX NSWriteDefault (DEFOWNER, name, value);
|
||||
// XXX NSWriteDefault (DEFOWNER, name, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Read in at start of program
|
||||
// Read in at start of program
|
||||
//
|
||||
- readDefaults
|
||||
-readDefaults
|
||||
{
|
||||
char *string = "";
|
||||
float value = 0;
|
||||
char *string = "";
|
||||
float value = 0;
|
||||
|
||||
//XXX string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
|
||||
[self setProjectPath: string];
|
||||
// XXX string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
|
||||
[self setProjectPath:string];
|
||||
|
||||
//XXX string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
|
||||
// XXX string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
|
||||
[self setBspSoundPath:string];
|
||||
|
||||
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
|
||||
// XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
|
||||
[self setShowBSP:value];
|
||||
|
||||
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
|
||||
// XXX value = _atoi((char
|
||||
// *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
|
||||
[self setBrushOffset:value];
|
||||
|
||||
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
|
||||
// XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
|
||||
[self setStartWad:value];
|
||||
|
||||
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
|
||||
// XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
|
||||
[self setXlight:value];
|
||||
|
||||
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
|
||||
// XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
|
||||
[self setYlight:value];
|
||||
|
||||
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
|
||||
// XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
|
||||
[self setZlight:value];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- setProjectPath:(char *)path
|
||||
-setProjectPath:(char *) path
|
||||
{
|
||||
if (!path)
|
||||
path = "";
|
||||
|
@ -91,14 +97,15 @@ void WriteStringDefault (char *name, char *value)
|
|||
return self;
|
||||
}
|
||||
|
||||
- setCurrentProject:sender
|
||||
-setCurrentProject:sender
|
||||
{
|
||||
[startproject_i setStringValue: [NSString stringWithCString:[project_i currentProjectFile]]];
|
||||
[self UIChanged: self];
|
||||
[startproject_i setStringValue: [NSString stringWithCString:[project_i
|
||||
currentProjectFile]]];
|
||||
[self UIChanged:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (char *)getProjectPath
|
||||
-(char *) getProjectPath
|
||||
{
|
||||
return projectpath;
|
||||
}
|
||||
|
@ -106,35 +113,33 @@ void WriteStringDefault (char *name, char *value)
|
|||
|
||||
//
|
||||
//===============================================
|
||||
// BSP sound stuff
|
||||
// BSP sound stuff
|
||||
//===============================================
|
||||
//
|
||||
// Set the BSP sound using an OpenPanel
|
||||
// Set the BSP sound using an OpenPanel
|
||||
//
|
||||
- setBspSound:sender
|
||||
-setBspSound:sender
|
||||
{
|
||||
id panel;
|
||||
NSString *types[] = {@"snd"};
|
||||
int rtn;
|
||||
id panel;
|
||||
NSString *types[] = { @"snd" };
|
||||
int rtn;
|
||||
NSArray *filenames;
|
||||
char path[1024], file[64];
|
||||
char path[1024], file[64];
|
||||
|
||||
panel = [NSOpenPanel new];
|
||||
panel =[NSOpenPanel new];
|
||||
|
||||
//XXX ExtractFilePath (bspSound, path);
|
||||
//XXX ExtractFileBase (bspSound, file);
|
||||
// XXX ExtractFilePath (bspSound, path);
|
||||
// XXX ExtractFileBase (bspSound, file);
|
||||
|
||||
rtn = [panel
|
||||
runModalForDirectory:[NSString stringWithCString:path]
|
||||
file: [NSString stringWithCString:file]
|
||||
types: [NSArray arrayWithObjects:types count:1]];
|
||||
rtn =[panel runModalForDirectory: [NSString stringWithCString:path]
|
||||
file: [NSString stringWithCString:file]
|
||||
types: [NSArray arrayWithObjects: types count:1]];
|
||||
|
||||
if (rtn)
|
||||
{
|
||||
filenames = [panel filenames];
|
||||
strcpy(bspSound,[[panel directory] cString]);
|
||||
strcat(bspSound,"/");
|
||||
strcat(bspSound, [[filenames objectAtIndex:0] cString]);
|
||||
if (rtn) {
|
||||
filenames =[panel filenames];
|
||||
strcpy (bspSound,[[panel directory] cString]);
|
||||
strcat (bspSound, "/");
|
||||
strcat (bspSound,[[filenames objectAtIndex:0] cString]);
|
||||
[self setBspSoundPath:bspSound];
|
||||
[self playBspSound];
|
||||
}
|
||||
|
@ -144,9 +149,9 @@ void WriteStringDefault (char *name, char *value)
|
|||
|
||||
|
||||
//
|
||||
// Play the BSP sound
|
||||
// Play the BSP sound
|
||||
//
|
||||
- playBspSound
|
||||
-playBspSound
|
||||
{
|
||||
[bspSound_i play];
|
||||
return self;
|
||||
|
@ -154,24 +159,23 @@ void WriteStringDefault (char *name, char *value)
|
|||
|
||||
|
||||
//
|
||||
// Set the bspSound path
|
||||
// Set the bspSound path
|
||||
//
|
||||
- setBspSoundPath:(char *)path
|
||||
-setBspSoundPath:(char *) path
|
||||
{
|
||||
if (!path)
|
||||
path = "";
|
||||
strcpy(bspSound,path);
|
||||
strcpy (bspSound, path);
|
||||
|
||||
if (bspSound_i)
|
||||
[bspSound_i release];
|
||||
bspSound_i = [[NSSound alloc] initWithContentsOfFile:[NSString stringWithCString:bspSound]];
|
||||
if (!bspSound_i)
|
||||
{
|
||||
bspSound_i =[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:bspSound]];
|
||||
if (!bspSound_i) {
|
||||
strcpy (bspSound, "/NextLibrary/Sounds/Funk.snd");
|
||||
bspSound_i = [[NSSound alloc] initWithContentsOfFile:[NSString stringWithCString:bspSound]];
|
||||
bspSound_i =[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:bspSound]];
|
||||
}
|
||||
|
||||
[bspSoundField_i setStringValue:[NSString stringWithCString:bspSound]];
|
||||
[bspSoundField_i setStringValue: [NSString stringWithCString:bspSound]];
|
||||
|
||||
WriteStringDefault ("BspSoundPath", bspSound);
|
||||
|
||||
|
@ -179,13 +183,13 @@ void WriteStringDefault (char *name, char *value)
|
|||
}
|
||||
|
||||
//===============================================
|
||||
// Show BSP Output management
|
||||
// Show BSP Output management
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// Set the state
|
||||
// Set the state
|
||||
//
|
||||
- setShowBSP:(int)state
|
||||
-setShowBSP:(int) state
|
||||
{
|
||||
showBSP = state;
|
||||
[showBSP_i setIntValue:state];
|
||||
|
@ -195,22 +199,22 @@ void WriteStringDefault (char *name, char *value)
|
|||
}
|
||||
|
||||
//
|
||||
// Get the state
|
||||
// Get the state
|
||||
//
|
||||
- (int)getShowBSP
|
||||
-(int) getShowBSP
|
||||
{
|
||||
return showBSP;
|
||||
}
|
||||
|
||||
|
||||
//===============================================
|
||||
// "Offset Brush ..." management
|
||||
// "Offset Brush ..." management
|
||||
//===============================================
|
||||
|
||||
//
|
||||
// Set the state
|
||||
// Set the state
|
||||
//
|
||||
- setBrushOffset:(int)state
|
||||
-setBrushOffset:(int) state
|
||||
{
|
||||
brushOffset = state;
|
||||
[brushOffset_i setIntValue:state];
|
||||
|
@ -219,42 +223,42 @@ void WriteStringDefault (char *name, char *value)
|
|||
}
|
||||
|
||||
//
|
||||
// Get the state
|
||||
// Get the state
|
||||
//
|
||||
- (int)getBrushOffset
|
||||
-(int) getBrushOffset
|
||||
{
|
||||
return brushOffset;
|
||||
}
|
||||
|
||||
//===============================================
|
||||
// StartWad
|
||||
// StartWad
|
||||
//===============================================
|
||||
|
||||
- setStartWad:(int)value // set start wad (0-2)
|
||||
-setStartWad:(int) value // set start wad (0-2)
|
||||
{
|
||||
startwad = value;
|
||||
if (startwad<0 || startwad>2)
|
||||
if (startwad < 0 || startwad > 2)
|
||||
startwad = 0;
|
||||
|
||||
[startwad_i selectCellAtRow:startwad column: 0];
|
||||
[startwad_i selectCellAtRow: startwad column:0];
|
||||
|
||||
WriteNumericDefault ("StartWad", value);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int)getStartWad
|
||||
-(int) getStartWad
|
||||
{
|
||||
return startwad;
|
||||
}
|
||||
|
||||
|
||||
//===============================================
|
||||
// X,Y,Z light values
|
||||
// X,Y,Z light values
|
||||
//===============================================
|
||||
//
|
||||
// Set the state
|
||||
// Set the state
|
||||
//
|
||||
- setXlight:(float)value
|
||||
-setXlight:(float) value
|
||||
{
|
||||
xlight = value;
|
||||
if (xlight < 0.25 || xlight > 1)
|
||||
|
@ -264,7 +268,8 @@ void WriteStringDefault (char *name, char *value)
|
|||
WriteNumericDefault ("Xlight", xlight);
|
||||
return self;
|
||||
}
|
||||
- setYlight:(float)value
|
||||
|
||||
-setYlight:(float) value
|
||||
{
|
||||
ylight = value;
|
||||
if (ylight < 0.25 || ylight > 1)
|
||||
|
@ -274,7 +279,8 @@ void WriteStringDefault (char *name, char *value)
|
|||
WriteNumericDefault ("Ylight", ylight);
|
||||
return self;
|
||||
}
|
||||
- setZlight:(float)value
|
||||
|
||||
-setZlight:(float) value
|
||||
{
|
||||
zlight = value;
|
||||
if (zlight < 0.25 || zlight > 1)
|
||||
|
@ -286,19 +292,21 @@ void WriteStringDefault (char *name, char *value)
|
|||
}
|
||||
|
||||
//
|
||||
// Get the state
|
||||
// Get the state
|
||||
//
|
||||
- (float)getXlight
|
||||
-(float) getXlight
|
||||
{
|
||||
return [xlight_i floatValue];
|
||||
return[xlight_i floatValue];
|
||||
}
|
||||
- (float)getYlight
|
||||
|
||||
-(float) getYlight
|
||||
{
|
||||
return [ylight_i floatValue];
|
||||
return[ylight_i floatValue];
|
||||
}
|
||||
- (float)getZlight
|
||||
|
||||
-(float) getZlight
|
||||
{
|
||||
return [zlight_i floatValue];
|
||||
return[zlight_i floatValue];
|
||||
}
|
||||
|
||||
|
||||
|
@ -310,20 +318,20 @@ UIChanged
|
|||
Grab all the current UI state
|
||||
============
|
||||
*/
|
||||
-UIChanged: sender
|
||||
-UIChanged:sender
|
||||
{
|
||||
qprintf ("defaults updated");
|
||||
|
||||
[self setProjectPath: (char *)[startproject_i stringValue]];
|
||||
[self setBspSoundPath: (char *)[bspSoundField_i stringValue]];
|
||||
[self setShowBSP: [showBSP_i intValue]];
|
||||
[self setBrushOffset: [brushOffset_i intValue]];
|
||||
[self setStartWad: [startwad_i selectedRow]];
|
||||
[self setXlight: [xlight_i floatValue]];
|
||||
[self setYlight: [ylight_i floatValue]];
|
||||
[self setZlight: [zlight_i floatValue]];
|
||||
[self setProjectPath:(char *)[startproject_i stringValue]];
|
||||
[self setBspSoundPath:(char *)[bspSoundField_i stringValue]];
|
||||
[self setShowBSP:[showBSP_i intValue]];
|
||||
[self setBrushOffset:[brushOffset_i intValue]];
|
||||
[self setStartWad:[startwad_i selectedRow]];
|
||||
[self setXlight:[xlight_i floatValue]];
|
||||
[self setYlight:[ylight_i floatValue]];
|
||||
[self setZlight:[zlight_i floatValue]];
|
||||
|
||||
[map_i makeGlobalPerform: @selector(flushTextures)];
|
||||
[map_i makeGlobalPerform:@selector (flushTextures)];
|
||||
[quakeed_i updateAll];
|
||||
|
||||
return self;
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
#include "TexturePalette.h"
|
||||
|
||||
|
||||
id project_i;
|
||||
id project_i;
|
||||
|
||||
@implementation Project
|
||||
|
||||
- init
|
||||
-init
|
||||
{
|
||||
project_i = self;
|
||||
|
||||
|
@ -30,89 +30,83 @@ id project_i;
|
|||
|
||||
//===========================================================
|
||||
//
|
||||
// Project code
|
||||
// Project code
|
||||
//
|
||||
//===========================================================
|
||||
- initVars
|
||||
-initVars
|
||||
{
|
||||
char *s;
|
||||
char *s;
|
||||
|
||||
s = [preferences_i getProjectPath];
|
||||
//XXX StripFilename(s);
|
||||
strcpy(path_basepath,s);
|
||||
s =[preferences_i getProjectPath];
|
||||
// XXX StripFilename(s);
|
||||
strcpy (path_basepath, s);
|
||||
|
||||
strcpy(path_progdir,s);
|
||||
strcat(path_progdir,"/"SUBDIR_ENT);
|
||||
strcpy (path_progdir, s);
|
||||
strcat (path_progdir, "/" SUBDIR_ENT);
|
||||
|
||||
strcpy(path_mapdirectory,s);
|
||||
strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir
|
||||
strcpy (path_mapdirectory, s);
|
||||
strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir
|
||||
|
||||
strcpy(path_finalmapdir,s);
|
||||
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
||||
strcpy (path_finalmapdir, s);
|
||||
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
||||
|
||||
[basepathinfo_i setStringValue:[NSString stringWithCString:s]]; // in Project Inspector
|
||||
[basepathinfo_i setStringValue: [NSString stringWithCString:s]];
|
||||
// in Project Inspector
|
||||
|
||||
#if 0
|
||||
if ((s = [projectInfo getStringFor:BASEPATHKEY]))
|
||||
{
|
||||
strcpy(path_basepath,s);
|
||||
#if 0
|
||||
if ((s =[projectInfo getStringFor:BASEPATHKEY])) {
|
||||
strcpy (path_basepath, s);
|
||||
|
||||
strcpy(path_progdir,s);
|
||||
strcat(path_progdir,"/"SUBDIR_ENT);
|
||||
strcpy (path_progdir, s);
|
||||
strcat (path_progdir, "/" SUBDIR_ENT);
|
||||
|
||||
strcpy(path_mapdirectory,s);
|
||||
strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir
|
||||
strcpy (path_mapdirectory, s);
|
||||
strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir
|
||||
|
||||
strcpy(path_finalmapdir,s);
|
||||
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
||||
strcpy (path_finalmapdir, s);
|
||||
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
||||
|
||||
[basepathinfo_i setStringValue:s]; // in Project Inspector
|
||||
[basepathinfo_i setStringValue:s];
|
||||
// in Project Inspector
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPFULLVIS]))
|
||||
{
|
||||
strcpy(string_fullvis,s);
|
||||
changeString('@','\"',string_fullvis);
|
||||
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:BSPFASTVIS])) {
|
||||
strcpy (string_fastvis, s);
|
||||
changeString ('@', '\"', string_fastvis);
|
||||
}
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPNOVIS]))
|
||||
{
|
||||
strcpy(string_novis,s);
|
||||
changeString('@','\"',string_novis);
|
||||
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:BSPRELIGHT])) {
|
||||
strcpy (string_relight, s);
|
||||
changeString ('@', '\"', string_relight);
|
||||
}
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPLEAKTEST]))
|
||||
{
|
||||
strcpy(string_leaktest,s);
|
||||
changeString('@','\"',string_leaktest);
|
||||
if ((s =[projectInfo getStringFor:BSPLEAKTEST])) {
|
||||
strcpy (string_leaktest, s);
|
||||
changeString ('@', '\"', string_leaktest);
|
||||
}
|
||||
|
||||
if ((s = [projectInfo getStringFor:BSPENTITIES]))
|
||||
{
|
||||
strcpy(string_entities,s);
|
||||
changeString('@','\"', string_entities);
|
||||
if ((s =[projectInfo getStringFor:BSPENTITIES])) {
|
||||
strcpy (string_entities, s);
|
||||
changeString ('@', '\"', string_entities);
|
||||
}
|
||||
|
||||
// Build list of wads
|
||||
wadList = [projectInfo parseMultipleFrom:WADSKEY];
|
||||
wadList =[projectInfo parseMultipleFrom:WADSKEY];
|
||||
|
||||
// Build list of maps & descriptions
|
||||
mapList = [projectInfo parseMultipleFrom:MAPNAMESKEY];
|
||||
descList = [projectInfo parseMultipleFrom:DESCKEY];
|
||||
[self changeChar:'_' to:' ' in:descList];
|
||||
// Build list of maps & descriptions
|
||||
mapList =[projectInfo parseMultipleFrom:MAPNAMESKEY];
|
||||
descList =[projectInfo parseMultipleFrom:DESCKEY];
|
||||
[self changeChar: '_' to: ' ' in:descList];
|
||||
|
||||
[self initProjSettings];
|
||||
|
||||
|
@ -120,55 +114,55 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Init Project Settings fields
|
||||
// Init Project Settings fields
|
||||
//
|
||||
- initProjSettings
|
||||
-initProjSettings
|
||||
{
|
||||
[pis_basepath_i setStringValue:[NSString stringWithCString:path_basepath]];
|
||||
[pis_fullvis_i setStringValue:[NSString stringWithCString:string_fullvis]];
|
||||
[pis_fastvis_i setStringValue:[NSString stringWithCString:string_fastvis]];
|
||||
[pis_novis_i setStringValue:[NSString stringWithCString:string_novis]];
|
||||
[pis_relight_i setStringValue:[NSString stringWithCString:string_relight]];
|
||||
[pis_leaktest_i setStringValue:[NSString stringWithCString:string_leaktest]];
|
||||
[pis_basepath_i setStringValue: [NSString stringWithCString:path_basepath]];
|
||||
[pis_fullvis_i setStringValue: [NSString stringWithCString:string_fullvis]];
|
||||
[pis_fastvis_i setStringValue: [NSString stringWithCString:string_fastvis]];
|
||||
[pis_novis_i setStringValue: [NSString stringWithCString:string_novis]];
|
||||
[pis_relight_i setStringValue: [NSString stringWithCString:string_relight]];
|
||||
[pis_leaktest_i setStringValue: [NSString stringWithCString:string_leaktest]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Add text to the BSP Output window
|
||||
// Add text to the BSP Output window
|
||||
//
|
||||
- addToOutput:(char *)string
|
||||
-addToOutput:(char *) string
|
||||
{
|
||||
int end;
|
||||
int end;
|
||||
|
||||
end = [BSPoutput_i textLength];
|
||||
[BSPoutput_i replaceCharactersInRange:NSMakeRange (end, 0) withString:[NSString stringWithCString:string]];
|
||||
end =[BSPoutput_i textLength];
|
||||
[BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0) withString: [NSString stringWithCString:string]];
|
||||
|
||||
end = [BSPoutput_i textLength];
|
||||
end =[BSPoutput_i textLength];
|
||||
[BSPoutput_i setSelectedRange:NSMakeRange (end, 0)];
|
||||
//XXX [BSPoutput_i scrollSelToVisible];
|
||||
// XXX [BSPoutput_i scrollSelToVisible];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- clearBspOutput:sender
|
||||
-clearBspOutput:sender
|
||||
{
|
||||
int end;
|
||||
int end;
|
||||
|
||||
end = [BSPoutput_i textLength];
|
||||
[BSPoutput_i replaceCharactersInRange:NSMakeRange (0, end) withString:@""];
|
||||
end =[BSPoutput_i textLength];
|
||||
[BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString:@""];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- print
|
||||
-print
|
||||
{
|
||||
//XXX [BSPoutput_i printPSCode:self];
|
||||
// XXX [BSPoutput_i printPSCode:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- initProject
|
||||
-initProject
|
||||
{
|
||||
[self parseProjectFile];
|
||||
if (projectInfo == NULL)
|
||||
|
@ -179,57 +173,56 @@ id project_i;
|
|||
[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
|
||||
// Change a character to another in a Storage list of strings
|
||||
//
|
||||
- changeChar:(char)f to:(char)t in:(id)obj
|
||||
-changeChar:(char)
|
||||
f to:(char)
|
||||
t in:(id) obj
|
||||
{
|
||||
int i;
|
||||
int max;
|
||||
char *string;
|
||||
int i;
|
||||
int max;
|
||||
char *string;
|
||||
|
||||
max = [obj count];
|
||||
for (i = 0;i < max;i++)
|
||||
{
|
||||
string = [obj elementAt:i];
|
||||
changeString(f,t,string);
|
||||
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)
|
||||
// Fill the QuakeEd Maps or wads browser
|
||||
// (Delegate method - delegated in Interface Builder)
|
||||
//
|
||||
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
|
||||
-(int) browser: sender fillMatrix: matrix inColumn:(int) column
|
||||
{
|
||||
id cell, list;
|
||||
int max;
|
||||
char *name;
|
||||
int i;
|
||||
id cell, list;
|
||||
int max;
|
||||
char *name;
|
||||
int i;
|
||||
|
||||
if (sender == mapbrowse_i)
|
||||
list = mapList;
|
||||
else if (sender == pis_wads_i)
|
||||
list = wadList;
|
||||
else
|
||||
{
|
||||
else {
|
||||
list = nil;
|
||||
Sys_Error ("Project: unknown browser to fill");
|
||||
}
|
||||
|
||||
max = [list count];
|
||||
for (i = 0 ; i<max ; i++)
|
||||
{
|
||||
name = [list elementAt:i];
|
||||
max =[list count];
|
||||
for (i = 0; i < max; i++) {
|
||||
name =[list elementAt:i];
|
||||
[matrix addRow];
|
||||
cell = [matrix cellAtRow:i column:0];
|
||||
[cell setStringValue:[NSString stringWithCString:name]];
|
||||
cell =[matrix cellAtRow: i column:0];
|
||||
[cell setStringValue: [NSString stringWithCString:name]];
|
||||
[cell setLeaf:YES];
|
||||
[cell setLoaded:YES];
|
||||
}
|
||||
|
@ -237,55 +230,52 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Clicked on a map name or description!
|
||||
// Clicked on a map name or description!
|
||||
//
|
||||
- clickedOnMap:sender
|
||||
-clickedOnMap:sender
|
||||
{
|
||||
id matrix;
|
||||
int row;
|
||||
char fname[1024];
|
||||
id panel;
|
||||
id matrix;
|
||||
int row;
|
||||
char fname[1024];
|
||||
id panel;
|
||||
|
||||
matrix = [sender matrixInColumn:0];
|
||||
row = [matrix selectedRow];
|
||||
sprintf(fname,"%s/%s.map",path_mapdirectory,
|
||||
(char *)[mapList elementAt:row]);
|
||||
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 = NSGetAlertPanel (@"Loading...",
|
||||
@"Loading map. Please wait.", NULL, NULL, NULL);
|
||||
[panel orderFront:NULL];
|
||||
|
||||
[quakeed_i doOpen:fname];
|
||||
|
||||
[panel performClose:NULL];
|
||||
//NSFreeAlertPanel(panel);
|
||||
// NSFreeAlertPanel(panel);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- setTextureWad: (char *)wf
|
||||
-setTextureWad:(char *) wf
|
||||
{
|
||||
int i, c;
|
||||
char *name;
|
||||
int i, c;
|
||||
char *name;
|
||||
|
||||
qprintf ("loading %s", wf);
|
||||
|
||||
// set the row in the settings inspector wad browser
|
||||
c = [wadList count];
|
||||
for (i=0 ; i<c ; i++)
|
||||
{
|
||||
c =[wadList count];
|
||||
for (i = 0; i < c; i++) {
|
||||
name = (char *)[wadList elementAt:i];
|
||||
if (!strcmp(name, wf))
|
||||
{
|
||||
[[pis_wads_i matrixInColumn:0] selectCellAtRow: i column: 0];
|
||||
if (!strcmp (name, wf)) {
|
||||
[[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column:0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// update the texture inspector
|
||||
[texturepalette_i initPaletteFromWadfile:wf ];
|
||||
[[map_i objectAtIndex: 0] setKey:"wad" toValue: wf];
|
||||
// [inspcontrol_i changeInspectorTo:i_textures];
|
||||
[texturepalette_i initPaletteFromWadfile:wf];
|
||||
[[map_i objectAtIndex: 0] setKey: "wad" toValue:wf];
|
||||
// [inspcontrol_i changeInspectorTo:i_textures];
|
||||
|
||||
[quakeed_i updateAll];
|
||||
|
||||
|
@ -293,41 +283,40 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Clicked on a wad name
|
||||
// Clicked on a wad name
|
||||
//
|
||||
- clickedOnWad:sender
|
||||
-clickedOnWad:sender
|
||||
{
|
||||
id matrix;
|
||||
int row;
|
||||
char *name;
|
||||
id matrix;
|
||||
int row;
|
||||
char *name;
|
||||
|
||||
matrix = [sender matrixInColumn:0];
|
||||
row = [matrix selectedRow];
|
||||
matrix =[sender matrixInColumn:0];
|
||||
row =[matrix selectedRow];
|
||||
|
||||
name = (char *)[wadList elementAt:row];
|
||||
[self setTextureWad: name];
|
||||
[self setTextureWad:name];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Read in the <name>.QE_Project file
|
||||
// Read in the <name>.QE_Project file
|
||||
//
|
||||
- parseProjectFile
|
||||
-parseProjectFile
|
||||
{
|
||||
char *path;
|
||||
int rtn;
|
||||
char *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);
|
||||
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];
|
||||
while (1) // can't run without a project
|
||||
[NSApp terminate:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -336,58 +325,57 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Loads and parses a project file
|
||||
// Loads and parses a project file
|
||||
//
|
||||
- openProjectFile:(char *)path
|
||||
-openProjectFile:(char *) path
|
||||
{
|
||||
FILE *fp;
|
||||
struct stat s;
|
||||
FILE *fp;
|
||||
struct stat s;
|
||||
|
||||
strcpy(path_projectinfo,path);
|
||||
strcpy (path_projectinfo, path);
|
||||
|
||||
projectInfo = NULL;
|
||||
fp = fopen(path,"r+t");
|
||||
fp = fopen (path, "r+t");
|
||||
if (fp == NULL)
|
||||
return self;
|
||||
|
||||
stat(path,&s);
|
||||
stat (path, &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
|
||||
-(char *) currentProjectFile
|
||||
{
|
||||
return path_projectinfo;
|
||||
}
|
||||
|
||||
//
|
||||
// Open a project file
|
||||
// Open a project file
|
||||
//
|
||||
- openProject
|
||||
-openProject
|
||||
{
|
||||
char path[128];
|
||||
id openpanel;
|
||||
int rtn;
|
||||
NSString *projtypes[] ={ @"qpr"};
|
||||
char path[128];
|
||||
id openpanel;
|
||||
int rtn;
|
||||
NSString *projtypes[] = { @"qpr" };
|
||||
NSArray *filenames;
|
||||
const char *dir;
|
||||
|
||||
openpanel = [NSOpenPanel new];
|
||||
//[openpanel allowMultipleFiles:NO];
|
||||
//[openpanel chooseDirectories:NO];
|
||||
rtn = [openpanel runModalForTypes:[NSArray arrayWithObjects: projtypes count:1]];
|
||||
if (rtn == NSOKButton)
|
||||
{
|
||||
filenames = [openpanel filenames];
|
||||
dir = [[openpanel directory] cString];
|
||||
sprintf (path, "%s/%s", dir, [[filenames objectAtIndex:0] cString]);
|
||||
strcpy(path_projectinfo,path);
|
||||
[self openProjectFile:path];
|
||||
return self;
|
||||
openpanel =[NSOpenPanel new];
|
||||
// [openpanel allowMultipleFiles:NO];
|
||||
// [openpanel chooseDirectories:NO];
|
||||
rtn =[openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes count:1]];
|
||||
if (rtn == NSOKButton) {
|
||||
filenames =[openpanel filenames];
|
||||
dir =[[openpanel directory] cString];
|
||||
sprintf (path, "%s/%s", dir,[[filenames objectAtIndex:0] cString]);
|
||||
strcpy (path_projectinfo, path);
|
||||
[self openProjectFile:path];
|
||||
return self;
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
@ -395,44 +383,44 @@ id project_i;
|
|||
|
||||
|
||||
//
|
||||
// Search for a string in a List of strings
|
||||
// Search for a string in a List of strings
|
||||
//
|
||||
- (int)searchForString:(char *)str in:(id)obj
|
||||
-(int) searchForString:(char *)
|
||||
str in:(id) obj
|
||||
{
|
||||
int i;
|
||||
int max;
|
||||
char *s;
|
||||
int i;
|
||||
int max;
|
||||
char *s;
|
||||
|
||||
max = [obj count];
|
||||
for (i = 0;i < max; i++)
|
||||
{
|
||||
max =[obj count];
|
||||
for (i = 0; i < max; i++) {
|
||||
s = (char *)[obj elementAt:i];
|
||||
if (!strcmp(s,str))
|
||||
if (!strcmp (s, str))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (char *)getMapDirectory
|
||||
-(char *) getMapDirectory
|
||||
{
|
||||
return path_mapdirectory;
|
||||
}
|
||||
|
||||
- (char *)getFinalMapDirectory
|
||||
-(char *) getFinalMapDirectory
|
||||
{
|
||||
return path_finalmapdir;
|
||||
}
|
||||
|
||||
- (char *)getProgDirectory
|
||||
-(char *) getProgDirectory
|
||||
{
|
||||
return path_progdir;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return the WAD name for cmd-8
|
||||
// Return the WAD name for cmd-8
|
||||
//
|
||||
- (char *)getWAD8
|
||||
-(char *) getWAD8
|
||||
{
|
||||
if (!path_wad8[0])
|
||||
return NULL;
|
||||
|
@ -440,9 +428,9 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Return the WAD name for cmd-9
|
||||
// Return the WAD name for cmd-9
|
||||
//
|
||||
- (char *)getWAD9
|
||||
-(char *) getWAD9
|
||||
{
|
||||
if (!path_wad9[0])
|
||||
return NULL;
|
||||
|
@ -450,9 +438,9 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Return the WAD name for cmd-0
|
||||
// Return the WAD name for cmd-0
|
||||
//
|
||||
- (char *)getWAD0
|
||||
-(char *) getWAD0
|
||||
{
|
||||
if (!path_wad0[0])
|
||||
return NULL;
|
||||
|
@ -460,9 +448,9 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Return the FULLVIS cmd string
|
||||
// Return the FULLVIS cmd string
|
||||
//
|
||||
- (char *)getFullVisCmd
|
||||
-(char *) getFullVisCmd
|
||||
{
|
||||
if (!string_fullvis[0])
|
||||
return NULL;
|
||||
|
@ -470,9 +458,9 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Return the FASTVIS cmd string
|
||||
// Return the FASTVIS cmd string
|
||||
//
|
||||
- (char *)getFastVisCmd
|
||||
-(char *) getFastVisCmd
|
||||
{
|
||||
if (!string_fastvis[0])
|
||||
return NULL;
|
||||
|
@ -480,9 +468,9 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Return the NOVIS cmd string
|
||||
// Return the NOVIS cmd string
|
||||
//
|
||||
- (char *)getNoVisCmd
|
||||
-(char *) getNoVisCmd
|
||||
{
|
||||
if (!string_novis[0])
|
||||
return NULL;
|
||||
|
@ -490,9 +478,9 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Return the RELIGHT cmd string
|
||||
// Return the RELIGHT cmd string
|
||||
//
|
||||
- (char *)getRelightCmd
|
||||
-(char *) getRelightCmd
|
||||
{
|
||||
if (!string_relight[0])
|
||||
return NULL;
|
||||
|
@ -500,16 +488,16 @@ id project_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Return the LEAKTEST cmd string
|
||||
// Return the LEAKTEST cmd string
|
||||
//
|
||||
- (char *)getLeaktestCmd
|
||||
-(char *) getLeaktestCmd
|
||||
{
|
||||
if (!string_leaktest[0])
|
||||
return NULL;
|
||||
return string_leaktest;
|
||||
}
|
||||
|
||||
- (char *)getEntitiesCmd
|
||||
-(char *) getEntitiesCmd
|
||||
{
|
||||
if (!string_entities[0])
|
||||
return NULL;
|
||||
|
@ -517,21 +505,18 @@ id project_i;
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
//====================================================
|
||||
// C Functions
|
||||
//====================================================
|
||||
|
||||
//
|
||||
// Change a character to a different char in a string
|
||||
//
|
||||
void changeString(char cf,char ct,char *string)
|
||||
void
|
||||
changeString (char cf, char ct, char *string)
|
||||
{
|
||||
int j;
|
||||
int j;
|
||||
|
||||
for (j = 0;j < strlen(string);j++)
|
||||
for (j = 0; j < strlen (string); j++)
|
||||
if (string[j] == cf)
|
||||
string[j] = ct;
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
main (int argc, const char *argv[])
|
||||
{
|
||||
return NSApplicationMain (argc, argv);
|
||||
return NSApplicationMain (argc, argv);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,24 @@
|
|||
/* Implementation of Objective C NeXT-compatible Storage object
|
||||
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
This library is 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.
|
||||
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> */
|
||||
|
@ -28,257 +28,250 @@
|
|||
|
||||
|
||||
#define GNU_STORAGE_NTH(x,N) \
|
||||
({ GNUStorageId* __s=(GNUStorageId*)(x); \
|
||||
(void*)(((char*)__s->dataPtr)+(__s->elementSize*(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)
|
||||
@defs (Storage)
|
||||
} GNUStorageId;
|
||||
|
||||
@implementation Storage
|
||||
|
||||
+ initialize
|
||||
+initialize
|
||||
{
|
||||
if (self == [Storage class])
|
||||
[self setVersion:0]; /* beta release */
|
||||
return self;
|
||||
if (self ==[Storage class])
|
||||
[self setVersion:0]; /* beta release */
|
||||
return self;
|
||||
}
|
||||
|
||||
// INITIALIZING, FREEING;
|
||||
|
||||
- initCount: (NSUInteger)numSlots
|
||||
elementSize: (NSUInteger)sizeInBytes
|
||||
description: (const char*)elemDesc;
|
||||
-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;
|
||||
[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;
|
||||
}
|
||||
|
||||
- init
|
||||
-init
|
||||
{
|
||||
return [self initCount:1
|
||||
elementSize:sizeof(id)
|
||||
description:@encode(id)];
|
||||
return[self initCount: 1 elementSize:sizeof (id)
|
||||
description:@encode (id)];
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
-(void) dealloc
|
||||
{
|
||||
if (dataPtr)
|
||||
free(dataPtr);
|
||||
[super dealloc];
|
||||
if (dataPtr)
|
||||
free (dataPtr);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (const char*) description
|
||||
-(const char *) description
|
||||
{
|
||||
return description;
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
// COPYING;
|
||||
|
||||
- copy
|
||||
-copy
|
||||
{
|
||||
Storage *c = [super copy];
|
||||
c->dataPtr = (void*) objc_malloc (maxElements * elementSize);
|
||||
memcpy(c->dataPtr, dataPtr, numElements * elementSize);
|
||||
return c;
|
||||
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
|
||||
-(BOOL) isEqual:anObject
|
||||
{
|
||||
if ([anObject isKindOfClass: [Storage class]]
|
||||
&& [anObject count] == [self count]
|
||||
&& !memcmp(((GNUStorageId*)anObject)->dataPtr,
|
||||
dataPtr, numElements*elementSize))
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
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)
|
||||
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);
|
||||
}
|
||||
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)
|
||||
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);
|
||||
}
|
||||
if (self->numElements < (self->maxElements / 2)) {
|
||||
self->maxElements /= 2;
|
||||
self->dataPtr = (void *)
|
||||
objc_realloc (self->dataPtr, self->maxElements * self->elementSize);
|
||||
}
|
||||
}
|
||||
|
||||
- setAvailableCapacity:(NSUInteger)numSlots
|
||||
-setAvailableCapacity:(NSUInteger) numSlots
|
||||
{
|
||||
if (numSlots > numElements)
|
||||
{
|
||||
maxElements = numSlots;
|
||||
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
||||
}
|
||||
return self;
|
||||
if (numSlots > numElements) {
|
||||
maxElements = numSlots;
|
||||
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- setNumSlots:(NSUInteger)numSlots
|
||||
-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;
|
||||
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
|
||||
-(NSUInteger) count
|
||||
{
|
||||
return numElements;
|
||||
return numElements;
|
||||
}
|
||||
|
||||
- (void*) elementAt: (NSUInteger)index
|
||||
-(void *) elementAt:(NSUInteger) index
|
||||
{
|
||||
CHECK_INDEX(index);
|
||||
return STORAGE_NTH (index);
|
||||
CHECK_INDEX (index);
|
||||
return STORAGE_NTH (index);
|
||||
}
|
||||
|
||||
- addElement: (void*)anElement
|
||||
-addElement:(void *) anElement
|
||||
{
|
||||
_makeRoomForAnotherIfNecessary(self);
|
||||
memcpy(STORAGE_NTH(numElements), anElement, elementSize);
|
||||
numElements++;
|
||||
return self;
|
||||
_makeRoomForAnotherIfNecessary (self);
|
||||
memcpy (STORAGE_NTH (numElements), anElement, elementSize);
|
||||
numElements++;
|
||||
return self;
|
||||
}
|
||||
|
||||
- insertElement: (void*)anElement at: (NSUInteger)index
|
||||
-insertElement:(void *)
|
||||
anElement at:(NSUInteger) index
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
CHECK_INDEX(index);
|
||||
_makeRoomForAnotherIfNecessary(self);
|
||||
CHECK_INDEX (index);
|
||||
_makeRoomForAnotherIfNecessary (self);
|
||||
#ifndef STABLE_MEMCPY
|
||||
for (i = numElements; i >= index; i--)
|
||||
memcpy (STORAGE_NTH(i+1), STORAGE_NTH(i), elementSize);
|
||||
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));
|
||||
memcpy (STORAGE_NTH (index + 1),
|
||||
STORAGE_NTH (index), elementSize * (numElements - index));
|
||||
#endif
|
||||
memcpy(STORAGE_NTH(i), anElement, elementSize);
|
||||
numElements++;
|
||||
return self;
|
||||
memcpy (STORAGE_NTH (i), anElement, elementSize);
|
||||
numElements++;
|
||||
return self;
|
||||
}
|
||||
|
||||
- removeElementAt: (NSUInteger)index
|
||||
-removeElementAt:(NSUInteger) index
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
CHECK_INDEX(index);
|
||||
numElements--;
|
||||
CHECK_INDEX (index);
|
||||
numElements--;
|
||||
#ifndef STABLE_MEMCPY
|
||||
for (i = index; i < numElements; i++)
|
||||
memcpy(STORAGE_NTH(i),
|
||||
STORAGE_NTH(i+1),
|
||||
elementSize);
|
||||
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));
|
||||
memcpy (STORAGE_NTH (index),
|
||||
STORAGE_NTH (index + 1), elementSize * (numElements - index - 1));
|
||||
#endif
|
||||
_shrinkIfDesired(self);
|
||||
return self;
|
||||
_shrinkIfDesired (self);
|
||||
return self;
|
||||
}
|
||||
|
||||
- removeLastElement
|
||||
-removeLastElement
|
||||
{
|
||||
if (numElements)
|
||||
{
|
||||
numElements--;
|
||||
_shrinkIfDesired(self);
|
||||
}
|
||||
return self;
|
||||
if (numElements) {
|
||||
numElements--;
|
||||
_shrinkIfDesired (self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- replaceElementAt:(NSUInteger)index with:(void*)newElement
|
||||
-replaceElementAt:(NSUInteger)
|
||||
index with:(void *) newElement
|
||||
{
|
||||
CHECK_INDEX(index);
|
||||
memcpy(STORAGE_NTH(index), newElement, elementSize);
|
||||
return self;
|
||||
CHECK_INDEX (index);
|
||||
memcpy (STORAGE_NTH (index), newElement, elementSize);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Emptying the Storage */
|
||||
|
||||
- empty
|
||||
-empty
|
||||
{
|
||||
numElements = 0;
|
||||
maxElements = 1;
|
||||
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
||||
return self;
|
||||
numElements = 0;
|
||||
maxElements = 1;
|
||||
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Archiving */
|
||||
|
||||
- write: (TypedStream*)aStream
|
||||
-write:(TypedStream *) aStream
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
[super write:aStream];
|
||||
objc_write_types(aStream, "III*",
|
||||
&numElements, &maxElements, &elementSize, &description);
|
||||
for (i = 0; i < numElements; i++)
|
||||
objc_write_type(aStream, description, STORAGE_NTH(i));
|
||||
return self;
|
||||
[super write:aStream];
|
||||
objc_write_types (aStream, "III*",
|
||||
&numElements, &maxElements, &elementSize, &description);
|
||||
for (i = 0; i < numElements; i++)
|
||||
objc_write_type (aStream, description, STORAGE_NTH (i));
|
||||
return self;
|
||||
}
|
||||
|
||||
- read: (TypedStream*)aStream
|
||||
-read:(TypedStream *) aStream
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
[super read:aStream];
|
||||
objc_read_types(aStream, "III*",
|
||||
&numElements, &maxElements, &elementSize, &description);
|
||||
dataPtr = (void*) objc_malloc (maxElements * elementSize);
|
||||
for (i = 0; i < numElements; i++)
|
||||
objc_read_type(aStream, description, STORAGE_NTH(i));
|
||||
return self;
|
||||
[super read:aStream];
|
||||
objc_read_types (aStream, "III*",
|
||||
&numElements, &maxElements, &elementSize, &description);
|
||||
dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
||||
for (i = 0; i < numElements; i++)
|
||||
objc_read_type (aStream, description, STORAGE_NTH (i));
|
||||
return self;
|
||||
}
|
||||
|
||||
+ new
|
||||
+new
|
||||
{
|
||||
return [[self alloc] init];
|
||||
return[[self alloc] init];
|
||||
}
|
||||
|
||||
+ newCount:(NSUInteger)count elementSize:(NSUInteger)sizeInBytes
|
||||
description:(const char *)descriptor
|
||||
+newCount:(NSUInteger)
|
||||
count elementSize:(NSUInteger) sizeInBytes
|
||||
description:(const char *) descriptor
|
||||
{
|
||||
return [[self alloc] initCount:count elementSize:sizeInBytes
|
||||
description:descriptor];
|
||||
return[[self alloc] initCount: count elementSize: sizeInBytes description:descriptor];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,143 +13,136 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
|||
|
||||
@implementation TextureView
|
||||
|
||||
- init
|
||||
-init
|
||||
{
|
||||
deselectIndex = -1;
|
||||
return self;
|
||||
}
|
||||
|
||||
- setParent:(id)from
|
||||
-setParent:(id) from
|
||||
{
|
||||
parent_i = from;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstMouse
|
||||
-(BOOL) acceptsFirstMouse
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- drawSelf:(const NSRect *)rects :(int)rectCount
|
||||
-drawSelf: (const NSRect *) rects:(int) rectCount
|
||||
{
|
||||
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;
|
||||
|
||||
selected = [parent_i getSelectedTexture];
|
||||
list_i = [parent_i getList];
|
||||
GSSetFont (DEFCTXT, [NSFont fontWithName:@"Helvetica-Medium" size:FONTSIZE]);
|
||||
PSrotate(0);
|
||||
selected =[parent_i getSelectedTexture];
|
||||
list_i =[parent_i getList];
|
||||
GSSetFont (DEFCTXT,[NSFont fontWithName: @"Helvetica-Medium" size:FONTSIZE]);
|
||||
PSrotate (0);
|
||||
|
||||
PSsetgray(NSLightGray);
|
||||
PSrectfill(rects->origin.x, rects->origin.y,
|
||||
rects->size.width, rects->size.height);
|
||||
PSsetgray (NSLightGray);
|
||||
PSrectfill (rects->origin.x, rects->origin.y,
|
||||
rects->size.width, rects->size.height);
|
||||
|
||||
if (!list_i) // WADfile didn't init
|
||||
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;
|
||||
r.size.width += TEX_INDENT * 2;
|
||||
r.size.height += TEX_INDENT * 2;
|
||||
|
||||
//XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||
PSrectfill(r.origin.x, r.origin.y,
|
||||
r.size.width, r.size.height);
|
||||
// XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||
PSrectfill (r.origin.x, r.origin.y, r.size.width, r.size.height);
|
||||
p = t->r.origin;
|
||||
p.y += TEX_SPACING;
|
||||
[t->image drawAtPoint:p fromRect:r operation:NSCompositeCopy fraction:1.0];
|
||||
PSsetgray(0);
|
||||
[t->image drawAtPoint: p fromRect: r operation: NSCompositeCopy fraction:1.0];
|
||||
PSsetgray (0);
|
||||
x = t->r.origin.x;
|
||||
y = t->r.origin.y + 7;
|
||||
PSmoveto(x,y);
|
||||
PSshow(t->name);
|
||||
PSstroke();
|
||||
PSmoveto (x, y);
|
||||
PSshow (t->name);
|
||||
PSstroke ();
|
||||
deselectIndex = -1;
|
||||
}
|
||||
|
||||
max = [list_i count];
|
||||
PSsetgray(0);
|
||||
max =[list_i count];
|
||||
PSsetgray (0);
|
||||
|
||||
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[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);
|
||||
}
|
||||
|
||||
p = t->r.origin;
|
||||
p.y += TEX_SPACING;
|
||||
[t->image drawAtPoint:p fromRect:r operation:NSCompositeCopy fraction:1.0];
|
||||
[t->image drawAtPoint: p fromRect: r operation: NSCompositeCopy fraction:1.0];
|
||||
x = t->r.origin.x;
|
||||
y = t->r.origin.y + 7;
|
||||
PSmoveto(x,y);
|
||||
PSshow(t->name);
|
||||
PSmoveto (x, y);
|
||||
PSshow (t->name);
|
||||
}
|
||||
}
|
||||
PSstroke();
|
||||
PSstroke ();
|
||||
return self;
|
||||
}
|
||||
|
||||
- deselect
|
||||
-deselect
|
||||
{
|
||||
deselectIndex = [parent_i getSelectedTexture];
|
||||
deselectIndex =[parent_i getSelectedTexture];
|
||||
return self;
|
||||
}
|
||||
|
||||
- mouseDown:(NSEvent *)theEvent
|
||||
-mouseDown:(NSEvent *) theEvent
|
||||
{
|
||||
NSPoint loc;
|
||||
int i;
|
||||
int max;
|
||||
//int oldwindowmask;
|
||||
texpal_t *t;
|
||||
id list;
|
||||
NSRect r;
|
||||
NSPoint loc;
|
||||
int i;
|
||||
int max;
|
||||
|
||||
//oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
||||
loc = [theEvent locationInWindow];
|
||||
[self convertPoint:loc fromView:NULL];
|
||||
// int oldwindowmask;
|
||||
texpal_t *t;
|
||||
id list;
|
||||
NSRect r;
|
||||
|
||||
list = [parent_i getList];
|
||||
max = [list count];
|
||||
for (i = 0;i < max; i++)
|
||||
{
|
||||
t = [list elementAt:i];
|
||||
// oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
||||
loc =[theEvent locationInWindow];
|
||||
[self convertPoint: loc fromView:NULL];
|
||||
|
||||
list =[parent_i getList];
|
||||
max =[list count];
|
||||
for (i = 0; i < max; i++) {
|
||||
t =[list elementAt:i];
|
||||
r = t->r;
|
||||
if (NSPointInRect(loc,r) == YES)
|
||||
{
|
||||
if (NSPointInRect (loc, r) == YES) {
|
||||
[self deselect];
|
||||
[parent_i setSelectedTexture:i];
|
||||
[parent_i setSelectedTexture:i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//[window setEventMask:oldwindowmask];
|
||||
// [window setEventMask:oldwindowmask];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include "KeypairView.h"
|
||||
#include "Project.h"
|
||||
|
||||
id things_i;
|
||||
id things_i;
|
||||
|
||||
@implementation Things
|
||||
|
||||
- init
|
||||
-init
|
||||
{
|
||||
[super init];
|
||||
|
||||
|
@ -21,192 +21,189 @@ id things_i;
|
|||
}
|
||||
|
||||
//
|
||||
// Load the TEXT object with the entity comment
|
||||
// Load the TEXT object with the entity comment
|
||||
//
|
||||
- loadEntityComment:(id)obj
|
||||
-loadEntityComment:(id) obj
|
||||
{
|
||||
[entity_comment_i selectAll:self];
|
||||
[entity_comment_i replaceCharactersInRange:[entity_comment_i selectedRange] withString:[NSString stringWithCString:[obj comments]]];
|
||||
[entity_comment_i replaceCharactersInRange: [entity_comment_i selectedRange] withString: [NSString stringWithCString:[obj
|
||||
comments]]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- initEntities
|
||||
-initEntities
|
||||
{
|
||||
char *path;
|
||||
char *path;
|
||||
|
||||
path = [project_i getProgDirectory];
|
||||
path =[project_i getProgDirectory];
|
||||
|
||||
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
||||
|
||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||
[[EntityClassList alloc] initForSourceDirectory:path];
|
||||
|
||||
[self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
|
||||
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
||||
[entity_browser_i loadColumnZero];
|
||||
[[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
|
||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
||||
|
||||
[entity_browser_i setDoubleAction: @selector(doubleClickEntity:)];
|
||||
[entity_browser_i setDoubleAction: @selector (doubleClickEntity:)];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- selectEntity: sender
|
||||
-selectEntity:sender
|
||||
{
|
||||
id matr;
|
||||
id matr;
|
||||
|
||||
matr = [sender matrixInColumn: 0];
|
||||
lastSelected = [matr selectedRow];
|
||||
[self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
matr =[sender matrixInColumn:0];
|
||||
lastSelected =[matr selectedRow];
|
||||
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
||||
[quakeed_i makeFirstResponder:quakeed_i];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- doubleClickEntity: sender
|
||||
-doubleClickEntity:sender
|
||||
{
|
||||
[map_i makeEntity: sender];
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
[map_i makeEntity:sender];
|
||||
[quakeed_i makeFirstResponder:quakeed_i];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (char *)spawnName
|
||||
-(char *) spawnName
|
||||
{
|
||||
return [[entity_classes_i objectAtIndex:lastSelected] classname];
|
||||
return[[entity_classes_i objectAtIndex:lastSelected] classname];
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Flush entity classes & reload them!
|
||||
// Flush entity classes & reload them!
|
||||
//
|
||||
- reloadEntityClasses: sender
|
||||
-reloadEntityClasses:sender
|
||||
{
|
||||
EntityClass *ent;
|
||||
char *path;
|
||||
char *path;
|
||||
|
||||
path = (char *)[prog_path_i stringValue];
|
||||
if (!path || !path[0])
|
||||
{
|
||||
path = [project_i getProgDirectory];
|
||||
if (!path || !path[0]) {
|
||||
path =[project_i getProgDirectory];
|
||||
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
||||
}
|
||||
|
||||
// Free all entity info in memory...
|
||||
// Free all entity info in memory...
|
||||
[entity_classes_i removeAllObjects];
|
||||
[entity_classes_i release];
|
||||
|
||||
// Now, RELOAD!
|
||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||
// Now, RELOAD!
|
||||
[[EntityClassList alloc] initForSourceDirectory:path];
|
||||
|
||||
lastSelected = 0;
|
||||
ent = [entity_classes_i objectAtIndex:lastSelected];
|
||||
[self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
|
||||
ent =[entity_classes_i objectAtIndex:lastSelected];
|
||||
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
||||
|
||||
[entity_browser_i loadColumnZero];
|
||||
[[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
|
||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
||||
|
||||
[self newCurrentEntity]; // in case flags changed
|
||||
[self newCurrentEntity]; // in case flags changed
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- selectClass: (char *)class
|
||||
-selectClass:(char *) class
|
||||
{
|
||||
id classent;
|
||||
id classent;
|
||||
|
||||
classent = [entity_classes_i classForName:class];
|
||||
classent =[entity_classes_i classForName:class];
|
||||
if (!classent)
|
||||
return self;
|
||||
lastSelected = [entity_classes_i indexOfObject: classent];
|
||||
lastSelected =[entity_classes_i indexOfObject:classent];
|
||||
|
||||
if (lastSelected < 0)
|
||||
lastSelected = 0;
|
||||
|
||||
[self loadEntityComment:classent];
|
||||
[[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
|
||||
[[entity_browser_i matrixInColumn:0] scrollCellToVisibleAtRow:lastSelected column:0];
|
||||
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
||||
[[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected column:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- newCurrentEntity
|
||||
-newCurrentEntity
|
||||
{
|
||||
id ent, classent, cell;
|
||||
char *classname;
|
||||
int r, c;
|
||||
char *flagname;
|
||||
int flags;
|
||||
id ent, classent, cell;
|
||||
char *classname;
|
||||
int r, c;
|
||||
char *flagname;
|
||||
int flags;
|
||||
|
||||
ent = [map_i currentEntity];
|
||||
classname = [ent valueForQKey: "classname"];
|
||||
if (ent != [map_i objectAtIndex: 0])
|
||||
[self selectClass: classname]; // don't reset for world
|
||||
classent = [entity_classes_i classForName:classname];
|
||||
flagname = [ent valueForQKey: "spawnflags"];
|
||||
ent =[map_i currentEntity];
|
||||
classname =[ent valueForQKey:"classname"];
|
||||
if (ent !=[map_i objectAtIndex:0])
|
||||
[self selectClass:classname]; // don't reset for world
|
||||
classent =[entity_classes_i classForName:classname];
|
||||
flagname =[ent valueForQKey:"spawnflags"];
|
||||
if (!flagname)
|
||||
flags = 0;
|
||||
else
|
||||
flags = atoi(flagname);
|
||||
flags = 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];
|
||||
[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];
|
||||
[quakeed_i makeFirstResponder:quakeed_i];
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Clicked in the Keypair view - set as selected
|
||||
// Clicked in the Keypair view - set as selected
|
||||
//
|
||||
- setSelectedKey:(epair_t *)ep;
|
||||
-setSelectedKey:(epair_t *) ep;
|
||||
{
|
||||
[keyInput_i setStringValue:[NSString stringWithCString:ep->key]];
|
||||
[valueInput_i setStringValue:[NSString stringWithCString:ep->value]];
|
||||
[valueInput_i selectText:self];
|
||||
[keyInput_i setStringValue: [NSString stringWithCString:ep->key]];
|
||||
[valueInput_i setStringValue: [NSString stringWithCString:ep->value]];
|
||||
[valueInput_i selectText:self];
|
||||
return self;
|
||||
}
|
||||
|
||||
- clearInputs
|
||||
-clearInputs
|
||||
{
|
||||
// [keyInput_i setStringValue: ""];
|
||||
// [valueInput_i setStringValue: ""];
|
||||
// [keyInput_i setStringValue: ""];
|
||||
// [valueInput_i setStringValue: ""];
|
||||
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
[quakeed_i makeFirstResponder:quakeed_i];
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Action methods
|
||||
// Action methods
|
||||
//
|
||||
|
||||
-addPair:sender
|
||||
{
|
||||
char *key, *value;
|
||||
char *key, *value;
|
||||
|
||||
key = (char *)[keyInput_i stringValue];
|
||||
value = (char *)[valueInput_i stringValue];
|
||||
|
||||
[ [map_i currentEntity] setKey: key toValue: value ];
|
||||
[[map_i currentEntity] setKey: key toValue:value];
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
[keypairview_i display];
|
||||
|
@ -219,9 +216,9 @@ id things_i;
|
|||
|
||||
-delPair:sender
|
||||
{
|
||||
[quakeed_i makeFirstResponder: quakeed_i];
|
||||
[quakeed_i makeFirstResponder:quakeed_i];
|
||||
|
||||
[ [map_i currentEntity] removeKeyPair: (char *)[keyInput_i stringValue] ];
|
||||
[[map_i currentEntity] removeKeyPair:(char *)[keyInput_i stringValue]];
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
[keypairview_i display];
|
||||
|
@ -235,23 +232,23 @@ id things_i;
|
|||
|
||||
|
||||
//
|
||||
// Set the key/value fields to "angle <button value>"
|
||||
// Set the key/value fields to "angle <button value>"
|
||||
//
|
||||
- setAngle:sender
|
||||
-setAngle:sender
|
||||
{
|
||||
const char *title;
|
||||
char value[10];
|
||||
char value[10];
|
||||
|
||||
title = [[[sender selectedCell] title] cString];
|
||||
if (!strcmp(title,"Up"))
|
||||
title =[[[sender selectedCell] title] cString];
|
||||
if (!strcmp (title, "Up"))
|
||||
strcpy (value, "-1");
|
||||
else if (!strcmp(title,"Dn"))
|
||||
else if (!strcmp (title, "Dn"))
|
||||
strcpy (value, "-2");
|
||||
else
|
||||
strcpy (value, title);
|
||||
|
||||
[keyInput_i setStringValue:@"angle"];
|
||||
[valueInput_i setStringValue:[NSString stringWithCString:value]];
|
||||
[valueInput_i setStringValue: [NSString stringWithCString:value]];
|
||||
[self addPair:NULL];
|
||||
|
||||
[self clearInputs];
|
||||
|
@ -261,30 +258,28 @@ id things_i;
|
|||
return self;
|
||||
}
|
||||
|
||||
- setFlags:sender
|
||||
-setFlags:sender
|
||||
{
|
||||
int flags;
|
||||
int r, c, i;
|
||||
id cell;
|
||||
char str[20];
|
||||
int flags;
|
||||
int r, c, i;
|
||||
id cell;
|
||||
char str[20];
|
||||
|
||||
[self clearInputs];
|
||||
flags = 0;
|
||||
|
||||
for (r=0 ; r<4 ; r++)
|
||||
for (c=0 ; c<3 ; c++)
|
||||
{
|
||||
cell = [flags_i cellAtRow: r column: 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
|
||||
{
|
||||
[[map_i currentEntity] removeKeyPair:"spawnflags"];
|
||||
else {
|
||||
sprintf (str, "%i", flags);
|
||||
[[map_i currentEntity] setKey: "spawnflags" toValue: str];
|
||||
[[map_i currentEntity] setKey: "spawnflags" toValue:str];
|
||||
}
|
||||
|
||||
[keypairview_i calcViewSize];
|
||||
|
@ -295,24 +290,24 @@ id things_i;
|
|||
|
||||
|
||||
//
|
||||
// Fill the Entity browser
|
||||
// (Delegate method - delegated in Interface Builder)
|
||||
// Fill the Entity browser
|
||||
// (Delegate method - delegated in Interface Builder)
|
||||
//
|
||||
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
|
||||
-(int) browser: sender fillMatrix: matrix inColumn:(int) column
|
||||
{
|
||||
id cell;
|
||||
int max;
|
||||
int i;
|
||||
id object;
|
||||
id cell;
|
||||
int max;
|
||||
int i;
|
||||
id object;
|
||||
|
||||
max = [entity_classes_i count];
|
||||
max =[entity_classes_i count];
|
||||
i = 0;
|
||||
while(max--)
|
||||
{
|
||||
object = [entity_classes_i objectAtIndex:i];
|
||||
while (max--) {
|
||||
object =[entity_classes_i objectAtIndex:i];
|
||||
[matrix addRow];
|
||||
cell = [matrix cellAtRow:i++ column:0];
|
||||
[cell setStringValue:[NSString stringWithCString:[object classname]]];
|
||||
cell =[matrix cellAtRow: i++ column:0];
|
||||
[cell setStringValue: [NSString stringWithCString:[object
|
||||
classname]]];
|
||||
[cell setLeaf:YES];
|
||||
[cell setLoaded:YES];
|
||||
}
|
||||
|
|
|
@ -14,63 +14,68 @@
|
|||
#include <math.h>
|
||||
#include <libc.h>
|
||||
|
||||
static NSZone *upZone = NULL;
|
||||
static NSZone *upZone = NULL;
|
||||
|
||||
NSZone *userPathZone()
|
||||
NSZone *
|
||||
userPathZone ()
|
||||
/* Creates a unique zone for use by all user paths */
|
||||
{
|
||||
if (!upZone) {
|
||||
upZone = NSCreateZone(vm_page_size, vm_page_size, 1);
|
||||
}
|
||||
if (!upZone) {
|
||||
upZone = NSCreateZone (vm_page_size, vm_page_size, 1);
|
||||
}
|
||||
|
||||
return upZone;
|
||||
return upZone;
|
||||
}
|
||||
|
||||
UserPath *newUserPath()
|
||||
UserPath *
|
||||
newUserPath ()
|
||||
/* Creates a new User Path in the zone returned by userPathZone */
|
||||
{
|
||||
UserPath *up;
|
||||
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;
|
||||
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;
|
||||
return up;
|
||||
}
|
||||
|
||||
void freeUserPath(UserPath *up)
|
||||
void
|
||||
freeUserPath (UserPath * up)
|
||||
/* Frees User Path and its associated buffers */
|
||||
{
|
||||
free(up->points);
|
||||
free(up->ops);
|
||||
free(up);
|
||||
free (up->points);
|
||||
free (up->ops);
|
||||
free (up);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
void growUserPath(UserPath *up)
|
||||
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));
|
||||
/* 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;
|
||||
return;
|
||||
}
|
||||
|
||||
void beginUserPath(UserPath *up, BOOL cache)
|
||||
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
|
||||
|
@ -78,20 +83,21 @@ void beginUserPath(UserPath *up, BOOL cache)
|
|||
* 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;
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
||||
void endUserPath(UserPath *up, int op)
|
||||
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
|
||||
|
@ -101,13 +107,14 @@ void endUserPath(UserPath *up, int op)
|
|||
* These are defined in <dpsclient/dpsNext.h.
|
||||
*/
|
||||
{
|
||||
up->opForUserPath = op;
|
||||
up->opForUserPath = op;
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void UPdebug(UserPath *up, BOOL shouldPing)
|
||||
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
|
||||
|
@ -116,12 +123,13 @@ void UPdebug(UserPath *up, BOOL shouldPing)
|
|||
* ping is NO.
|
||||
*/
|
||||
{
|
||||
up->ping = shouldPing;
|
||||
up->ping = shouldPing;
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
int sendUserPath(UserPath *up)
|
||||
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,
|
||||
|
@ -133,77 +141,77 @@ int sendUserPath(UserPath *up)
|
|||
* server.
|
||||
*/
|
||||
{
|
||||
NSHandler exception;
|
||||
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();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//NS_HANDLER
|
||||
// exception = NSLocalHandler;
|
||||
//NS_ENDHANDLER
|
||||
if (exception.code) {
|
||||
NSReportError(&exception);
|
||||
if (exception.code == dps_err_ps) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void UPmoveto(UserPath *up, float x, float y)
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void UPlineto(UserPath *up, float x, float y)
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,6 @@
|
|||
#include "ZScrollView.h"
|
||||
|
||||
@implementation ZScrollView
|
||||
|
||||
/*
|
||||
====================
|
||||
initWithFrame: button:
|
||||
|
@ -9,42 +8,37 @@ initWithFrame: button:
|
|||
Initizes a scroll view with a button at it's lower right corner
|
||||
====================
|
||||
*/
|
||||
- initWithFrame:(NSRect)
|
||||
frameRect button1:b1 {
|
||||
[super initWithFrame:frameRect];
|
||||
|
||||
- initWithFrame:(NSRect)frameRect button1:b1
|
||||
{
|
||||
[super initWithFrame: frameRect];
|
||||
|
||||
[self addSubview: b1];
|
||||
[self addSubview:b1];
|
||||
|
||||
button1 = b1;
|
||||
|
||||
[self setHasHorizontalScroller: YES];
|
||||
[self setHasVerticalScroller: YES];
|
||||
[self setHasHorizontalScroller:YES];
|
||||
[self setHasVerticalScroller:YES];
|
||||
|
||||
[self setBorderType: NSBezelBorder];
|
||||
[self setBorderType:NSBezelBorder];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
tile
|
||||
|
||||
Adjust the size for the pop up scale menu
|
||||
=================
|
||||
*/
|
||||
|
||||
- tile
|
||||
*/ -tile
|
||||
{
|
||||
NSRect scrollerframe;
|
||||
NSRect scrollerframe;
|
||||
|
||||
[super tile];
|
||||
scrollerframe = [_horizScroller frame];
|
||||
[button1 setFrame: scrollerframe];
|
||||
scrollerframe =[_horizScroller frame];
|
||||
[button1 setFrame:scrollerframe];
|
||||
|
||||
scrollerframe.size.width = 0;
|
||||
[_horizScroller setFrame: scrollerframe];
|
||||
[_horizScroller setFrame:scrollerframe];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -53,8 +47,9 @@ Adjust the size for the pop up scale menu
|
|||
|
||||
-(BOOL) acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
- superviewSizeChanged:(const NSSize *)oldSize
|
||||
{
|
||||
|
@ -68,4 +63,3 @@ Adjust the size for the pop up scale menu
|
|||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -6,25 +6,24 @@
|
|||
#include "XYView.h"
|
||||
#include "CameraView.h"
|
||||
|
||||
id zview_i;
|
||||
id zview_i;
|
||||
|
||||
id zscrollview_i, zscalemenu_i, zscalebutton_i;
|
||||
id zscrollview_i, zscalemenu_i, zscalebutton_i;
|
||||
|
||||
float zplane;
|
||||
float zplanedir;
|
||||
float zplane;
|
||||
float zplanedir;
|
||||
|
||||
extern NSBezierPath *path;
|
||||
|
||||
@implementation ZView
|
||||
|
||||
/*
|
||||
==================
|
||||
initWithFrame:
|
||||
==================
|
||||
*/
|
||||
- (id)initWithFrame:(NSRect)frameRect
|
||||
- (id) initWithFrame:(NSRect) frameRect
|
||||
{
|
||||
NSPoint pt;
|
||||
NSPoint pt;
|
||||
|
||||
origin[0] = 0.333;
|
||||
origin[1] = 0.333;
|
||||
|
@ -39,31 +38,30 @@ initWithFrame:
|
|||
//
|
||||
// initialize the pop up menus
|
||||
//
|
||||
zscalebutton_i = [[NSPopUpButton alloc] init];
|
||||
[zscalebutton_i setTarget: self];
|
||||
[zscalebutton_i setAction: @selector(scaleMenuTarget:)];
|
||||
zscalebutton_i =[[NSPopUpButton alloc] init];
|
||||
[zscalebutton_i setTarget:self];
|
||||
[zscalebutton_i setAction: @selector (scaleMenuTarget:)];
|
||||
|
||||
[zscalebutton_i addItemWithTitle: @"12.5%"];
|
||||
[zscalebutton_i addItemWithTitle: @"25%"];
|
||||
[zscalebutton_i addItemWithTitle: @"50%"];
|
||||
[zscalebutton_i addItemWithTitle: @"75%"];
|
||||
[zscalebutton_i addItemWithTitle: @"100%"];
|
||||
[zscalebutton_i addItemWithTitle: @"200%"];
|
||||
[zscalebutton_i addItemWithTitle: @"300%"];
|
||||
[zscalebutton_i selectItemAtIndex: 4];
|
||||
[zscalebutton_i addItemWithTitle:@"12.5%"];
|
||||
[zscalebutton_i addItemWithTitle:@"25%"];
|
||||
[zscalebutton_i addItemWithTitle:@"50%"];
|
||||
[zscalebutton_i addItemWithTitle:@"75%"];
|
||||
[zscalebutton_i addItemWithTitle:@"100%"];
|
||||
[zscalebutton_i addItemWithTitle:@"200%"];
|
||||
[zscalebutton_i addItemWithTitle:@"300%"];
|
||||
[zscalebutton_i selectItemAtIndex:4];
|
||||
|
||||
|
||||
// initialize the scroll view
|
||||
zscrollview_i = [[ZScrollView alloc]
|
||||
initWithFrame: frameRect
|
||||
button1: zscalebutton_i
|
||||
];
|
||||
[zscrollview_i setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
||||
zscrollview_i =[[ZScrollView alloc]
|
||||
initWithFrame: frameRect button1:zscalebutton_i];
|
||||
[zscrollview_i setAutoresizingMask:NSViewWidthSizable |
|
||||
NSViewHeightSizable];
|
||||
|
||||
[zscrollview_i setDocumentView: self];
|
||||
[zscrollview_i setDocumentView:self];
|
||||
RELEASE (zscrollview_i);
|
||||
|
||||
// [_super_view setDrawOrigin: 0 : 0];
|
||||
// [_super_view setDrawOrigin: 0 : 0];
|
||||
|
||||
minheight = 0;
|
||||
maxheight = 64;
|
||||
|
@ -73,19 +71,19 @@ initWithFrame:
|
|||
|
||||
[self newRealBounds];
|
||||
|
||||
[self setOrigin: &pt scale: 1];
|
||||
[self setOrigin: &pt scale:1];
|
||||
|
||||
return zscrollview_i;
|
||||
}
|
||||
|
||||
- setXYOrigin: (NSPoint *)pt
|
||||
-setXYOrigin:(NSPoint *) pt
|
||||
{
|
||||
origin[0] = pt->x + 0.333;
|
||||
origin[1] = pt->y + 0.333;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (float)currentScale
|
||||
-(float) currentScale
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
|
@ -95,18 +93,19 @@ initWithFrame:
|
|||
setOrigin:scale:
|
||||
===================
|
||||
*/
|
||||
- setOrigin: (NSPoint *)pt scale: (float)sc
|
||||
-setOrigin:(NSPoint *)
|
||||
pt scale:(float) sc
|
||||
{
|
||||
NSRect sframe;
|
||||
NSRect newbounds;
|
||||
NSRect sframe;
|
||||
NSRect newbounds;
|
||||
|
||||
//
|
||||
// calculate the area visible in the cliprect
|
||||
//
|
||||
scale = sc;
|
||||
|
||||
sframe = [_super_view frame];
|
||||
newbounds = [_super_view frame];
|
||||
sframe =[_super_view frame];
|
||||
newbounds =[_super_view frame];
|
||||
newbounds.origin = *pt;
|
||||
newbounds.size.width /= scale;
|
||||
newbounds.size.height /= scale;
|
||||
|
@ -114,38 +113,35 @@ setOrigin:scale:
|
|||
//
|
||||
// union with the realbounds
|
||||
//
|
||||
if (newbounds.origin.y > oldminheight)
|
||||
{
|
||||
if (newbounds.origin.y > oldminheight) {
|
||||
newbounds.size.height += newbounds.origin.y - oldminheight;
|
||||
newbounds.origin.y = oldminheight;
|
||||
}
|
||||
if (newbounds.origin.y+newbounds.size.height < oldmaxheight)
|
||||
{
|
||||
if (newbounds.origin.y + newbounds.size.height < oldmaxheight) {
|
||||
newbounds.size.height += oldmaxheight
|
||||
- (newbounds.origin.y + newbounds.size.height);
|
||||
- (newbounds.origin.y + newbounds.size.height);
|
||||
}
|
||||
|
||||
//
|
||||
// redisplay everything
|
||||
//
|
||||
//XXX[quakeed_i disableDisplay];
|
||||
// XXX[quakeed_i disableDisplay];
|
||||
|
||||
//
|
||||
// size this view
|
||||
//
|
||||
[self setBoundsSize: newbounds.size];
|
||||
//XXX[self setDrawOrigin: -newbounds.size.width/2 : newbounds.origin.y];
|
||||
//XXX[self moveTo: -newbounds.size.width/2 : newbounds.origin.y];
|
||||
[self setBoundsSize:newbounds.size];
|
||||
// XXX[self setDrawOrigin: -newbounds.size.width/2 : newbounds.origin.y];
|
||||
// XXX[self moveTo: -newbounds.size.width/2 : newbounds.origin.y];
|
||||
|
||||
//
|
||||
// scroll and scale the clip view
|
||||
//
|
||||
//XXX[_super_view setDrawSize
|
||||
//XXX : sframe.size.width/scale
|
||||
//XXX : sframe.size.height/scale];
|
||||
//XXX[_super_view setDrawOrigin: pt->x : pt->y];
|
||||
// XXX[_super_view setDrawSize
|
||||
// XXX : sframe.size.width/scale
|
||||
// XXX : sframe.size.height/scale];
|
||||
// XXX[_super_view setDrawOrigin: pt->x : pt->y];
|
||||
|
||||
//XXX[quakeed_i reenableDisplay];
|
||||
// XXX[quakeed_i reenableDisplay];
|
||||
[zscrollview_i display];
|
||||
|
||||
return self;
|
||||
|
@ -159,35 +155,35 @@ scaleMenuTarget:
|
|||
Called when the scaler popup on the window is used
|
||||
====================
|
||||
*/
|
||||
- scaleMenuTarget: sender
|
||||
-scaleMenuTarget:sender
|
||||
{
|
||||
char const *item;
|
||||
NSRect visrect, sframe;
|
||||
float nscale;
|
||||
char const *item;
|
||||
NSRect visrect, sframe;
|
||||
float nscale;
|
||||
|
||||
item = [[sender titleOfSelectedItem] cString];
|
||||
sscanf (item,"%f",&nscale);
|
||||
item =[[sender titleOfSelectedItem] cString];
|
||||
sscanf (item, "%f", &nscale);
|
||||
nscale /= 100;
|
||||
|
||||
if (nscale == scale)
|
||||
return NULL;
|
||||
|
||||
// keep the center of the view constant
|
||||
visrect = [_super_view bounds];
|
||||
sframe = [_super_view frame];
|
||||
visrect.origin.x += visrect.size.width/2;
|
||||
visrect.origin.y += visrect.size.height/2;
|
||||
visrect =[_super_view bounds];
|
||||
sframe =[_super_view frame];
|
||||
visrect.origin.x += visrect.size.width / 2;
|
||||
visrect.origin.y += visrect.size.height / 2;
|
||||
|
||||
visrect.origin.x -= sframe.size.width/2/nscale;
|
||||
visrect.origin.y -= sframe.size.height/2/nscale;
|
||||
visrect.origin.x -= sframe.size.width / 2 / nscale;
|
||||
visrect.origin.y -= sframe.size.height / 2 / nscale;
|
||||
|
||||
[self setOrigin: &visrect.origin scale: nscale];
|
||||
[self setOrigin: &visrect.origin scale:nscale];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- clearBounds
|
||||
-clearBounds
|
||||
{
|
||||
topbound = 999999;
|
||||
bottombound = -999999;
|
||||
|
@ -195,7 +191,7 @@ Called when the scaler popup on the window is used
|
|||
return self;
|
||||
}
|
||||
|
||||
- getBounds: (float *)top :(float *)bottom;
|
||||
-getBounds: (float *) top:(float *) bottom;
|
||||
{
|
||||
*top = topbound;
|
||||
*bottom = bottombound;
|
||||
|
@ -208,7 +204,7 @@ Called when the scaler popup on the window is used
|
|||
addToHeightRange:
|
||||
==================
|
||||
*/
|
||||
- addToHeightRange: (float)height
|
||||
-addToHeightRange:(float) height
|
||||
{
|
||||
if (height < minheight)
|
||||
minheight = height;
|
||||
|
@ -225,7 +221,7 @@ newSuperBounds
|
|||
When _super_view is resized
|
||||
==================
|
||||
*/
|
||||
- newSuperBounds
|
||||
-newSuperBounds
|
||||
{
|
||||
oldminheight++;
|
||||
[self newRealBounds];
|
||||
|
@ -242,10 +238,10 @@ Should only change the scroll bars, not cause any redraws.
|
|||
If realbounds has shrunk, nothing will change.
|
||||
===================
|
||||
*/
|
||||
- newRealBounds
|
||||
-newRealBounds
|
||||
{
|
||||
NSRect sbounds;
|
||||
float vistop, visbottom;
|
||||
NSRect sbounds;
|
||||
float vistop, visbottom;
|
||||
|
||||
if (minheight == oldminheight && maxheight == oldmaxheight)
|
||||
return self;
|
||||
|
@ -259,7 +255,7 @@ If realbounds has shrunk, nothing will change.
|
|||
//
|
||||
// calculate the area visible in the cliprect
|
||||
//
|
||||
sbounds = [_super_view bounds];
|
||||
sbounds =[_super_view bounds];
|
||||
visbottom = sbounds.origin.y;
|
||||
vistop = visbottom + sbounds.size.height;
|
||||
|
||||
|
@ -267,7 +263,8 @@ If realbounds has shrunk, nothing will change.
|
|||
maxheight = vistop;
|
||||
if (visbottom < minheight)
|
||||
minheight = visbottom;
|
||||
if (minheight == _bounds.origin.y && maxheight-minheight == _bounds.size.height)
|
||||
if (minheight == _bounds.origin.y
|
||||
&& maxheight - minheight == _bounds.size.height)
|
||||
return self;
|
||||
|
||||
sbounds.origin.y = minheight;
|
||||
|
@ -276,18 +273,18 @@ If realbounds has shrunk, nothing will change.
|
|||
//
|
||||
// size this view
|
||||
//
|
||||
//XXX[quakeed_i disableDisplay];
|
||||
// XXX[quakeed_i disableDisplay];
|
||||
|
||||
//XXX[self suspendNotifyAncestorWhenFrameChanged:YES];
|
||||
[self setBoundsSize: sbounds.size];
|
||||
//XXX[self setDrawOrigin: -sbounds.size.width/2 : sbounds.origin.y];
|
||||
//XXX[self moveTo: -sbounds.size.width/2 : sbounds.origin.y];
|
||||
//XXX[self suspendNotifyAncestorWhenFrameChanged:NO];
|
||||
//XXX[[_super_view _super_view] reflectScroll: _super_view];
|
||||
// XXX[self suspendNotifyAncestorWhenFrameChanged:YES];
|
||||
[self setBoundsSize:sbounds.size];
|
||||
// XXX[self setDrawOrigin: -sbounds.size.width/2 : sbounds.origin.y];
|
||||
// XXX[self moveTo: -sbounds.size.width/2 : sbounds.origin.y];
|
||||
// XXX[self suspendNotifyAncestorWhenFrameChanged:NO];
|
||||
// XXX[[_super_view _super_view] reflectScroll: _super_view];
|
||||
|
||||
//XXX[quakeed_i reenableDisplay];
|
||||
// XXX[quakeed_i reenableDisplay];
|
||||
|
||||
//XXX[[[[self _super_view] _super_view] vertScroller] display];
|
||||
// XXX[[[[self _super_view] _super_view] vertScroller] display];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -305,26 +302,26 @@ Rect is in global world (unscaled) coordinates
|
|||
============
|
||||
*/
|
||||
|
||||
- drawGrid: (const NSRect *)rect
|
||||
-drawGrid:(const NSRect *) rect
|
||||
{
|
||||
int y, stopy;
|
||||
float top,bottom;
|
||||
int left, right;
|
||||
int gridsize;
|
||||
char text[10];
|
||||
BOOL showcoords;
|
||||
int y, stopy;
|
||||
float top, bottom;
|
||||
int left, right;
|
||||
int gridsize;
|
||||
char text[10];
|
||||
BOOL showcoords;
|
||||
|
||||
showcoords = [quakeed_i showCoordinates];
|
||||
showcoords =[quakeed_i showCoordinates];
|
||||
|
||||
PSsetlinewidth (0);
|
||||
|
||||
gridsize = [xyview_i gridsize];
|
||||
gridsize =[xyview_i gridsize];
|
||||
|
||||
left = _bounds.origin.x;
|
||||
right = 24;
|
||||
|
||||
bottom = rect->origin.y-1;
|
||||
top = rect->origin.y+rect->size.height+2;
|
||||
bottom = rect->origin.y - 1;
|
||||
top = rect->origin.y + rect->size.height + 2;
|
||||
|
||||
//
|
||||
// grid
|
||||
|
@ -332,37 +329,33 @@ Rect is in global world (unscaled) coordinates
|
|||
// can't just divide by grid size because of negetive coordinate
|
||||
// truncating direction
|
||||
//
|
||||
if (gridsize>= 4/scale)
|
||||
{
|
||||
y = floor(bottom/gridsize);
|
||||
stopy = floor(top/gridsize);
|
||||
if (gridsize >= 4 / scale) {
|
||||
y = floor (bottom / gridsize);
|
||||
stopy = floor (top / gridsize);
|
||||
|
||||
y *= gridsize;
|
||||
stopy *= gridsize;
|
||||
if (y<bottom)
|
||||
y+= gridsize;
|
||||
if (y < bottom)
|
||||
y += gridsize;
|
||||
|
||||
[path removeAllPoints];
|
||||
|
||||
for ( ; y<=stopy ; y+= gridsize)
|
||||
if (y&31)
|
||||
{
|
||||
[path moveToPoint: NSMakePoint (left, y)];
|
||||
[path lineToPoint: NSMakePoint (right, y)];
|
||||
for (; y <= stopy; y += gridsize)
|
||||
if (y & 31) {
|
||||
[path moveToPoint:NSMakePoint (left, y)];
|
||||
[path lineToPoint:NSMakePoint (right, y)];
|
||||
}
|
||||
|
||||
//endUserPath (upath, dps_ustroke);
|
||||
PSsetrgbcolor (0.8,0.8,1.0); // thin grid color
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
PSsetrgbcolor (0.8, 0.8, 1.0); // thin grid color
|
||||
[path stroke];
|
||||
}
|
||||
|
||||
//
|
||||
// half tiles
|
||||
//
|
||||
y = floor(bottom/32);
|
||||
stopy = floor(top/32);
|
||||
y = floor (bottom / 32);
|
||||
stopy = floor (top / 32);
|
||||
|
||||
if ( ! (((int)y + 4096) & 1) )
|
||||
if (!(((int) y + 4096) & 1))
|
||||
y++;
|
||||
y *= 32;
|
||||
stopy *= 32;
|
||||
|
@ -371,61 +364,59 @@ Rect is in global world (unscaled) coordinates
|
|||
|
||||
[path removeAllPoints];
|
||||
|
||||
for ( ; y<=stopy ; y+= 64)
|
||||
{
|
||||
[path moveToPoint: NSMakePoint (left, y)];
|
||||
[path lineToPoint: NSMakePoint (right, y)];
|
||||
for (; y <= stopy; y += 64) {
|
||||
[path moveToPoint:NSMakePoint (left, y)];
|
||||
[path lineToPoint:NSMakePoint (right, y)];
|
||||
}
|
||||
|
||||
//endUserPath (upath, dps_ustroke);
|
||||
PSsetgray (12.0/16.0);
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
PSsetgray (12.0 / 16.0);
|
||||
[path stroke];
|
||||
|
||||
//
|
||||
// tiles
|
||||
//
|
||||
y = floor(bottom/64);
|
||||
stopy = floor(top/64);
|
||||
y = floor (bottom / 64);
|
||||
stopy = floor (top / 64);
|
||||
|
||||
y *= 64;
|
||||
stopy *= 64;
|
||||
if (y<bottom)
|
||||
y+= 64;
|
||||
if (y < bottom)
|
||||
y += 64;
|
||||
if (stopy >= top)
|
||||
stopy -= 64;
|
||||
|
||||
[path removeAllPoints];
|
||||
PSsetgray (0); // for text
|
||||
GSSetFont (DEFCTXT, [NSFont fontWithName:@"Helvetica-Medium" size: 10/scale]);
|
||||
PSrotate(0);
|
||||
PSsetgray (0); // for text
|
||||
GSSetFont (DEFCTXT,[NSFont fontWithName: @"Helvetica-Medium" size:10 / scale]);
|
||||
PSrotate (0);
|
||||
|
||||
for ( ; y<=stopy ; y+= 64)
|
||||
{
|
||||
if (showcoords)
|
||||
{
|
||||
sprintf (text, "%i",y);
|
||||
PSmoveto(left,y);
|
||||
PSshow(text);
|
||||
for (; y <= stopy; y += 64) {
|
||||
if (showcoords) {
|
||||
sprintf (text, "%i", y);
|
||||
PSmoveto (left, y);
|
||||
PSshow (text);
|
||||
}
|
||||
[path moveToPoint: NSMakePoint (left + 24, y)];
|
||||
[path lineToPoint: NSMakePoint (right, y)];
|
||||
[path moveToPoint:NSMakePoint (left + 24, y)];
|
||||
[path lineToPoint:NSMakePoint (right, y)];
|
||||
}
|
||||
|
||||
// divider
|
||||
[path moveToPoint: NSMakePoint (0, _bounds.origin.y)];
|
||||
[path lineToPoint: NSMakePoint (0, _bounds.origin.y + _bounds.size.height)];
|
||||
[path moveToPoint:NSMakePoint (0, _bounds.origin.y)];
|
||||
[path lineToPoint:NSMakePoint (0,
|
||||
_bounds.origin.y + _bounds.size.height)];
|
||||
|
||||
//endUserPath (upath, dps_ustroke);
|
||||
PSsetgray (10.0/16.0);
|
||||
// endUserPath (upath, dps_ustroke);
|
||||
PSsetgray (10.0 / 16.0);
|
||||
[path stroke];
|
||||
|
||||
//
|
||||
// origin
|
||||
//
|
||||
PSsetlinewidth (5);
|
||||
PSsetgray (4.0/16.0);
|
||||
PSmoveto (right,0);
|
||||
PSlineto (left,0);
|
||||
PSsetgray (4.0 / 16.0);
|
||||
PSmoveto (right, 0);
|
||||
PSlineto (left, 0);
|
||||
PSstroke ();
|
||||
PSsetlinewidth (0.15);
|
||||
|
||||
|
@ -433,10 +424,10 @@ Rect is in global world (unscaled) coordinates
|
|||
}
|
||||
|
||||
|
||||
- drawZplane
|
||||
-drawZplane
|
||||
{
|
||||
PSsetrgbcolor (0.2, 0.2, 0);
|
||||
PSarc (0, zplane, 4, 0, M_PI*2);
|
||||
PSarc (0, zplane, 4, 0, M_PI * 2);
|
||||
PSfill ();
|
||||
return self;
|
||||
}
|
||||
|
@ -447,28 +438,28 @@ drawSelf
|
|||
===============================================================================
|
||||
*/
|
||||
|
||||
- drawSelf:(const NSRect *)rects :(int)rectCount
|
||||
-drawSelf: (const NSRect *) rects:(int) rectCount
|
||||
{
|
||||
NSRect visRect;
|
||||
NSRect visRect;
|
||||
|
||||
minheight = 999999;
|
||||
maxheight = -999999;
|
||||
|
||||
// allways draw the entire bar
|
||||
visRect = [self visibleRect];
|
||||
visRect =[self visibleRect];
|
||||
rects = &visRect;
|
||||
|
||||
// erase window
|
||||
NSEraseRect (rects[0]);
|
||||
|
||||
// draw grid
|
||||
[self drawGrid: &rects[0]];
|
||||
[self drawGrid:&rects[0]];
|
||||
|
||||
// draw zplane
|
||||
// [self drawZplane];
|
||||
// [self drawZplane];
|
||||
|
||||
// draw all entities
|
||||
[map_i makeUnselectedPerform: @selector(ZDrawSelf)];
|
||||
[map_i makeUnselectedPerform:@selector (ZDrawSelf)];
|
||||
|
||||
// possibly resize the view
|
||||
[self newRealBounds];
|
||||
|
@ -481,14 +472,14 @@ drawSelf
|
|||
XYDrawSelf
|
||||
==============
|
||||
*/
|
||||
- XYDrawSelf
|
||||
-XYDrawSelf
|
||||
{
|
||||
PSsetrgbcolor (0,0.5,1.0);
|
||||
PSsetrgbcolor (0, 0.5, 1.0);
|
||||
PSsetlinewidth (0.15);
|
||||
PSmoveto (origin[0]-16, origin[1]-16);
|
||||
PSrlineto (32,32);
|
||||
PSmoveto (origin[0]-16, origin[1]+16);
|
||||
PSrlineto (32,-32);
|
||||
PSmoveto (origin[0] - 16, origin[1] - 16);
|
||||
PSrlineto (32, 32);
|
||||
PSmoveto (origin[0] - 16, origin[1] + 16);
|
||||
PSrlineto (32, -32);
|
||||
PSstroke ();
|
||||
|
||||
return self;
|
||||
|
@ -500,14 +491,14 @@ XYDrawSelf
|
|||
getPoint: (NSPoint *)pt
|
||||
==============
|
||||
*/
|
||||
- getPoint: (NSPoint *)pt
|
||||
-getPoint:(NSPoint *) pt
|
||||
{
|
||||
pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases
|
||||
pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases
|
||||
pt->y = origin[1] + 0.333;
|
||||
return self;
|
||||
}
|
||||
|
||||
- setPoint: (NSPoint *)pt
|
||||
-setPoint:(NSPoint *) pt
|
||||
{
|
||||
origin[0] = pt->x;
|
||||
origin[1] = pt->y;
|
||||
|
@ -529,45 +520,42 @@ MOUSE CLICKING
|
|||
dragLoop:
|
||||
================
|
||||
*/
|
||||
static NSPoint oldreletive;
|
||||
- dragFrom: (NSEvent *)startevent
|
||||
useGrid: (BOOL)ug
|
||||
callback: (void (*) (float dy)) callback
|
||||
static NSPoint oldreletive;
|
||||
|
||||
-dragFrom: (NSEvent *) startevent useGrid: (BOOL) ug callback:(void (*)(float dy)) callback
|
||||
{
|
||||
NSEvent *event;
|
||||
NSPoint startpt, newpt;
|
||||
NSPoint reletive, delta;
|
||||
int gridsize;
|
||||
NSEvent *event;
|
||||
NSPoint startpt, newpt;
|
||||
NSPoint reletive, delta;
|
||||
int gridsize;
|
||||
|
||||
gridsize = [xyview_i gridsize];
|
||||
gridsize =[xyview_i gridsize];
|
||||
|
||||
startpt = [startevent locationInWindow];
|
||||
startpt = [self convertPoint:startpt fromView:NULL];
|
||||
startpt =[startevent locationInWindow];
|
||||
startpt =[self convertPoint: startpt fromView:NULL];
|
||||
|
||||
oldreletive.x = oldreletive.y = 0;
|
||||
reletive.x = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
||||
| NSApplicationDefinedMask;
|
||||
event = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
||||
| NSApplicationDefinedMask;
|
||||
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate
|
||||
distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode dequeue:YES];
|
||||
|
||||
if ([event type] == NSLeftMouseUp || [event type] == NSRightMouseUp)
|
||||
if ([event type] == NSLeftMouseUp ||[event type] == NSRightMouseUp)
|
||||
break;
|
||||
|
||||
newpt = [event locationInWindow];
|
||||
newpt = [self convertPoint:newpt fromView:NULL];
|
||||
newpt =[event locationInWindow];
|
||||
newpt =[self convertPoint: newpt fromView:NULL];
|
||||
|
||||
reletive.y = newpt.y - startpt.y;
|
||||
|
||||
if (ug)
|
||||
{ // we want truncate towards 0 behavior here
|
||||
reletive.y = gridsize * (int)(reletive.y / gridsize);
|
||||
if (ug) { // we want truncate towards 0 behavior
|
||||
// here
|
||||
reletive.y = gridsize * (int) (reletive.y / gridsize);
|
||||
}
|
||||
|
||||
if (reletive.y == oldreletive.y)
|
||||
|
@ -584,23 +572,22 @@ static NSPoint oldreletive;
|
|||
//============================================================================
|
||||
|
||||
|
||||
void ZDragCallback (float dy)
|
||||
void
|
||||
ZDragCallback (float dy)
|
||||
{
|
||||
sb_translate[0] = 0;
|
||||
sb_translate[1] = 0;
|
||||
sb_translate[2] = dy;
|
||||
|
||||
[map_i makeSelectedPerform: @selector(translate)];
|
||||
[map_i makeSelectedPerform:@selector (translate)];
|
||||
|
||||
[quakeed_i redrawInstance];
|
||||
}
|
||||
|
||||
- selectionDragFrom: (NSEvent*)theEvent
|
||||
-selectionDragFrom:(NSEvent *) theEvent
|
||||
{
|
||||
qprintf ("dragging selection");
|
||||
[self dragFrom: theEvent
|
||||
useGrid: YES
|
||||
callback: ZDragCallback ];
|
||||
[self dragFrom: theEvent useGrid: YES callback:ZDragCallback];
|
||||
[quakeed_i updateCamera];
|
||||
qprintf ("");
|
||||
return self;
|
||||
|
@ -609,73 +596,72 @@ void ZDragCallback (float dy)
|
|||
|
||||
//============================================================================
|
||||
|
||||
void ZScrollCallback (float dy)
|
||||
void
|
||||
ZScrollCallback (float dy)
|
||||
{
|
||||
NSRect basebounds;
|
||||
NSPoint neworg;
|
||||
float scale;
|
||||
NSRect basebounds;
|
||||
NSPoint neworg;
|
||||
float scale;
|
||||
|
||||
basebounds = [[zview_i superview] bounds];
|
||||
basebounds = [zview_i convertRect: basebounds fromView: [zview_i superview]];
|
||||
basebounds =[[zview_i superview] bounds];
|
||||
basebounds =[zview_i convertRect: basebounds fromView:[zview_i
|
||||
superview]];
|
||||
|
||||
neworg.y = basebounds.origin.y - dy;
|
||||
|
||||
scale = [zview_i currentScale];
|
||||
scale =[zview_i currentScale];
|
||||
|
||||
oldreletive.y -= dy;
|
||||
[zview_i setOrigin: &neworg scale: scale];
|
||||
[zview_i setOrigin: &neworg scale:scale];
|
||||
}
|
||||
|
||||
- scrollDragFrom: (NSEvent*)theEvent
|
||||
-scrollDragFrom:(NSEvent *) theEvent
|
||||
{
|
||||
qprintf ("scrolling view");
|
||||
[self dragFrom: theEvent
|
||||
useGrid: YES
|
||||
callback: ZScrollCallback ];
|
||||
[self dragFrom: theEvent useGrid: YES callback:ZScrollCallback];
|
||||
qprintf ("");
|
||||
return self;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
void ZControlCallback (float dy)
|
||||
void
|
||||
ZControlCallback (float dy)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<numcontrolpoints ; i++)
|
||||
for (i = 0; i < numcontrolpoints; i++)
|
||||
controlpoints[i][2] += dy;
|
||||
|
||||
[[map_i selectedBrush] calcWindings];
|
||||
[quakeed_i redrawInstance];
|
||||
}
|
||||
|
||||
- (BOOL)planeDragFrom: (NSEvent*)theEvent
|
||||
-(BOOL) planeDragFrom:(NSEvent *) theEvent
|
||||
{
|
||||
NSPoint pt;
|
||||
vec3_t dragpoint;
|
||||
NSPoint pt;
|
||||
vec3_t dragpoint;
|
||||
|
||||
if ([map_i numSelected] != 1)
|
||||
return NO;
|
||||
|
||||
pt= [theEvent locationInWindow];
|
||||
pt = [self convertPoint:pt fromView:NULL];
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
|
||||
dragpoint[0] = origin[0];
|
||||
dragpoint[1] = origin[1];
|
||||
dragpoint[2] = pt.y;
|
||||
|
||||
[[map_i selectedBrush] getZdragface: dragpoint];
|
||||
[[map_i selectedBrush] getZdragface:dragpoint];
|
||||
if (!numcontrolpoints)
|
||||
return NO;
|
||||
|
||||
qprintf ("dragging brush plane");
|
||||
|
||||
pt= [theEvent locationInWindow];
|
||||
pt = [self convertPoint:pt fromView:NULL];
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
|
||||
[self dragFrom: theEvent
|
||||
useGrid: YES
|
||||
callback: ZControlCallback ];
|
||||
[self dragFrom: theEvent useGrid: YES callback:ZControlCallback];
|
||||
|
||||
[[map_i selectedBrush] removeIfInvalid];
|
||||
|
||||
|
@ -692,67 +678,61 @@ void ZControlCallback (float dy)
|
|||
mouseDown
|
||||
===================
|
||||
*/
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
-(void) mouseDown:(NSEvent *) theEvent
|
||||
{
|
||||
NSPoint pt;
|
||||
int flags;
|
||||
vec3_t p1;
|
||||
NSPoint pt;
|
||||
int flags;
|
||||
vec3_t p1;
|
||||
|
||||
pt= [theEvent locationInWindow];
|
||||
pt = [self convertPoint:pt fromView:NULL];
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
|
||||
p1[0] = origin[0];
|
||||
p1[1] = origin[1];
|
||||
p1[2] = pt.y;
|
||||
|
||||
flags = [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
|
||||
flags =
|
||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
||||
NSAlternateKeyMask | NSCommandKeyMask);
|
||||
|
||||
//
|
||||
// shift click to select / deselect a brush from the world
|
||||
//
|
||||
if (flags == NSShiftKeyMask)
|
||||
{
|
||||
[map_i selectRay: p1 : p1 : NO];
|
||||
if (flags == NSShiftKeyMask) {
|
||||
[map_i selectRay: p1: p1:NO];
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// alt click = set entire brush texture
|
||||
//
|
||||
if (flags == NSAlternateKeyMask)
|
||||
{
|
||||
[map_i setTextureRay: p1 : p1 : YES];
|
||||
if (flags == NSAlternateKeyMask) {
|
||||
[map_i setTextureRay: p1: p1:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// control click = position view
|
||||
//
|
||||
if (flags == NSControlKeyMask)
|
||||
{
|
||||
[cameraview_i setZOrigin: pt.y];
|
||||
if (flags == NSControlKeyMask) {
|
||||
[cameraview_i setZOrigin:pt.y];
|
||||
[quakeed_i updateAll];
|
||||
[cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]];
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// bare click to drag icons or new brush drag
|
||||
//
|
||||
if ( flags == 0 )
|
||||
{
|
||||
if (flags == 0) {
|
||||
// check eye
|
||||
if ( [cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]] )
|
||||
if ([cameraview_i ZmouseDown: &pt flags:[theEvent
|
||||
modifierFlags]])
|
||||
return;
|
||||
|
||||
if ([map_i numSelected])
|
||||
{
|
||||
if ( pt.x > 0)
|
||||
{
|
||||
if ([self planeDragFrom: theEvent])
|
||||
if ([map_i numSelected]) {
|
||||
if (pt.x > 0) {
|
||||
if ([self planeDragFrom:theEvent])
|
||||
return;
|
||||
}
|
||||
[self selectionDragFrom: theEvent];
|
||||
[self selectionDragFrom:theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -768,23 +748,24 @@ mouseDown
|
|||
rightMouseDown
|
||||
===================
|
||||
*/
|
||||
- (void)rightMouseDown:(NSEvent *)theEvent
|
||||
-(void) rightMouseDown:(NSEvent *) theEvent
|
||||
{
|
||||
NSPoint pt;
|
||||
int flags;
|
||||
NSPoint pt;
|
||||
int flags;
|
||||
|
||||
pt= [theEvent locationInWindow];
|
||||
pt = [self convertPoint:pt fromView:NULL];
|
||||
pt =[theEvent locationInWindow];
|
||||
pt =[self convertPoint: pt fromView:NULL];
|
||||
|
||||
flags = [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask);
|
||||
flags =
|
||||
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
||||
NSAlternateKeyMask | NSCommandKeyMask);
|
||||
|
||||
|
||||
//
|
||||
// click = scroll view
|
||||
//
|
||||
if (flags == 0)
|
||||
{
|
||||
[self scrollDragFrom: theEvent];
|
||||
if (flags == 0) {
|
||||
[self scrollDragFrom:theEvent];
|
||||
}
|
||||
|
||||
qprintf ("bad flags for click");
|
||||
|
@ -805,14 +786,14 @@ rightMouseDown
|
|||
modalMoveLoop
|
||||
================
|
||||
*/
|
||||
- modalMoveLoop: (NSPoint *)basept :(vec3_t)movemod : converter
|
||||
-modalMoveLoop: (NSPoint *) basept: (vec3_t) movemod:converter
|
||||
{
|
||||
vec3_t originbase;
|
||||
NSEvent *event;
|
||||
NSPoint newpt;
|
||||
vec3_t delta;
|
||||
vec3_t originbase;
|
||||
NSEvent *event;
|
||||
NSPoint newpt;
|
||||
vec3_t delta;
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
VectorCopy (origin, originbase);
|
||||
|
||||
|
@ -821,23 +802,22 @@ modalMoveLoop
|
|||
//
|
||||
goto drawentry;
|
||||
|
||||
while ([event type] != NSLeftMouseUp)
|
||||
{
|
||||
while ([event type] != NSLeftMouseUp) {
|
||||
//
|
||||
// calculate new point
|
||||
//
|
||||
newpt = [event locationInWindow];
|
||||
newpt = [converter convertPoint:newpt fromView:NULL];
|
||||
newpt =[event locationInWindow];
|
||||
newpt =[converter convertPoint: newpt fromView:NULL];
|
||||
|
||||
delta[0] = newpt.x-basept->x;
|
||||
delta[1] = newpt.y-basept->y;
|
||||
delta[2] = delta[1]; // height change
|
||||
delta[0] = newpt.x - basept->x;
|
||||
delta[1] = newpt.y - basept->y;
|
||||
delta[2] = delta[1]; // height change
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
origin[i] = originbase[i]+movemod[i]*delta[i];
|
||||
for (i = 0; i < 3; i++)
|
||||
origin[i] = originbase[i] + movemod[i] * delta[i];
|
||||
|
||||
|
||||
drawentry:
|
||||
drawentry:
|
||||
//
|
||||
// instance draw new frame
|
||||
//
|
||||
|
@ -845,16 +825,16 @@ drawentry:
|
|||
[self display];
|
||||
|
||||
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
||||
event = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
|
||||
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate
|
||||
distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode dequeue:YES];
|
||||
}
|
||||
|
||||
//
|
||||
// draw the brush back into the window buffer
|
||||
//
|
||||
// [xyview_i display];
|
||||
// [xyview_i display];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -864,19 +844,18 @@ drawentry:
|
|||
XYmouseDown
|
||||
===============
|
||||
*/
|
||||
- (BOOL)XYmouseDown: (NSPoint *)pt
|
||||
-(BOOL) XYmouseDown:(NSPoint *) pt
|
||||
{
|
||||
vec3_t movemod;
|
||||
vec3_t movemod;
|
||||
|
||||
if (fabs(pt->x - origin[0]) > 16
|
||||
|| fabs(pt->y - origin[1]) > 16)
|
||||
if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16)
|
||||
return NO;
|
||||
|
||||
movemod[0] = 1;
|
||||
movemod[1] = 1;
|
||||
movemod[2] = 0;
|
||||
|
||||
[self modalMoveLoop: pt : movemod : xyview_i];
|
||||
[self modalMoveLoop: pt: movemod:xyview_i];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -1,41 +1,40 @@
|
|||
|
||||
|
||||
|
||||
char token[MAXTOKEN];
|
||||
boolean unget;
|
||||
char *script_p;
|
||||
int scriptline;
|
||||
char token[MAXTOKEN];
|
||||
boolean unget;
|
||||
char *script_p;
|
||||
int scriptline;
|
||||
|
||||
void StartTokenParsing (char *data)
|
||||
void
|
||||
StartTokenParsing (char *data)
|
||||
{
|
||||
scriptline = 1;
|
||||
script_p = data;
|
||||
unget = false;
|
||||
}
|
||||
|
||||
boolean GetToken (boolean crossline)
|
||||
boolean
|
||||
GetToken (boolean crossline)
|
||||
{
|
||||
char *token_p;
|
||||
char *token_p;
|
||||
|
||||
if (unget) // is a token allready waiting?
|
||||
if (unget) // is a token allready waiting?
|
||||
return true;
|
||||
|
||||
//
|
||||
// skip space
|
||||
//
|
||||
skipspace:
|
||||
while (*script_p <= 32)
|
||||
{
|
||||
if (!*script_p)
|
||||
{
|
||||
skipspace:
|
||||
while (*script_p <= 32) {
|
||||
if (!*script_p) {
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete",scriptline);
|
||||
Error ("Line %i is incomplete", scriptline);
|
||||
return false;
|
||||
}
|
||||
if (*script_p++ == '\n')
|
||||
{
|
||||
if (*script_p++ == '\n') {
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete",scriptline);
|
||||
Error ("Line %i is incomplete", scriptline);
|
||||
scriptline++;
|
||||
}
|
||||
}
|
||||
|
@ -43,48 +42,44 @@ skipspace:
|
|||
if (script_p[0] == '/' && script_p[1] == '/') // comment field
|
||||
{
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete\n",scriptline);
|
||||
Error ("Line %i is incomplete\n", scriptline);
|
||||
while (*script_p++ != '\n')
|
||||
if (!*script_p)
|
||||
{
|
||||
if (!*script_p) {
|
||||
if (!crossline)
|
||||
Error ("Line %i is incomplete",scriptline);
|
||||
Error ("Line %i is incomplete", scriptline);
|
||||
return false;
|
||||
}
|
||||
goto skipspace;
|
||||
}
|
||||
|
||||
//
|
||||
// copy token
|
||||
//
|
||||
token_p = token;
|
||||
|
||||
if (*script_p == '"')
|
||||
{
|
||||
if (*script_p == '"') {
|
||||
script_p++;
|
||||
while ( *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);
|
||||
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);
|
||||
}
|
||||
} 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 ()
|
||||
void
|
||||
UngetToken ()
|
||||
{
|
||||
unget = true;
|
||||
}
|
||||
|
@ -93,17 +88,18 @@ void UngetToken ()
|
|||
|
||||
|
||||
|
||||
void qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||
void
|
||||
qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsprintf (string, fmt,argptr);
|
||||
vsprintf (string, fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
[g_cmd_out_i setStringValue: [NSString stringWithCString: string]];
|
||||
//NSPing ();
|
||||
[g_cmd_out_i setStringValue: [NSString stringWithCString:string]];
|
||||
// NSPing ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -116,53 +112,55 @@ Error
|
|||
For abnormal program terminations
|
||||
=================
|
||||
*/
|
||||
BOOL in_error;
|
||||
void Error (char *error, ...)
|
||||
BOOL in_error;
|
||||
void
|
||||
Error (char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
va_list argptr;
|
||||
static char string[1024];
|
||||
|
||||
if (in_error)
|
||||
[NSApp terminate: NULL];
|
||||
[NSApp terminate:NULL];
|
||||
in_error = YES;
|
||||
|
||||
va_start (argptr,error);
|
||||
vsprintf (string,error,argptr);
|
||||
va_start (argptr, error);
|
||||
vsprintf (string, error, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
strcat (string, "\nmap saved to "FN_CRASHSAVE);
|
||||
strcat (string, "\nmap saved to " FN_CRASHSAVE);
|
||||
|
||||
[map_i writeMapFile: FN_CRASHSAVE useRegion: NO];
|
||||
NSRunAlertPanel (@"Error", [NSString stringWithCString: string],NULL,NULL,NULL);
|
||||
[map_i writeMapFile: FN_CRASHSAVE useRegion:NO];
|
||||
NSRunAlertPanel (@"Error",[NSString stringWithCString:string], NULL, NULL,
|
||||
NULL);
|
||||
|
||||
[NSApp terminate: NULL];
|
||||
[NSApp terminate:NULL];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CleanupName (char *in, char *out)
|
||||
void
|
||||
CleanupName (char *in, char *out)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i=0 ; i< 16 ; i++ )
|
||||
{
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (!in[i])
|
||||
break;
|
||||
|
||||
out[i] = toupper(in[i]);
|
||||
out[i] = toupper (in[i]);
|
||||
}
|
||||
|
||||
for ( ; i< 16 ; i++ )
|
||||
for (; i < 16; i++)
|
||||
out[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
void PrintRect (NSRect *r)
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,11 +171,12 @@ FileTime
|
|||
returns -1 if not present
|
||||
============
|
||||
*/
|
||||
int FileTime (char *path)
|
||||
int
|
||||
FileTime (char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
struct stat buf;
|
||||
|
||||
if (stat (path,&buf) == -1)
|
||||
if (stat (path, &buf) == -1)
|
||||
return -1;
|
||||
|
||||
return buf.st_mtime;
|
||||
|
@ -188,25 +187,25 @@ int FileTime (char *path)
|
|||
CreatePath
|
||||
============
|
||||
*/
|
||||
void CreatePath (char *path)
|
||||
void
|
||||
CreatePath (char *path)
|
||||
{
|
||||
char *ofs;
|
||||
char *ofs;
|
||||
|
||||
for (ofs = path+1 ; *ofs ; ofs++)
|
||||
{
|
||||
if (*ofs == '/')
|
||||
{ // create the directory
|
||||
for (ofs = path + 1; *ofs; ofs++) {
|
||||
if (*ofs == '/') { // create the directory
|
||||
*ofs = 0;
|
||||
mkdir (path,0777);
|
||||
mkdir (path, 0777);
|
||||
*ofs = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int I_FileOpenRead (char *path, int *handle)
|
||||
int
|
||||
I_FileOpenRead (char *path, int *handle)
|
||||
{
|
||||
int h;
|
||||
struct stat fileinfo;
|
||||
int h;
|
||||
struct stat fileinfo;
|
||||
|
||||
|
||||
h = open (path, O_RDONLY, 0666);
|
||||
|
@ -214,23 +213,23 @@ int I_FileOpenRead (char *path, int *handle)
|
|||
if (h == -1)
|
||||
return -1;
|
||||
|
||||
if (fstat (h,&fileinfo) == -1)
|
||||
if (fstat (h, &fileinfo) == -1)
|
||||
Error ("Error fstating %s", path);
|
||||
|
||||
return fileinfo.st_size;
|
||||
}
|
||||
|
||||
int I_FileOpenWrite (char *path)
|
||||
int
|
||||
I_FileOpenWrite (char *path)
|
||||
{
|
||||
int handle;
|
||||
int handle;
|
||||
|
||||
umask (0);
|
||||
|
||||
handle = open(path,O_RDWR | O_CREAT | O_TRUNC
|
||||
, 0666);
|
||||
handle = open (path, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (handle == -1)
|
||||
Error ("Error opening %s: %s", path,strerror(errno));
|
||||
Error ("Error opening %s: %s", path, strerror (errno));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -242,17 +241,18 @@ Sys_UpdateFile
|
|||
Copies a more recent net file to the local drive
|
||||
============
|
||||
*/
|
||||
void Sys_UpdateFile (char *path, char *netpath)
|
||||
void
|
||||
Sys_UpdateFile (char *path, char *netpath)
|
||||
{
|
||||
int ltime, ntime;
|
||||
int in, out, size;
|
||||
char *buf;
|
||||
int ltime, ntime;
|
||||
int in, out, size;
|
||||
char *buf;
|
||||
|
||||
ltime = FileTime (path);
|
||||
ntime = FileTime (netpath);
|
||||
|
||||
if (ntime <= ltime)
|
||||
return; // up to date
|
||||
return; // up to date
|
||||
|
||||
// copy the file
|
||||
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
|
||||
|
@ -269,5 +269,3 @@ void Sys_UpdateFile (char *path, char *netpath)
|
|||
close (out);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,41 +1,42 @@
|
|||
|
||||
#include "render.h"
|
||||
|
||||
extern vec3_t xy_viewnormal;
|
||||
extern vec3_t xy_viewnormal;
|
||||
|
||||
//define NOLIGHT
|
||||
//define NOLIGHT
|
||||
|
||||
vec3_t r_origin, r_matrix[3];
|
||||
vec3_t r_origin, r_matrix[3];
|
||||
|
||||
int t_width, t_height;
|
||||
unsigned *t_data;
|
||||
int t_widthmask, t_heightmask, t_widthshift;
|
||||
float t_widthadd, t_heightadd;
|
||||
int t_width, t_height;
|
||||
unsigned *t_data;
|
||||
int t_widthmask, t_heightmask, t_widthshift;
|
||||
float t_widthadd, t_heightadd;
|
||||
|
||||
int r_width, r_height;
|
||||
float *r_zbuffer;
|
||||
unsigned *r_picbuffer;
|
||||
int r_width, r_height;
|
||||
float *r_zbuffer;
|
||||
unsigned *r_picbuffer;
|
||||
|
||||
vec5_t rightside, leftside, rightstep,leftstep;
|
||||
vec5_t rightside, leftside, rightstep, leftstep;
|
||||
|
||||
face_t *r_face;
|
||||
face_t *r_face;
|
||||
|
||||
BOOL r_drawflat;
|
||||
BOOL r_drawflat;
|
||||
|
||||
pixel32_t r_flatcolor;
|
||||
pixel32_t r_flatcolor;
|
||||
|
||||
int sy[20];
|
||||
int sy[20];
|
||||
|
||||
/*
|
||||
====================
|
||||
REN_ClearBuffers
|
||||
====================
|
||||
*/
|
||||
void REN_ClearBuffers (void)
|
||||
void
|
||||
REN_ClearBuffers (void)
|
||||
{
|
||||
int size;
|
||||
int size;
|
||||
|
||||
size = r_width * r_height*4;
|
||||
size = r_width * r_height * 4;
|
||||
|
||||
memset (r_zbuffer, 0, size);
|
||||
memset (r_picbuffer, 0, size);
|
||||
|
@ -48,11 +49,12 @@ REN_SetTexture
|
|||
====================
|
||||
*/
|
||||
|
||||
void REN_SetTexture (face_t *face)
|
||||
void
|
||||
REN_SetTexture (face_t * face)
|
||||
{
|
||||
int i;
|
||||
int t_heightshift;
|
||||
qtexture_t *q;
|
||||
int i;
|
||||
int t_heightshift;
|
||||
qtexture_t *q;
|
||||
|
||||
if (!face->qtexture)
|
||||
face->qtexture = TEX_ForName (face->texture.texture); // try to load
|
||||
|
@ -67,29 +69,27 @@ void REN_SetTexture (face_t *face)
|
|||
r_flatcolor.chan[1] *= r_face->light;
|
||||
r_flatcolor.chan[2] *= r_face->light;
|
||||
|
||||
t_widthadd = t_width*1024;
|
||||
t_heightadd = t_height*1024;
|
||||
t_widthadd = t_width * 1024;
|
||||
t_heightadd = t_height * 1024;
|
||||
|
||||
t_widthmask = t_width-1;
|
||||
t_heightmask = t_height-1;
|
||||
t_widthmask = t_width - 1;
|
||||
t_heightmask = t_height - 1;
|
||||
|
||||
t_widthshift = 0;
|
||||
i = t_width;
|
||||
while (i >= 2)
|
||||
{
|
||||
while (i >= 2) {
|
||||
t_widthshift++;
|
||||
i>>=1;
|
||||
i >>= 1;
|
||||
}
|
||||
|
||||
t_heightshift = 0;
|
||||
i = t_width;
|
||||
while (i >= 2)
|
||||
{
|
||||
while (i >= 2) {
|
||||
t_heightshift++;
|
||||
i>>=1;
|
||||
i >>= 1;
|
||||
}
|
||||
|
||||
if ( (1<<t_widthshift) != t_width || (1<<t_heightshift) != t_height)
|
||||
if ((1 << t_widthshift) != t_width || (1 << t_heightshift) != t_height)
|
||||
t_widthshift = t_heightshift = 0; // non power of two
|
||||
}
|
||||
|
||||
|
@ -98,17 +98,18 @@ void REN_SetTexture (face_t *face)
|
|||
REN_DrawSpan
|
||||
==================
|
||||
*/
|
||||
void REN_DrawSpan (int y)
|
||||
void
|
||||
REN_DrawSpan (int y)
|
||||
{
|
||||
int x, count;
|
||||
int ofs;
|
||||
int tx, ty;
|
||||
int x1, x2;
|
||||
float ufrac, vfrac, zfrac, lightfrac, ustep, vstep, zstep;
|
||||
pixel32_t *in, *out;
|
||||
float scale;
|
||||
int x, count;
|
||||
int ofs;
|
||||
int tx, ty;
|
||||
int x1, x2;
|
||||
float ufrac, vfrac, zfrac, lightfrac, ustep, vstep, zstep;
|
||||
pixel32_t *in, *out;
|
||||
float scale;
|
||||
|
||||
if (y<0 || y >= r_height)
|
||||
if (y < 0 || y >= r_height)
|
||||
return;
|
||||
|
||||
x1 = (leftside[0]);
|
||||
|
@ -126,54 +127,48 @@ void REN_DrawSpan (int y)
|
|||
if (!count)
|
||||
scale = 1;
|
||||
else
|
||||
scale = 1.0/count;
|
||||
scale = 1.0 / count;
|
||||
|
||||
zstep = (rightside[2] - zfrac)*scale;
|
||||
ustep = (rightside[3] - ufrac)*scale;
|
||||
vstep = (rightside[4] - vfrac)*scale;
|
||||
zstep = (rightside[2] - zfrac) * scale;
|
||||
ustep = (rightside[3] - ufrac) * scale;
|
||||
vstep = (rightside[4] - vfrac) * scale;
|
||||
|
||||
if (x1 < 0)
|
||||
{
|
||||
ufrac -= x1*ustep;
|
||||
vfrac -= x1*vstep;
|
||||
zfrac -= x1*zstep;
|
||||
if (x1 < 0) {
|
||||
ufrac -= x1 * ustep;
|
||||
vfrac -= x1 * vstep;
|
||||
zfrac -= x1 * zstep;
|
||||
x1 = 0;
|
||||
}
|
||||
|
||||
if (x2 > r_width)
|
||||
x2 = r_width;
|
||||
|
||||
ofs = y*r_width+x1;
|
||||
ofs = y * r_width + x1;
|
||||
|
||||
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
||||
for (x=x1 ; x < x2 ; x++)
|
||||
{
|
||||
if (r_zbuffer[ofs] <= zfrac)
|
||||
{
|
||||
scale = 1/zfrac;
|
||||
for (x = x1; x < x2; x++) {
|
||||
if (r_zbuffer[ofs] <= zfrac) {
|
||||
scale = 1 / zfrac;
|
||||
|
||||
r_zbuffer[ofs] = zfrac;
|
||||
|
||||
if (t_widthshift)
|
||||
{
|
||||
tx = (int)((ufrac*scale)) & t_widthmask;
|
||||
ty = (int)((vfrac*scale)) & t_heightmask;
|
||||
in = (pixel32_t *)&t_data [(ty<<t_widthshift)+tx];
|
||||
}
|
||||
else
|
||||
{
|
||||
tx = (int)((ufrac*scale)+t_widthadd) % t_width;
|
||||
ty = (int)((vfrac*scale)+t_heightadd) % t_height;
|
||||
in = (pixel32_t *)&t_data [ty*t_width+tx];
|
||||
if (t_widthshift) {
|
||||
tx = (int) ((ufrac * scale)) & t_widthmask;
|
||||
ty = (int) ((vfrac * scale)) & t_heightmask;
|
||||
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
||||
} else {
|
||||
tx = (int) ((ufrac * scale) + t_widthadd) % t_width;
|
||||
ty = (int) ((vfrac * scale) + t_heightadd) % t_height;
|
||||
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
||||
}
|
||||
|
||||
out = (pixel32_t *)&r_picbuffer[ofs];
|
||||
out = (pixel32_t *) & r_picbuffer[ofs];
|
||||
#ifdef NOLIGHT
|
||||
*out = *in;
|
||||
#else
|
||||
out->chan[0] = in->chan[0]*lightfrac;
|
||||
out->chan[1] = in->chan[1]*lightfrac;
|
||||
out->chan[2] = in->chan[2]*lightfrac;
|
||||
out->chan[0] = in->chan[0] * lightfrac;
|
||||
out->chan[1] = in->chan[1] * lightfrac;
|
||||
out->chan[2] = in->chan[2] * lightfrac;
|
||||
out->chan[3] = 0xff;
|
||||
#endif
|
||||
}
|
||||
|
@ -190,15 +185,16 @@ void REN_DrawSpan (int y)
|
|||
REN_DrawFlatSpan
|
||||
==================
|
||||
*/
|
||||
void REN_DrawFlatSpan (int y)
|
||||
void
|
||||
REN_DrawFlatSpan (int y)
|
||||
{
|
||||
int x, count;
|
||||
int ofs;
|
||||
int x1, x2;
|
||||
float zfrac, zstep;
|
||||
int *out;
|
||||
int x, count;
|
||||
int ofs;
|
||||
int x1, x2;
|
||||
float zfrac, zstep;
|
||||
int *out;
|
||||
|
||||
if (y<0 || y >= r_height)
|
||||
if (y < 0 || y >= r_height)
|
||||
return;
|
||||
|
||||
x1 = (leftside[0]);
|
||||
|
@ -210,26 +206,23 @@ void REN_DrawFlatSpan (int y)
|
|||
|
||||
zfrac = leftside[2];
|
||||
|
||||
zstep = (rightside[2] - zfrac)/count;
|
||||
zstep = (rightside[2] - zfrac) / count;
|
||||
|
||||
if (x1 < 0)
|
||||
{
|
||||
zfrac -= x1*zstep;
|
||||
if (x1 < 0) {
|
||||
zfrac -= x1 * zstep;
|
||||
x1 = 0;
|
||||
}
|
||||
|
||||
if (x2 > r_width)
|
||||
x2 = r_width;
|
||||
|
||||
ofs = y*r_width+x1;
|
||||
ofs = y * r_width + x1;
|
||||
|
||||
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
||||
for (x=x1 ; x < x2 ; x++)
|
||||
{
|
||||
if (r_zbuffer[ofs] <= zfrac)
|
||||
{
|
||||
for (x = x1; x < x2; x++) {
|
||||
if (r_zbuffer[ofs] <= zfrac) {
|
||||
r_zbuffer[ofs] = zfrac;
|
||||
out = (int *)&r_picbuffer[ofs];
|
||||
out = (int *) &r_picbuffer[ofs];
|
||||
*out = r_flatcolor.p;
|
||||
}
|
||||
zfrac += zstep;
|
||||
|
@ -244,14 +237,15 @@ REN_RasterizeFace
|
|||
|
||||
=====================
|
||||
*/
|
||||
void REN_RasterizeFace (winding_t *w)
|
||||
void
|
||||
REN_RasterizeFace (winding_t * w)
|
||||
{
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
|
||||
//
|
||||
// find top vertex
|
||||
|
@ -261,15 +255,13 @@ void REN_RasterizeFace (winding_t *w)
|
|||
bot = 0x80000000;
|
||||
leftv = 0;
|
||||
|
||||
for (i=0 ; i<numvertex ; i++)
|
||||
{
|
||||
for (i = 0; i < numvertex; i++) {
|
||||
w->points[i][3] *= w->points[i][2];
|
||||
w->points[i][4] *= w->points[i][2];
|
||||
|
||||
sy[i] = (int)w->points[i][1];
|
||||
sy[i] = (int) w->points[i][1];
|
||||
|
||||
if (sy[i] < top)
|
||||
{
|
||||
if (sy[i] < top) {
|
||||
top = sy[i];
|
||||
leftv = i;
|
||||
}
|
||||
|
@ -279,42 +271,37 @@ void REN_RasterizeFace (winding_t *w)
|
|||
rightv = leftv;
|
||||
|
||||
if (top < 0 || bot > r_height || top > bot)
|
||||
return; // shouldn't have to have this...
|
||||
return; // shouldn't have to have this...
|
||||
|
||||
//
|
||||
// render a trapezoid
|
||||
//
|
||||
y = top;
|
||||
|
||||
while (y < bot)
|
||||
{
|
||||
if (y >= sy[leftv])
|
||||
{
|
||||
do
|
||||
{
|
||||
for (i=0 ; i<5 ; i++)
|
||||
while (y < bot) {
|
||||
if (y >= sy[leftv]) {
|
||||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
leftside[i] = w->points[leftv][i];
|
||||
leftv--;
|
||||
if (leftv == -1)
|
||||
leftv = numvertex-1;
|
||||
leftv = numvertex - 1;
|
||||
} while (sy[leftv] <= y);
|
||||
count = sy[leftv]-y;
|
||||
for (i=0 ; i<5 ; i++)
|
||||
leftstep[i] = (w->points[leftv][i] - leftside[i])/count;
|
||||
count = sy[leftv] - y;
|
||||
for (i = 0; i < 5; i++)
|
||||
leftstep[i] = (w->points[leftv][i] - leftside[i]) / count;
|
||||
}
|
||||
if (y >= sy[rightv])
|
||||
{
|
||||
do
|
||||
{
|
||||
for (i=0 ; i<5 ; i++)
|
||||
if (y >= sy[rightv]) {
|
||||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
rightside[i] = w->points[rightv][i];
|
||||
rightv++;
|
||||
if (rightv == numvertex)
|
||||
rightv = 0;
|
||||
} while (sy[rightv] <= y);
|
||||
count = sy[rightv]-y;
|
||||
for (i=0 ; i<5 ; i++)
|
||||
rightstep[i] = (w->points[rightv][i] - rightside[i])/count;
|
||||
count = sy[rightv] - y;
|
||||
for (i = 0; i < 5; i++)
|
||||
rightstep[i] = (w->points[rightv][i] - rightside[i]) / count;
|
||||
}
|
||||
|
||||
if (r_drawflat)
|
||||
|
@ -322,8 +309,7 @@ void REN_RasterizeFace (winding_t *w)
|
|||
else
|
||||
REN_DrawSpan (y);
|
||||
|
||||
for (i=0 ; i<5 ; i++)
|
||||
{
|
||||
for (i = 0; i < 5; i++) {
|
||||
leftside[i] += leftstep[i];
|
||||
rightside[i] += rightstep[i];
|
||||
}
|
||||
|
@ -339,17 +325,18 @@ void REN_RasterizeFace (winding_t *w)
|
|||
REN_DrawSpanLinear
|
||||
==================
|
||||
*/
|
||||
void REN_DrawSpanLinear (int y)
|
||||
void
|
||||
REN_DrawSpanLinear (int y)
|
||||
{
|
||||
int x, count;
|
||||
int ofs;
|
||||
int tx, ty;
|
||||
int x1, x2;
|
||||
float ufrac, vfrac, zfrac, ustep, vstep, zstep;
|
||||
pixel32_t *in, *out;
|
||||
float scale;
|
||||
int x, count;
|
||||
int ofs;
|
||||
int tx, ty;
|
||||
int x1, x2;
|
||||
float ufrac, vfrac, zfrac, ustep, vstep, zstep;
|
||||
pixel32_t *in, *out;
|
||||
float scale;
|
||||
|
||||
if (y<0 || y >= r_height)
|
||||
if (y < 0 || y >= r_height)
|
||||
return;
|
||||
|
||||
x1 = (leftside[0]);
|
||||
|
@ -366,46 +353,40 @@ void REN_DrawSpanLinear (int y)
|
|||
if (!count)
|
||||
scale = 1;
|
||||
else
|
||||
scale = 1.0/count;
|
||||
scale = 1.0 / count;
|
||||
|
||||
zstep = (rightside[2] - zfrac)*scale;
|
||||
ustep = (rightside[3] - ufrac)*scale;
|
||||
vstep = (rightside[4] - vfrac)*scale;
|
||||
zstep = (rightside[2] - zfrac) * scale;
|
||||
ustep = (rightside[3] - ufrac) * scale;
|
||||
vstep = (rightside[4] - vfrac) * scale;
|
||||
|
||||
|
||||
if (x1 < 0)
|
||||
{
|
||||
ufrac -= x1*ustep;
|
||||
vfrac -= x1*vstep;
|
||||
zfrac -= x1*zstep;
|
||||
if (x1 < 0) {
|
||||
ufrac -= x1 * ustep;
|
||||
vfrac -= x1 * vstep;
|
||||
zfrac -= x1 * zstep;
|
||||
x1 = 0;
|
||||
}
|
||||
|
||||
if (x2 > r_width)
|
||||
x2 = r_width;
|
||||
|
||||
ofs = y*r_width+x1;
|
||||
ofs = y * r_width + x1;
|
||||
|
||||
for (x=x1 ; x < x2 ; x++)
|
||||
{
|
||||
if (r_zbuffer[ofs] <= zfrac)
|
||||
{
|
||||
for (x = x1; x < x2; x++) {
|
||||
if (r_zbuffer[ofs] <= zfrac) {
|
||||
r_zbuffer[ofs] = zfrac;
|
||||
|
||||
if (t_widthshift)
|
||||
{
|
||||
tx = (int)ufrac & t_widthmask;
|
||||
ty = (int)vfrac & t_heightmask;
|
||||
in = (pixel32_t *)&t_data [(ty<<t_widthshift)+tx];
|
||||
}
|
||||
else
|
||||
{
|
||||
tx = (int)(ufrac+t_widthadd) % t_width;
|
||||
ty = (int)(vfrac+t_heightadd) % t_height;
|
||||
in = (pixel32_t *)&t_data [ty*t_width+tx];
|
||||
if (t_widthshift) {
|
||||
tx = (int) ufrac & t_widthmask;
|
||||
ty = (int) vfrac & t_heightmask;
|
||||
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
||||
} else {
|
||||
tx = (int) (ufrac + t_widthadd) % t_width;
|
||||
ty = (int) (vfrac + t_heightadd) % t_height;
|
||||
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
||||
}
|
||||
|
||||
out = (pixel32_t *)&r_picbuffer[ofs];
|
||||
out = (pixel32_t *) & r_picbuffer[ofs];
|
||||
*out = *in;
|
||||
}
|
||||
ufrac += ustep;
|
||||
|
@ -422,14 +403,15 @@ REN_RasterizeFaceLinear
|
|||
|
||||
=====================
|
||||
*/
|
||||
void REN_RasterizeFaceLinear (winding_t *w)
|
||||
void
|
||||
REN_RasterizeFaceLinear (winding_t * w)
|
||||
{
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
int y;
|
||||
int i;
|
||||
int top, bot;
|
||||
int leftv, rightv;
|
||||
int count;
|
||||
int numvertex;
|
||||
|
||||
//
|
||||
// find top vertex
|
||||
|
@ -439,12 +421,10 @@ void REN_RasterizeFaceLinear (winding_t *w)
|
|||
bot = 0x80000000;
|
||||
|
||||
leftv = 0;
|
||||
for (i=0 ; i<numvertex ; i++)
|
||||
{
|
||||
sy[i] = (int)w->points[i][1];
|
||||
for (i = 0; i < numvertex; i++) {
|
||||
sy[i] = (int) w->points[i][1];
|
||||
|
||||
if (sy[i] < top)
|
||||
{
|
||||
if (sy[i] < top) {
|
||||
top = sy[i];
|
||||
leftv = i;
|
||||
}
|
||||
|
@ -454,48 +434,42 @@ void REN_RasterizeFaceLinear (winding_t *w)
|
|||
rightv = leftv;
|
||||
|
||||
if (top < 0 || bot > r_height || top > bot)
|
||||
return; // shouldn't have to have this...
|
||||
return; // shouldn't have to have this...
|
||||
|
||||
//
|
||||
// render a trapezoid
|
||||
//
|
||||
y = top;
|
||||
|
||||
while (y < bot)
|
||||
{
|
||||
if (y >= sy[leftv])
|
||||
{
|
||||
do
|
||||
{
|
||||
for (i=0 ; i<5 ; i++)
|
||||
while (y < bot) {
|
||||
if (y >= sy[leftv]) {
|
||||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
leftside[i] = w->points[leftv][i];
|
||||
leftv--;
|
||||
if (leftv == -1)
|
||||
leftv = numvertex-1;
|
||||
leftv = numvertex - 1;
|
||||
} while (sy[leftv] <= y);
|
||||
count = sy[leftv]-y;
|
||||
for (i=0 ; i<5 ; i++)
|
||||
leftstep[i] = (w->points[leftv][i] - leftside[i])/count;
|
||||
count = sy[leftv] - y;
|
||||
for (i = 0; i < 5; i++)
|
||||
leftstep[i] = (w->points[leftv][i] - leftside[i]) / count;
|
||||
}
|
||||
if (y >= sy[rightv])
|
||||
{
|
||||
do
|
||||
{
|
||||
for (i=0 ; i<5 ; i++)
|
||||
if (y >= sy[rightv]) {
|
||||
do {
|
||||
for (i = 0; i < 5; i++)
|
||||
rightside[i] = w->points[rightv][i];
|
||||
rightv++;
|
||||
if (rightv == numvertex)
|
||||
rightv = 0;
|
||||
} while (sy[rightv] <= y);
|
||||
count = sy[rightv]-y;
|
||||
for (i=0 ; i<5 ; i++)
|
||||
rightstep[i] = (w->points[rightv][i] - rightside[i])/count;
|
||||
count = sy[rightv] - y;
|
||||
for (i = 0; i < 5; i++)
|
||||
rightstep[i] = (w->points[rightv][i] - rightside[i]) / count;
|
||||
}
|
||||
|
||||
REN_DrawSpanLinear (y);
|
||||
|
||||
for (i=0 ; i<5 ; i++)
|
||||
{
|
||||
for (i = 0; i < 5; i++) {
|
||||
leftside[i] += leftstep[i];
|
||||
rightside[i] += rightstep[i];
|
||||
}
|
||||
|
@ -511,13 +485,14 @@ void REN_RasterizeFaceLinear (winding_t *w)
|
|||
REN_BeginCamera
|
||||
===================
|
||||
*/
|
||||
float r_width_2, r_height_3;
|
||||
plane_t rfrustum[5];
|
||||
float r_width_2, r_height_3;
|
||||
plane_t rfrustum[5];
|
||||
|
||||
void REN_BeginCamera (void)
|
||||
void
|
||||
REN_BeginCamera (void)
|
||||
{
|
||||
r_width_2 = (float)r_width / 2;
|
||||
r_height_3 = (float)r_height / 3;
|
||||
r_width_2 = (float) r_width / 2;
|
||||
r_height_3 = (float) r_height / 3;
|
||||
|
||||
|
||||
// clip to right side
|
||||
|
@ -541,7 +516,7 @@ void REN_BeginCamera (void)
|
|||
// clip to bottom side
|
||||
rfrustum[3].normal[0] = 0;
|
||||
rfrustum[3].normal[1] = 1;
|
||||
rfrustum[3].normal[2] = 2*r_height_3 / r_width_2;
|
||||
rfrustum[3].normal[2] = 2 * r_height_3 / r_width_2;
|
||||
rfrustum[3].dist = 0;
|
||||
|
||||
// near Z
|
||||
|
@ -552,7 +527,8 @@ void REN_BeginCamera (void)
|
|||
}
|
||||
|
||||
|
||||
void REN_BeginXY (void)
|
||||
void
|
||||
REN_BeginXY (void)
|
||||
{
|
||||
rfrustum[0].normal[0] = 1;
|
||||
rfrustum[0].normal[1] = 0;
|
||||
|
@ -580,16 +556,17 @@ void REN_BeginXY (void)
|
|||
REN_DrawCameraFace
|
||||
=====================
|
||||
*/
|
||||
void REN_DrawCameraFace (face_t *idpol)
|
||||
void
|
||||
REN_DrawCameraFace (face_t * idpol)
|
||||
{
|
||||
int i;
|
||||
float scale;
|
||||
int numvertex;
|
||||
winding_t *w, *in;
|
||||
vec3_t temp;
|
||||
int i;
|
||||
float scale;
|
||||
int numvertex;
|
||||
winding_t *w, *in;
|
||||
vec3_t temp;
|
||||
|
||||
if (!idpol->w)
|
||||
return; // overconstrained plane
|
||||
return; // overconstrained plane
|
||||
|
||||
r_face = idpol;
|
||||
|
||||
|
@ -607,13 +584,12 @@ void REN_DrawCameraFace (face_t *idpol)
|
|||
|
||||
w = NewWinding (numvertex);
|
||||
w->numpoints = numvertex;
|
||||
for (i=0 ; i<numvertex ; i++)
|
||||
{
|
||||
for (i = 0; i < numvertex; i++) {
|
||||
VectorSubtract (in->points[i], r_origin, temp);
|
||||
|
||||
w->points[i][0] = DotProduct(temp,r_matrix[0]);
|
||||
w->points[i][1] = DotProduct(temp,r_matrix[1]);
|
||||
w->points[i][2] = DotProduct(temp,r_matrix[2]);
|
||||
w->points[i][0] = DotProduct (temp, r_matrix[0]);
|
||||
w->points[i][1] = DotProduct (temp, r_matrix[1]);
|
||||
w->points[i][2] = DotProduct (temp, r_matrix[2]);
|
||||
|
||||
w->points[i][3] = in->points[i][3];
|
||||
w->points[i][4] = in->points[i][4];
|
||||
|
@ -622,8 +598,7 @@ void REN_DrawCameraFace (face_t *idpol)
|
|||
//
|
||||
// 3D clip
|
||||
//
|
||||
for (i=0 ; i<4 ; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
w = ClipWinding (w, &rfrustum[i]);
|
||||
if (!w)
|
||||
return;
|
||||
|
@ -632,11 +607,10 @@ void REN_DrawCameraFace (face_t *idpol)
|
|||
//
|
||||
// project to 2D
|
||||
//
|
||||
for (i=0 ; i<w->numpoints ; i++)
|
||||
{
|
||||
for (i = 0; i < w->numpoints; i++) {
|
||||
scale = r_width_2 / w->points[i][2];
|
||||
w->points[i][0] = r_width_2 + scale*w->points[i][0];
|
||||
w->points[i][1] = r_height_3 - scale*w->points[i][1];
|
||||
w->points[i][0] = r_width_2 + scale * w->points[i][0];
|
||||
w->points[i][1] = r_height_3 - scale * w->points[i][1];
|
||||
w->points[i][2] = scale;
|
||||
}
|
||||
|
||||
|
@ -656,15 +630,16 @@ void REN_DrawCameraFace (face_t *idpol)
|
|||
REN_DrawXYFace
|
||||
=====================
|
||||
*/
|
||||
void REN_DrawXYFace (face_t *idpol)
|
||||
void
|
||||
REN_DrawXYFace (face_t * idpol)
|
||||
{
|
||||
int i, j, numvertex;
|
||||
winding_t *w, *in;
|
||||
float *dest, *source;
|
||||
float temp;
|
||||
int i, j, numvertex;
|
||||
winding_t *w, *in;
|
||||
float *dest, *source;
|
||||
float temp;
|
||||
|
||||
if (!idpol->w)
|
||||
return; // overconstrained plane
|
||||
return; // overconstrained plane
|
||||
w = idpol->w;
|
||||
|
||||
r_face = idpol;
|
||||
|
@ -684,11 +659,11 @@ void REN_DrawXYFace (face_t *idpol)
|
|||
w = NewWinding (numvertex);
|
||||
w->numpoints = numvertex;
|
||||
|
||||
for (i=0 ; i<numvertex ; i++)
|
||||
{
|
||||
// using Z as a scale for the 2D projection
|
||||
w->points[i][0] = (in->points[i][0] - r_origin[0])*r_origin[2];
|
||||
w->points[i][1] = r_height - (in->points[i][1] - r_origin[1])*r_origin[2];
|
||||
for (i = 0; i < numvertex; i++) {
|
||||
// using Z as a scale for the 2D projection
|
||||
w->points[i][0] = (in->points[i][0] - r_origin[0]) * r_origin[2];
|
||||
w->points[i][1] =
|
||||
r_height - (in->points[i][1] - r_origin[1]) * r_origin[2];
|
||||
w->points[i][2] = in->points[i][2] + 3000;
|
||||
w->points[i][3] = in->points[i][3];
|
||||
w->points[i][4] = in->points[i][4];
|
||||
|
@ -697,8 +672,7 @@ void REN_DrawXYFace (face_t *idpol)
|
|||
//
|
||||
// clip
|
||||
//
|
||||
for (i=0 ; i<4 ; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
w = ClipWinding (w, &rfrustum[i]);
|
||||
if (!w)
|
||||
return;
|
||||
|
@ -707,8 +681,7 @@ void REN_DrawXYFace (face_t *idpol)
|
|||
//
|
||||
// project to 2D
|
||||
//
|
||||
for (i=0 ; i<w->numpoints ; i++)
|
||||
{
|
||||
for (i = 0; i < w->numpoints; i++) {
|
||||
dest = w->points[i];
|
||||
if (dest[0] < 0)
|
||||
dest[0] = 0;
|
||||
|
@ -719,17 +692,14 @@ void REN_DrawXYFace (face_t *idpol)
|
|||
if (dest[1] > r_height)
|
||||
dest[1] = r_height;
|
||||
if (xy_viewnormal[2] > 0)
|
||||
dest[2] = 4096-dest[2];
|
||||
dest[2] = 4096 - dest[2];
|
||||
}
|
||||
|
||||
if (xy_viewnormal[2] > 0)
|
||||
{ // flip order when upside down
|
||||
for (i=0 ; i<w->numpoints/2 ; i++)
|
||||
{
|
||||
if (xy_viewnormal[2] > 0) { // flip order when upside down
|
||||
for (i = 0; i < w->numpoints / 2; i++) {
|
||||
dest = w->points[i];
|
||||
source = w->points[w->numpoints-1-i];
|
||||
for (j=0 ; j<5 ; j++)
|
||||
{
|
||||
source = w->points[w->numpoints - 1 - i];
|
||||
for (j = 0; j < 5; j++) {
|
||||
temp = dest[j];
|
||||
dest[j] = source[j];
|
||||
source[j] = temp;
|
||||
|
@ -746,4 +716,3 @@ void REN_DrawXYFace (face_t *idpol)
|
|||
REN_RasterizeFaceLinear (w);
|
||||
free (w);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue