mirror of
https://github.com/id-Software/Quake-Tools.git
synced 2026-03-20 00:49:35 +01:00
Source release of QuakeEd, the map editing application on NEXTSTEP for Quake.
This commit is contained in:
69
QuakeEd/DictList.m
Normal file
69
QuakeEd/DictList.m
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#import "qedefs.h"
|
||||
|
||||
@implementation DictList
|
||||
|
||||
//
|
||||
// Read in variable # of objects from FILE *
|
||||
//
|
||||
- initListFromFile:(FILE *)fp
|
||||
{
|
||||
id d;
|
||||
|
||||
[super init];
|
||||
do
|
||||
{
|
||||
d = [(Dict *)[Dict alloc] initFromFile:fp];
|
||||
if (d != NULL)
|
||||
[self addObject:d];
|
||||
} while(d != NULL);
|
||||
[d free];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Write out list file
|
||||
//
|
||||
- writeListFile:(char *)filename
|
||||
{
|
||||
FILE *fp;
|
||||
int i;
|
||||
id obj;
|
||||
|
||||
fp = fopen(filename,"w+t");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
fprintf(fp,"// Object List written by QuakeEd\n");
|
||||
|
||||
for (i = 0;i < maxElements;i++)
|
||||
{
|
||||
obj = [self objectAt:i];
|
||||
[obj writeBlockTo:fp];
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Find the keyword in all the Dict objects
|
||||
//
|
||||
- (id) findDictKeyword:(char *)key
|
||||
{
|
||||
int i;
|
||||
dict_t *d;
|
||||
id dict;
|
||||
|
||||
for (i = 0;i < maxElements;i++)
|
||||
{
|
||||
dict = [self objectAt:i];
|
||||
d = [(Dict *)dict findKeyword:key];
|
||||
if (d != NULL)
|
||||
return dict;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user