mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-02 23:32:09 +00:00
Finally, everything does compile.
However, it still won't work (no gorm, commented code, ...). Borrow an old implementation of the Storage class until I figure out just what it's being used for.
This commit is contained in:
parent
71dab805de
commit
b336ba79f1
17 changed files with 694 additions and 246 deletions
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
#include "Storage.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
#include "qedefs.h"
|
#include "Dict.h"
|
||||||
|
|
||||||
@implementation Dict
|
@implementation Dict
|
||||||
|
|
||||||
|
@ -31,14 +31,14 @@ copyFromZone
|
||||||
JDC
|
JDC
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
- copyFromZone:(NSZone *)zone
|
- copy
|
||||||
{
|
{
|
||||||
id new;
|
id new;
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
char *old;
|
char *old;
|
||||||
|
|
||||||
new = [super copyFromZone: zone];
|
new = [super copy];
|
||||||
for (i=0 ; i<numElements ; i++)
|
for (i=0 ; i<numElements ; i++)
|
||||||
{
|
{
|
||||||
d = [self elementAt: i];
|
d = [self elementAt: i];
|
||||||
|
@ -202,7 +202,7 @@ JDC
|
||||||
|
|
||||||
temp = [self parseMultipleFrom:key];
|
temp = [self parseMultipleFrom:key];
|
||||||
count = [temp count];
|
count = [temp count];
|
||||||
[temp free];
|
[temp release];
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ JDC
|
||||||
[temp removeElementAt:i];
|
[temp removeElementAt:i];
|
||||||
free(d->value);
|
free(d->value);
|
||||||
d->value = [self convertListToString:temp];
|
d->value = [self convertListToString:temp];
|
||||||
[temp free];
|
[temp release];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef DictList_h
|
#ifndef DictList_h
|
||||||
#endif DictList_h
|
#define DictList_h
|
||||||
|
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
@interface DictList:List
|
@interface DictList:NSMutableArray
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
#include "qedefs.h"
|
#include "DictList.h"
|
||||||
|
#include "Dict.h"
|
||||||
|
|
||||||
@implementation DictList
|
@implementation DictList
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
[self addObject:d];
|
[self addObject:d];
|
||||||
} while(d != NULL);
|
} while(d != NULL);
|
||||||
[d free];
|
[d release];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -37,9 +38,9 @@
|
||||||
|
|
||||||
fprintf(fp,"// Object List written by QuakeEd\n");
|
fprintf(fp,"// Object List written by QuakeEd\n");
|
||||||
|
|
||||||
for (i = 0;i < maxElements;i++)
|
for (i = 0;i < [self count];i++)
|
||||||
{
|
{
|
||||||
obj = [self objectAt:i];
|
obj = [self objectAtIndex:i];
|
||||||
[obj writeBlockTo:fp];
|
[obj writeBlockTo:fp];
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -56,9 +57,9 @@
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
id dict;
|
id dict;
|
||||||
|
|
||||||
for (i = 0;i < maxElements;i++)
|
for (i = 0;i < [self count];i++)
|
||||||
{
|
{
|
||||||
dict = [self objectAt:i];
|
dict = [self objectAtIndex:i];
|
||||||
d = [(Dict *)dict findKeyword:key];
|
d = [(Dict *)dict findKeyword:key];
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
return dict;
|
return dict;
|
||||||
|
|
|
@ -12,7 +12,7 @@ MapEdit_RESOURCE_FILES= \
|
||||||
MapEdit.gorm
|
MapEdit.gorm
|
||||||
|
|
||||||
MapEdit_OBJC_FILES= \
|
MapEdit_OBJC_FILES= \
|
||||||
CameraView.m Clipper.m Entity.m EntityClass.m KeypairView.m Map.m PopScrollView.m Things.m XYView.m ZScrollView.m ZView.m render.m
|
CameraView.m Clipper.m Dict.m DictList.m Entity.m EntityClass.m InspectorControl.m KeypairView.m Map.m PopScrollView.m Preferences.m Project.m QuakeEd.m QuakeEd_main.m SetBrush.m Storage.m TexturePalette.m TextureView.m Things.m XYView.m ZScrollView.m ZView.m render.m
|
||||||
|
|
||||||
MapEdit_HEADERS= \
|
MapEdit_HEADERS= \
|
||||||
EntityClass.h
|
EntityClass.h
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
#include "qedefs.h"
|
#include "InspectorControl.h"
|
||||||
|
|
||||||
// Add .h-files here for new inspectors
|
// Add .h-files here for new inspectors
|
||||||
#include "Things.h"
|
#include "Things.h"
|
||||||
|
@ -16,52 +16,52 @@ id inspcontrol_i;
|
||||||
|
|
||||||
currentInspectorType = -1;
|
currentInspectorType = -1;
|
||||||
|
|
||||||
contentList = [[List alloc] init];
|
contentList = [[NSArray alloc] init];
|
||||||
windowList = [[List alloc] init];
|
windowList = [[NSArray alloc] init];
|
||||||
itemList = [[List alloc] init];
|
itemList = [[NSArray alloc] init];
|
||||||
|
|
||||||
// ADD NEW INSPECTORS HERE...
|
// ADD NEW INSPECTORS HERE...
|
||||||
|
|
||||||
[windowList addObject:win_project_i];
|
[windowList addObject:win_project_i];
|
||||||
[contentList addObject:[win_project_i contentView]];
|
[contentList addObject:[win_project_i contentView]];
|
||||||
[itemProject_i setKeyEquivalent:'1'];
|
[itemProject_i setKeyEquivalent:@"1"];
|
||||||
[itemList addObject:itemProject_i];
|
[itemList addObject:itemProject_i];
|
||||||
|
|
||||||
[windowList addObject:win_textures_i];
|
[windowList addObject:win_textures_i];
|
||||||
[contentList addObject:[win_textures_i contentView]];
|
[contentList addObject:[win_textures_i contentView]];
|
||||||
[itemTextures_i setKeyEquivalent:'2'];
|
[itemTextures_i setKeyEquivalent:@"2"];
|
||||||
[itemList addObject:itemTextures_i];
|
[itemList addObject:itemTextures_i];
|
||||||
|
|
||||||
[windowList addObject:win_things_i];
|
[windowList addObject:win_things_i];
|
||||||
[contentList addObject:[win_things_i contentView]];
|
[contentList addObject:[win_things_i contentView]];
|
||||||
[itemThings_i setKeyEquivalent:'3'];
|
[itemThings_i setKeyEquivalent:@"3"];
|
||||||
[itemList addObject:itemThings_i];
|
[itemList addObject:itemThings_i];
|
||||||
|
|
||||||
[windowList addObject:win_prefs_i];
|
[windowList addObject:win_prefs_i];
|
||||||
[contentList addObject:[win_prefs_i contentView]];
|
[contentList addObject:[win_prefs_i contentView]];
|
||||||
[itemPrefs_i setKeyEquivalent:'4'];
|
[itemPrefs_i setKeyEquivalent:@"4"];
|
||||||
[itemList addObject:itemPrefs_i];
|
[itemList addObject:itemPrefs_i];
|
||||||
|
|
||||||
[windowList addObject:win_settings_i];
|
[windowList addObject:win_settings_i];
|
||||||
[contentList addObject:[win_settings_i contentView]];
|
[contentList addObject:[win_settings_i contentView]];
|
||||||
[itemSettings_i setKeyEquivalent:'5'];
|
[itemSettings_i setKeyEquivalent:@"5"];
|
||||||
[itemList addObject:itemSettings_i];
|
[itemList addObject:itemSettings_i];
|
||||||
|
|
||||||
[windowList addObject:win_output_i];
|
[windowList addObject:win_output_i];
|
||||||
[contentList addObject:[win_output_i contentView]];
|
[contentList addObject:[win_output_i contentView]];
|
||||||
[itemOutput_i setKeyEquivalent:'6'];
|
[itemOutput_i setKeyEquivalent:@"6"];
|
||||||
[itemList addObject:itemOutput_i];
|
[itemList addObject:itemOutput_i];
|
||||||
|
|
||||||
[windowList addObject:win_help_i];
|
[windowList addObject:win_help_i];
|
||||||
[contentList addObject:[win_help_i contentView]];
|
[contentList addObject:[win_help_i contentView]];
|
||||||
[itemHelp_i setKeyEquivalent:'7'];
|
[itemHelp_i setKeyEquivalent:@"7"];
|
||||||
[itemList addObject:itemHelp_i];
|
[itemList addObject:itemHelp_i];
|
||||||
|
|
||||||
// Setup inspector window with project subview first
|
// Setup inspector window with project subview first
|
||||||
|
|
||||||
[inspectorView_i setAutoresizeSubviews:YES];
|
[inspectorView_i setAutoresizesSubviews:YES];
|
||||||
|
|
||||||
inspectorSubview_i = [contentList objectAt:i_project];
|
inspectorSubview_i = [contentList objectAtIndex:i_project];
|
||||||
[inspectorView_i addSubview:inspectorSubview_i];
|
[inspectorView_i addSubview:inspectorSubview_i];
|
||||||
|
|
||||||
currentInspectorType = -1;
|
currentInspectorType = -1;
|
||||||
|
@ -98,21 +98,23 @@ id inspcontrol_i;
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
currentInspectorType = which;
|
currentInspectorType = which;
|
||||||
newView = [contentList objectAt:which];
|
newView = [contentList objectAtIndex:which];
|
||||||
|
|
||||||
cell = [itemList objectAt:which]; // set PopUpButton title
|
cell = [itemList objectAtIndex:which]; // set PopUpButton title
|
||||||
[popUpButton_i setTitle:[cell title]];
|
[popUpButton_i setTitle:[cell title]];
|
||||||
|
|
||||||
[inspectorView_i replaceSubview:inspectorSubview_i with:newView];
|
[inspectorView_i replaceSubview:inspectorSubview_i with:newView];
|
||||||
[inspectorView_i getFrame:&r];
|
r = [inspectorView_i frame];
|
||||||
inspectorSubview_i = newView;
|
inspectorSubview_i = newView;
|
||||||
[inspectorSubview_i setAutosizing:NS_WIDTHSIZABLE | NS_HEIGHTSIZABLE];
|
[inspectorSubview_i setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
[inspectorSubview_i sizeTo:r.size.width - 4 :r.size.height - 4];
|
r.size.width -= 4;
|
||||||
|
r.size.height -= 4;
|
||||||
|
[inspectorSubview_i setFrameSize:r.size];
|
||||||
|
|
||||||
[inspectorSubview_i lockFocus];
|
[inspectorSubview_i lockFocus];
|
||||||
[inspectorSubview_i getBounds:&f];
|
f = [inspectorSubview_i bounds];
|
||||||
PSsetgray(NS_LTGRAY);
|
PSsetgray(NSLightGray);
|
||||||
NSRectFill(&f);
|
NSRectFill(f);
|
||||||
[inspectorSubview_i unlockFocus];
|
[inspectorSubview_i unlockFocus];
|
||||||
[inspectorView_i display];
|
[inspectorView_i display];
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef Preferences_h
|
#ifndef Preferences_h
|
||||||
#define Preferences_h
|
#define Preferences_h
|
||||||
|
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
extern id preferences_i;
|
extern id preferences_i;
|
||||||
|
|
||||||
extern float lightaxis[3];
|
extern float lightaxis[3];
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
|
||||||
#include "qedefs.h"
|
#include "Preferences.h"
|
||||||
|
#include "Map.h"
|
||||||
|
#include "QuakeEd.h"
|
||||||
|
#include "Project.h"
|
||||||
|
|
||||||
id preferences_i;
|
id preferences_i;
|
||||||
|
|
||||||
|
@ -35,11 +38,11 @@ void WriteNumericDefault (char *name, float value)
|
||||||
char str[128];
|
char str[128];
|
||||||
|
|
||||||
sprintf (str,"%f", value);
|
sprintf (str,"%f", value);
|
||||||
NSWriteDefault (DEFOWNER, name, str);
|
//XXX NSWriteDefault (DEFOWNER, name, str);
|
||||||
}
|
}
|
||||||
void WriteStringDefault (char *name, char *value)
|
void WriteStringDefault (char *name, char *value)
|
||||||
{
|
{
|
||||||
NSWriteDefault (DEFOWNER, name, value);
|
//XXX NSWriteDefault (DEFOWNER, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -47,31 +50,31 @@ void WriteStringDefault (char *name, char *value)
|
||||||
//
|
//
|
||||||
- readDefaults
|
- readDefaults
|
||||||
{
|
{
|
||||||
char *string;
|
char *string = "";
|
||||||
float value;
|
float value = 0;
|
||||||
|
|
||||||
string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
|
//XXX string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
|
||||||
[self setProjectPath: string];
|
[self setProjectPath: string];
|
||||||
|
|
||||||
string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
|
//XXX string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
|
||||||
[self setBspSoundPath:string];
|
[self setBspSoundPath:string];
|
||||||
|
|
||||||
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
|
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
|
||||||
[self setShowBSP:value];
|
[self setShowBSP:value];
|
||||||
|
|
||||||
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
|
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
|
||||||
[self setBrushOffset:value];
|
[self setBrushOffset:value];
|
||||||
|
|
||||||
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
|
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
|
||||||
[self setStartWad:value];
|
[self setStartWad:value];
|
||||||
|
|
||||||
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
|
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
|
||||||
[self setXlight:value];
|
[self setXlight:value];
|
||||||
|
|
||||||
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
|
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
|
||||||
[self setYlight:value];
|
[self setYlight:value];
|
||||||
|
|
||||||
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
|
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
|
||||||
[self setZlight:value];
|
[self setZlight:value];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -83,14 +86,14 @@ void WriteStringDefault (char *name, char *value)
|
||||||
if (!path)
|
if (!path)
|
||||||
path = "";
|
path = "";
|
||||||
strcpy (projectpath, path);
|
strcpy (projectpath, path);
|
||||||
[startproject_i setStringValue: path];
|
[startproject_i setStringValue: [NSString stringWithCString:path]];
|
||||||
WriteStringDefault ("ProjectPath", path);
|
WriteStringDefault ("ProjectPath", path);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- setCurrentProject:sender
|
- setCurrentProject:sender
|
||||||
{
|
{
|
||||||
[startproject_i setStringValue: [project_i currentProjectFile]];
|
[startproject_i setStringValue: [NSString stringWithCString:[project_i currentProjectFile]]];
|
||||||
[self UIChanged: self];
|
[self UIChanged: self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -111,27 +114,27 @@ void WriteStringDefault (char *name, char *value)
|
||||||
- setBspSound:sender
|
- setBspSound:sender
|
||||||
{
|
{
|
||||||
id panel;
|
id panel;
|
||||||
char *types[]={"snd",NULL};
|
NSString *types[] = {@"snd"};
|
||||||
int rtn;
|
int rtn;
|
||||||
char **filename;
|
NSArray *filenames;
|
||||||
char path[1024], file[64];
|
char path[1024], file[64];
|
||||||
|
|
||||||
panel = [OpenPanel new];
|
panel = [NSOpenPanel new];
|
||||||
|
|
||||||
ExtractFilePath (bspSound, path);
|
//XXX ExtractFilePath (bspSound, path);
|
||||||
ExtractFileBase (bspSound, file);
|
//XXX ExtractFileBase (bspSound, file);
|
||||||
|
|
||||||
rtn = [panel
|
rtn = [panel
|
||||||
runModalForDirectory:path
|
runModalForDirectory:[NSString stringWithCString:path]
|
||||||
file: file
|
file: [NSString stringWithCString:file]
|
||||||
types: types];
|
types: [NSArray arrayWithObjects:types count:1]];
|
||||||
|
|
||||||
if (rtn)
|
if (rtn)
|
||||||
{
|
{
|
||||||
filename = (char **)[panel filenames];
|
filenames = [panel filenames];
|
||||||
strcpy(bspSound,[panel directory]);
|
strcpy(bspSound,[[panel directory] cString]);
|
||||||
strcat(bspSound,"/");
|
strcat(bspSound,"/");
|
||||||
strcat(bspSound,filename[0]);
|
strcat(bspSound, [[filenames objectAtIndex:0] cString]);
|
||||||
[self setBspSoundPath:bspSound];
|
[self setBspSoundPath:bspSound];
|
||||||
[self playBspSound];
|
[self playBspSound];
|
||||||
}
|
}
|
||||||
|
@ -160,15 +163,15 @@ void WriteStringDefault (char *name, char *value)
|
||||||
strcpy(bspSound,path);
|
strcpy(bspSound,path);
|
||||||
|
|
||||||
if (bspSound_i)
|
if (bspSound_i)
|
||||||
[bspSound_i free];
|
[bspSound_i release];
|
||||||
bspSound_i = [[Sound alloc] initFromSoundfile:bspSound];
|
bspSound_i = [[NSSound alloc] initWithContentsOfFile:[NSString stringWithCString:bspSound]];
|
||||||
if (!bspSound_i)
|
if (!bspSound_i)
|
||||||
{
|
{
|
||||||
strcpy (bspSound, "/NextLibrary/Sounds/Funk.snd");
|
strcpy (bspSound, "/NextLibrary/Sounds/Funk.snd");
|
||||||
bspSound_i = [[Sound alloc] initFromSoundfile:bspSound];
|
bspSound_i = [[NSSound alloc] initWithContentsOfFile:[NSString stringWithCString:bspSound]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[bspSoundField_i setStringValue:bspSound];
|
[bspSoundField_i setStringValue:[NSString stringWithCString:bspSound]];
|
||||||
|
|
||||||
WriteStringDefault ("BspSoundPath", bspSound);
|
WriteStringDefault ("BspSoundPath", bspSound);
|
||||||
|
|
||||||
|
@ -233,7 +236,7 @@ void WriteStringDefault (char *name, char *value)
|
||||||
if (startwad<0 || startwad>2)
|
if (startwad<0 || startwad>2)
|
||||||
startwad = 0;
|
startwad = 0;
|
||||||
|
|
||||||
[startwad_i selectCellAt:startwad : 0];
|
[startwad_i selectCellAtRow:startwad column: 0];
|
||||||
|
|
||||||
WriteNumericDefault ("StartWad", value);
|
WriteNumericDefault ("StartWad", value);
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -4,7 +4,17 @@
|
||||||
//
|
//
|
||||||
//======================================
|
//======================================
|
||||||
|
|
||||||
#include "qedefs.h"
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "QF/sys.h"
|
||||||
|
|
||||||
|
#include "Project.h"
|
||||||
|
#include "Map.h"
|
||||||
|
#include "QuakeEd.h"
|
||||||
|
#include "Preferences.h"
|
||||||
|
#include "Dict.h"
|
||||||
|
#include "Things.h"
|
||||||
|
#include "TexturePalette.h"
|
||||||
|
|
||||||
|
|
||||||
id project_i;
|
id project_i;
|
||||||
|
@ -28,7 +38,7 @@ id project_i;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = [preferences_i getProjectPath];
|
s = [preferences_i getProjectPath];
|
||||||
StripFilename(s);
|
//XXX StripFilename(s);
|
||||||
strcpy(path_basepath,s);
|
strcpy(path_basepath,s);
|
||||||
|
|
||||||
strcpy(path_progdir,s);
|
strcpy(path_progdir,s);
|
||||||
|
@ -40,7 +50,7 @@ id project_i;
|
||||||
strcpy(path_finalmapdir,s);
|
strcpy(path_finalmapdir,s);
|
||||||
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
||||||
|
|
||||||
[basepathinfo_i setStringValue:s]; // in Project Inspector
|
[basepathinfo_i setStringValue:[NSString stringWithCString:s]]; // in Project Inspector
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if ((s = [projectInfo getStringFor:BASEPATHKEY]))
|
if ((s = [projectInfo getStringFor:BASEPATHKEY]))
|
||||||
|
@ -114,12 +124,12 @@ id project_i;
|
||||||
//
|
//
|
||||||
- initProjSettings
|
- initProjSettings
|
||||||
{
|
{
|
||||||
[pis_basepath_i setStringValue:path_basepath];
|
[pis_basepath_i setStringValue:[NSString stringWithCString:path_basepath]];
|
||||||
[pis_fullvis_i setStringValue:string_fullvis];
|
[pis_fullvis_i setStringValue:[NSString stringWithCString:string_fullvis]];
|
||||||
[pis_fastvis_i setStringValue:string_fastvis];
|
[pis_fastvis_i setStringValue:[NSString stringWithCString:string_fastvis]];
|
||||||
[pis_novis_i setStringValue:string_novis];
|
[pis_novis_i setStringValue:[NSString stringWithCString:string_novis]];
|
||||||
[pis_relight_i setStringValue:string_relight];
|
[pis_relight_i setStringValue:[NSString stringWithCString:string_relight]];
|
||||||
[pis_leaktest_i setStringValue:string_leaktest];
|
[pis_leaktest_i setStringValue:[NSString stringWithCString:string_leaktest]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -132,27 +142,28 @@ id project_i;
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
end = [BSPoutput_i textLength];
|
end = [BSPoutput_i textLength];
|
||||||
[BSPoutput_i setSel:end :end];
|
[BSPoutput_i replaceCharactersInRange:NSMakeRange (end, 0) withString:[NSString stringWithCString:string]];
|
||||||
[BSPoutput_i replaceSel:string];
|
|
||||||
|
|
||||||
end = [BSPoutput_i textLength];
|
end = [BSPoutput_i textLength];
|
||||||
[BSPoutput_i setSel:end :end];
|
[BSPoutput_i setSelectedRange:NSMakeRange (end, 0)];
|
||||||
[BSPoutput_i scrollSelToVisible];
|
//XXX [BSPoutput_i scrollSelToVisible];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- clearBspOutput:sender
|
- clearBspOutput:sender
|
||||||
{
|
{
|
||||||
[BSPoutput_i selectAll:self];
|
int end;
|
||||||
[BSPoutput_i replaceSel:"\0"];
|
|
||||||
|
end = [BSPoutput_i textLength];
|
||||||
|
[BSPoutput_i replaceCharactersInRange:NSMakeRange (0, end) withString:@""];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- print
|
- print
|
||||||
{
|
{
|
||||||
[BSPoutput_i printPSCode:self];
|
//XXX [BSPoutput_i printPSCode:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,9 +174,9 @@ id project_i;
|
||||||
if (projectInfo == NULL)
|
if (projectInfo == NULL)
|
||||||
return self;
|
return self;
|
||||||
[self initVars];
|
[self initVars];
|
||||||
[mapbrowse_i reuseColumns:YES];
|
[mapbrowse_i setReusesColumns:YES];
|
||||||
[mapbrowse_i loadColumnZero];
|
[mapbrowse_i loadColumnZero];
|
||||||
[pis_wads_i reuseColumns:YES];
|
[pis_wads_i setReusesColumns:YES];
|
||||||
[pis_wads_i loadColumnZero];
|
[pis_wads_i loadColumnZero];
|
||||||
|
|
||||||
[things_i initEntities];
|
[things_i initEntities];
|
||||||
|
@ -209,7 +220,7 @@ id project_i;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list = nil;
|
list = nil;
|
||||||
Error ("Project: unknown browser to fill");
|
Sys_Error ("Project: unknown browser to fill");
|
||||||
}
|
}
|
||||||
|
|
||||||
max = [list count];
|
max = [list count];
|
||||||
|
@ -217,8 +228,8 @@ id project_i;
|
||||||
{
|
{
|
||||||
name = [list elementAt:i];
|
name = [list elementAt:i];
|
||||||
[matrix addRow];
|
[matrix addRow];
|
||||||
cell = [matrix cellAt:i :0];
|
cell = [matrix cellAtRow:i column:0];
|
||||||
[cell setStringValue:name];
|
[cell setStringValue:[NSString stringWithCString:name]];
|
||||||
[cell setLeaf:YES];
|
[cell setLeaf:YES];
|
||||||
[cell setLoaded:YES];
|
[cell setLoaded:YES];
|
||||||
}
|
}
|
||||||
|
@ -240,14 +251,14 @@ id project_i;
|
||||||
sprintf(fname,"%s/%s.map",path_mapdirectory,
|
sprintf(fname,"%s/%s.map",path_mapdirectory,
|
||||||
(char *)[mapList elementAt:row]);
|
(char *)[mapList elementAt:row]);
|
||||||
|
|
||||||
panel = NSGetAlertPanel("Loading...",
|
panel = NSGetAlertPanel(@"Loading...",
|
||||||
"Loading map. Please wait.",NULL,NULL,NULL);
|
@"Loading map. Please wait.",NULL,NULL,NULL);
|
||||||
[panel orderFront:NULL];
|
[panel orderFront:NULL];
|
||||||
|
|
||||||
[quakeed_i doOpen:fname];
|
[quakeed_i doOpen:fname];
|
||||||
|
|
||||||
[panel performClose:NULL];
|
[panel performClose:NULL];
|
||||||
NSFreeAlertPanel(panel);
|
//NSFreeAlertPanel(panel);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,14 +277,14 @@ id project_i;
|
||||||
name = (char *)[wadList elementAt:i];
|
name = (char *)[wadList elementAt:i];
|
||||||
if (!strcmp(name, wf))
|
if (!strcmp(name, wf))
|
||||||
{
|
{
|
||||||
[[pis_wads_i matrixInColumn:0] selectCellAt: i : 0];
|
[[pis_wads_i matrixInColumn:0] selectCellAtRow: i column: 0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the texture inspector
|
// update the texture inspector
|
||||||
[texturepalette_i initPaletteFromWadfile:wf ];
|
[texturepalette_i initPaletteFromWadfile:wf ];
|
||||||
[[map_i objectAt: 0] setKey:"wad" toValue: wf];
|
[[map_i objectAtIndex: 0] setKey:"wad" toValue: wf];
|
||||||
// [inspcontrol_i changeInspectorTo:i_textures];
|
// [inspcontrol_i changeInspectorTo:i_textures];
|
||||||
|
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
|
@ -311,9 +322,9 @@ id project_i;
|
||||||
path = [preferences_i getProjectPath];
|
path = [preferences_i getProjectPath];
|
||||||
if (!path || !path[0] || access(path,0))
|
if (!path || !path[0] || access(path,0))
|
||||||
{
|
{
|
||||||
rtn = NSRunAlertPanel("Project Error!",
|
rtn = NSRunAlertPanel(@"Project Error!",
|
||||||
"A default project has not been found.\n"
|
@"A default project has not been found.\n"
|
||||||
, "Open Project", NULL, NULL);
|
, @"Open Project", NULL, NULL);
|
||||||
if ([self openProject] == nil)
|
if ([self openProject] == nil)
|
||||||
while (1) // can't run without a project
|
while (1) // can't run without a project
|
||||||
[NSApp terminate: self];
|
[NSApp terminate: self];
|
||||||
|
@ -361,19 +372,19 @@ id project_i;
|
||||||
char path[128];
|
char path[128];
|
||||||
id openpanel;
|
id openpanel;
|
||||||
int rtn;
|
int rtn;
|
||||||
char *projtypes[2] = {"qpr",NULL};
|
NSString *projtypes[] ={ @"qpr"};
|
||||||
char **filenames;
|
NSArray *filenames;
|
||||||
char *dir;
|
const char *dir;
|
||||||
|
|
||||||
openpanel = [OpenPanel new];
|
openpanel = [NSOpenPanel new];
|
||||||
[openpanel allowMultipleFiles:NO];
|
//[openpanel allowMultipleFiles:NO];
|
||||||
[openpanel chooseDirectories:NO];
|
//[openpanel chooseDirectories:NO];
|
||||||
rtn = [openpanel runModalForTypes:projtypes];
|
rtn = [openpanel runModalForTypes:[NSArray arrayWithObjects: projtypes count:1]];
|
||||||
if (rtn == NS_OKTAG)
|
if (rtn == NSOKButton)
|
||||||
{
|
{
|
||||||
(const char *const *)filenames = [openpanel filenames];
|
filenames = [openpanel filenames];
|
||||||
dir = (char *)[openpanel directory];
|
dir = [[openpanel directory] cString];
|
||||||
sprintf(path,"%s/%s",dir,filenames[0]);
|
sprintf (path, "%s/%s", dir, [[filenames objectAtIndex:0] cString]);
|
||||||
strcpy(path_projectinfo,path);
|
strcpy(path_projectinfo,path);
|
||||||
[self openProjectFile:path];
|
[self openProjectFile:path];
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -1,9 +1,25 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include "QF/quakeio.h"
|
||||||
|
|
||||||
#include "QuakeEd.h"
|
#include "QuakeEd.h"
|
||||||
|
#include "Clipper.h"
|
||||||
|
#include "XYView.h"
|
||||||
|
#include "Map.h"
|
||||||
|
#include "CameraView.h"
|
||||||
|
#include "ZView.h"
|
||||||
|
#include "Preferences.h"
|
||||||
|
#include "InspectorControl.h"
|
||||||
|
#include "Project.h"
|
||||||
|
|
||||||
id quakeed_i;
|
id quakeed_i;
|
||||||
id entclasses_i;
|
id entclasses_i;
|
||||||
|
|
||||||
|
extern NSBezierPath *path;
|
||||||
id g_cmd_out_i;
|
id g_cmd_out_i;
|
||||||
|
|
||||||
BOOL autodirty;
|
BOOL autodirty;
|
||||||
|
@ -36,30 +52,18 @@ void My_Malloc_Error (int code)
|
||||||
write (1, "malloc error!\n", strlen("malloc error!\n")+1);
|
write (1, "malloc error!\n", strlen("malloc error!\n")+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
|
||||||
===============
|
|
||||||
AutoSave
|
|
||||||
|
|
||||||
Every five minutes, save a modified map
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
void AutoSave(DPSTimedEntry tag, double now, void *userData)
|
|
||||||
{
|
|
||||||
// automatic backup
|
|
||||||
if (autodirty)
|
|
||||||
{
|
|
||||||
autodirty = NO;
|
|
||||||
[map_i writeMapFile: FN_AUTOSAVE useRegion: NO];
|
|
||||||
}
|
|
||||||
[map_i writeStats];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DisplayCmdOutput (void)
|
void DisplayCmdOutput (void)
|
||||||
{
|
{
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
QFile *file;
|
||||||
|
int size;
|
||||||
|
|
||||||
LoadFile (FN_CMDOUT, (void **)&buffer);
|
file = Qopen (FN_CMDOUT, "rt");
|
||||||
|
size = Qfilesize (file);
|
||||||
|
buffer = malloc (size + 1);
|
||||||
|
size = Qread (file, buffer, size);
|
||||||
|
Qclose (file);
|
||||||
unlink (FN_CMDOUT);
|
unlink (FN_CMDOUT);
|
||||||
[project_i addToOutput:buffer];
|
[project_i addToOutput:buffer];
|
||||||
free (buffer);
|
free (buffer);
|
||||||
|
@ -69,7 +73,6 @@ void DisplayCmdOutput (void)
|
||||||
|
|
||||||
[preferences_i playBspSound];
|
[preferences_i playBspSound];
|
||||||
|
|
||||||
NSPing ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -79,8 +82,8 @@ CheckCmdDone
|
||||||
See if the BSP is done
|
See if the BSP is done
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
DPSTimedEntry cmdte;
|
//DPSTimedEntry cmdte;
|
||||||
void CheckCmdDone(DPSTimedEntry tag, double now, void *userData)
|
void CheckCmdDone(/*DPSTimedEntry tag,*/ double now, void *userData)
|
||||||
{
|
{
|
||||||
union wait statusp;
|
union wait statusp;
|
||||||
struct rusage rusage;
|
struct rusage rusage;
|
||||||
|
@ -89,49 +92,71 @@ void CheckCmdDone(DPSTimedEntry tag, double now, void *userData)
|
||||||
return;
|
return;
|
||||||
DisplayCmdOutput ();
|
DisplayCmdOutput ();
|
||||||
bsppid = 0;
|
bsppid = 0;
|
||||||
DPSRemoveTimedEntry( cmdte );
|
// DPSRemoveTimedEntry( cmdte );
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
@implementation QuakeEd
|
@implementation QuakeEd
|
||||||
|
|
||||||
|
/*
|
||||||
|
===============
|
||||||
|
AutoSave
|
||||||
|
|
||||||
|
Every five minutes, save a modified map
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
-(void) AutoSave
|
||||||
|
{
|
||||||
|
// automatic backup
|
||||||
|
if (autodirty)
|
||||||
|
{
|
||||||
|
autodirty = NO;
|
||||||
|
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
||||||
|
[map_i writeMapFile: FN_AUTOSAVE useRegion: NO];
|
||||||
|
}
|
||||||
|
[map_i writeStats];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
init
|
init
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
- initContent:(const NSRect *)contentRect
|
- initContent:(NSRect)contentRect
|
||||||
style:(int)aStyle
|
style:(int)aStyle
|
||||||
backing:(int)backingType
|
backing:(int)backingType
|
||||||
buttonMask:(int)mask
|
buttonMask:(int)mask
|
||||||
defer:(BOOL)flag
|
defer:(BOOL)flag
|
||||||
{
|
{
|
||||||
[super initContent:contentRect
|
[super initWithContentRect:contentRect
|
||||||
style:aStyle
|
styleMask:aStyle
|
||||||
backing:backingType
|
backing:backingType
|
||||||
buttonMask:mask
|
|
||||||
defer:flag];
|
defer:flag];
|
||||||
|
|
||||||
[self addToEventMask:
|
//XXX [self addToEventMask:
|
||||||
NS_RMOUSEDRAGGEDMASK|NS_LMOUSEDRAGGEDMASK];
|
//XXX NSRightMouseDragged|NSLeftMouseDragged];
|
||||||
|
|
||||||
malloc_error(My_Malloc_Error);
|
//XXX malloc_error(My_Malloc_Error);
|
||||||
|
|
||||||
quakeed_i = self;
|
quakeed_i = self;
|
||||||
dirty = autodirty = NO;
|
dirty = autodirty = NO;
|
||||||
|
|
||||||
DPSAddTimedEntry(5*60, AutoSave, self, NS_BASETHRESHOLD);
|
[NSTimer timerWithTimeInterval: 5 * 60
|
||||||
|
target: self
|
||||||
|
selector: @selector(AutoSave)
|
||||||
|
userInfo: nil
|
||||||
|
repeats: YES];
|
||||||
|
|
||||||
upath = newUserPath ();
|
path = [NSBezierPath new];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
#define FN_TEMPSAVE "/qcache/temp.map"
|
||||||
- setDefaultFilename
|
- setDefaultFilename
|
||||||
{
|
{
|
||||||
strcpy (filename, FN_TEMPSAVE);
|
strcpy (filename, FN_TEMPSAVE);
|
||||||
[self setTitleAsFilename:filename];
|
[self setTitleWithRepresentedFilename:[NSString stringWithCString:filename]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -160,15 +185,22 @@ BOOL updatecamera;
|
||||||
|
|
||||||
void postappdefined (void)
|
void postappdefined (void)
|
||||||
{
|
{
|
||||||
NSEvent ev;
|
NSEvent *ev;
|
||||||
|
|
||||||
if (updateinflight)
|
if (updateinflight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// post an event at the end of the que
|
// post an event at the end of the que
|
||||||
ev.type = NS_APPDEFINED;
|
ev = [NSEvent otherEventWithType: NSApplicationDefined
|
||||||
if (DPSPostEvent(&ev, 0) == -1)
|
location: NSZeroPoint
|
||||||
printf ("WARNING: DPSPostEvent: full\n");
|
modifierFlags: 0
|
||||||
|
timestamp: [[NSDate date] timeIntervalSinceReferenceDate]
|
||||||
|
windowNumber: 0
|
||||||
|
context: [NSApp context]
|
||||||
|
subtype: 0
|
||||||
|
data1: 0
|
||||||
|
data2: 0];
|
||||||
|
[NSApp postEvent: ev atStart: NO];
|
||||||
//printf ("posted\n");
|
//printf ("posted\n");
|
||||||
updateinflight = YES;
|
updateinflight = YES;
|
||||||
}
|
}
|
||||||
|
@ -237,44 +269,44 @@ instance draw the brush after each flush
|
||||||
{
|
{
|
||||||
[super flushWindow];
|
[super flushWindow];
|
||||||
|
|
||||||
if (!running || in_error)
|
if (!running)
|
||||||
return self; // don't lock focus before nib is finished loading
|
return self; // don't lock focus before nib is finished loading
|
||||||
|
|
||||||
if (_flushDisabled)
|
//if (_flushDisabled)
|
||||||
return self;
|
// return self;
|
||||||
|
|
||||||
[cameraview_i lockFocus];
|
[cameraview_i lockFocus];
|
||||||
if (clearinstance)
|
if (clearinstance)
|
||||||
{
|
{
|
||||||
PSnewinstance ();
|
//XXX PSnewinstance ();
|
||||||
clearinstance = NO;
|
clearinstance = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSsetinstance (1);
|
//XXX PSsetinstance (1);
|
||||||
linestart (0,0,0);
|
linestart (0,0,0);
|
||||||
[map_i makeSelectedPerform: @selector(CameraDrawSelf)];
|
[map_i makeSelectedPerform: @selector(CameraDrawSelf)];
|
||||||
[clipper_i cameraDrawSelf];
|
[clipper_i cameraDrawSelf];
|
||||||
lineflush ();
|
lineflush ();
|
||||||
PSsetinstance (0);
|
//XXX PSsetinstance (0);
|
||||||
[cameraview_i unlockFocus];
|
[cameraview_i unlockFocus];
|
||||||
|
|
||||||
[xyview_i lockFocus];
|
[xyview_i lockFocus];
|
||||||
PSsetinstance (1);
|
//XXX PSsetinstance (1);
|
||||||
linestart (0,0,0);
|
linestart (0,0,0);
|
||||||
[map_i makeSelectedPerform: @selector(XYDrawSelf)];
|
[map_i makeSelectedPerform: @selector(XYDrawSelf)];
|
||||||
lineflush ();
|
lineflush ();
|
||||||
[cameraview_i XYDrawSelf];
|
[cameraview_i XYDrawSelf];
|
||||||
[zview_i XYDrawSelf];
|
[zview_i XYDrawSelf];
|
||||||
[clipper_i XYDrawSelf];
|
[clipper_i XYDrawSelf];
|
||||||
PSsetinstance (0);
|
//XXX PSsetinstance (0);
|
||||||
[xyview_i unlockFocus];
|
[xyview_i unlockFocus];
|
||||||
|
|
||||||
[zview_i lockFocus];
|
[zview_i lockFocus];
|
||||||
PSsetinstance (1);
|
//XXX PSsetinstance (1);
|
||||||
[map_i makeSelectedPerform: @selector(ZDrawSelf)];
|
[map_i makeSelectedPerform: @selector(ZDrawSelf)];
|
||||||
[cameraview_i ZDrawSelf];
|
[cameraview_i ZDrawSelf];
|
||||||
[clipper_i ZDrawSelf];
|
[clipper_i ZDrawSelf];
|
||||||
PSsetinstance (0);
|
//XXX PSsetinstance (0);
|
||||||
[zview_i unlockFocus];
|
[zview_i unlockFocus];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -291,14 +323,17 @@ App delegate methods
|
||||||
|
|
||||||
- applicationDefined:(NSEvent *)theEvent
|
- applicationDefined:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSEvent ev, *evp;
|
NSEvent *evp;
|
||||||
|
|
||||||
updateinflight = NO;
|
updateinflight = NO;
|
||||||
|
|
||||||
//printf ("serviced\n");
|
//printf ("serviced\n");
|
||||||
|
|
||||||
// update screen
|
// update screen
|
||||||
evp = [NSApp peekNextEvent:-1 into:&ev];
|
evp = [NSApp nextEventMatchingMask: NSAnyEventMask
|
||||||
|
untilDate: [NSDate distantPast]
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: NO];
|
||||||
if (evp)
|
if (evp)
|
||||||
{
|
{
|
||||||
postappdefined();
|
postappdefined();
|
||||||
|
@ -322,7 +357,7 @@ App delegate methods
|
||||||
|
|
||||||
updatecamera = updatexy = updatez = NO;
|
updatecamera = updatexy = updatez = NO;
|
||||||
|
|
||||||
[self reenableFlushWindow];
|
[self enableFlushWindow];
|
||||||
[self flushWindow];
|
[self flushWindow];
|
||||||
|
|
||||||
// NSPing ();
|
// NSPing ();
|
||||||
|
@ -332,8 +367,8 @@ App delegate methods
|
||||||
|
|
||||||
- appDidInit:sender
|
- appDidInit:sender
|
||||||
{
|
{
|
||||||
NSScreen const *screens;
|
NSArray *screens;
|
||||||
int screencount;
|
NSScreen *scrn;
|
||||||
|
|
||||||
running = YES;
|
running = YES;
|
||||||
g_cmd_out_i = cmd_out_i; // for qprintf
|
g_cmd_out_i = cmd_out_i; // for qprintf
|
||||||
|
@ -345,14 +380,16 @@ App delegate methods
|
||||||
// scrollview and can't be
|
// scrollview and can't be
|
||||||
// connected directly in IB
|
// connected directly in IB
|
||||||
|
|
||||||
[self setFrameAutosaveName:"EditorWinFrame"];
|
[self setFrameAutosaveName:@"EditorWinFrame"];
|
||||||
[self clear: self];
|
[self clear: self];
|
||||||
|
|
||||||
// go to my second monitor
|
// go to my second monitor
|
||||||
[NSApp getScreens:&screens count:&screencount];
|
screens = [NSScreen screens];
|
||||||
if (screencount == 2)
|
if ([screens count] == 2) {
|
||||||
[self moveTopLeftTo:0 : screens[1].screenBounds.size.height
|
scrn = [screens objectAtIndex: 1];
|
||||||
screen:screens+1];
|
//XXX [self moveTopLeftTo:0 : [scrn frame].size.height
|
||||||
|
//XXX screen:scrn];
|
||||||
|
}
|
||||||
|
|
||||||
[self makeKeyAndOrderFront: self];
|
[self makeKeyAndOrderFront: self];
|
||||||
|
|
||||||
|
@ -379,7 +416,7 @@ App delegate methods
|
||||||
{
|
{
|
||||||
char const *t;
|
char const *t;
|
||||||
|
|
||||||
t = [sender stringValue];
|
t = [[sender stringValue] cString];
|
||||||
|
|
||||||
if (!strcmp (t, "texname"))
|
if (!strcmp (t, "texname"))
|
||||||
{
|
{
|
||||||
|
@ -425,7 +462,7 @@ App delegate methods
|
||||||
{
|
{
|
||||||
NSRect sbounds;
|
NSRect sbounds;
|
||||||
|
|
||||||
[[xyview_i _super_view] getBounds: &sbounds];
|
sbounds = [[xyview_i superview] bounds];
|
||||||
|
|
||||||
sbounds.origin.x += sbounds.size.width/2;
|
sbounds.origin.x += sbounds.size.width/2;
|
||||||
sbounds.origin.y += sbounds.size.height/2;
|
sbounds.origin.y += sbounds.size.height/2;
|
||||||
|
@ -440,7 +477,7 @@ App delegate methods
|
||||||
{
|
{
|
||||||
NSRect sbounds;
|
NSRect sbounds;
|
||||||
|
|
||||||
[[xyview_i _super_view] getBounds: &sbounds];
|
sbounds = [[xyview_i superview] bounds];
|
||||||
|
|
||||||
sbounds.origin.x += sbounds.size.width/2;
|
sbounds.origin.x += sbounds.size.width/2;
|
||||||
sbounds.origin.y += sbounds.size.height/2;
|
sbounds.origin.y += sbounds.size.height/2;
|
||||||
|
@ -529,7 +566,7 @@ applyRegion:
|
||||||
NSRect bounds;
|
NSRect bounds;
|
||||||
|
|
||||||
// get xy size
|
// get xy size
|
||||||
[[xyview_i _super_view] getBounds: &bounds];
|
bounds = [[xyview_i superview] bounds];
|
||||||
|
|
||||||
region_min[0] = bounds.origin.x;
|
region_min[0] = bounds.origin.x;
|
||||||
region_min[1] = bounds.origin.y;
|
region_min[1] = bounds.origin.y;
|
||||||
|
@ -624,7 +661,7 @@ saveBSP
|
||||||
if ([regionbutton_i intValue])
|
if ([regionbutton_i intValue])
|
||||||
{
|
{
|
||||||
strcpy (mappath, filename);
|
strcpy (mappath, filename);
|
||||||
StripExtension (mappath);
|
//XXX StripExtension (mappath);
|
||||||
strcat (mappath, ".reg");
|
strcat (mappath, ".reg");
|
||||||
[map_i writeMapFile: mappath useRegion: YES];
|
[map_i writeMapFile: mappath useRegion: YES];
|
||||||
wt = YES; // allways pop the dialog on region ops
|
wt = YES; // allways pop the dialog on region ops
|
||||||
|
@ -646,7 +683,7 @@ saveBSP
|
||||||
|
|
||||||
strcpy (bsppath, destdir);
|
strcpy (bsppath, destdir);
|
||||||
strcat (bsppath, "/");
|
strcat (bsppath, "/");
|
||||||
ExtractFileBase (mappath, bsppath + strlen(bsppath));
|
//XXX ExtractFileBase (mappath, bsppath + strlen(bsppath));
|
||||||
strcat (bsppath, ".bsp");
|
strcat (bsppath, ".bsp");
|
||||||
|
|
||||||
ExpandCommand (cmdline, expandedcmd, mappath, bsppath);
|
ExpandCommand (cmdline, expandedcmd, mappath, bsppath);
|
||||||
|
@ -666,16 +703,16 @@ saveBSP
|
||||||
{
|
{
|
||||||
id panel;
|
id panel;
|
||||||
|
|
||||||
panel = NSGetAlertPanel("BSP In Progress",expandedcmd,NULL,NULL,NULL);
|
panel = NSGetAlertPanel(@"BSP In Progress",[NSString stringWithCString:expandedcmd],NULL,NULL,NULL);
|
||||||
[panel makeKeyAndOrderFront:NULL];
|
[panel makeKeyAndOrderFront:NULL];
|
||||||
system(expandedcmd);
|
system(expandedcmd);
|
||||||
NSFreeAlertPanel(panel);
|
[panel release];
|
||||||
[self makeKeyAndOrderFront:NULL];
|
[self makeKeyAndOrderFront:NULL];
|
||||||
DisplayCmdOutput ();
|
DisplayCmdOutput ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmdte = DPSAddTimedEntry(1, CheckCmdDone, self, NS_BASETHRESHOLD);
|
//cmdte = DPSAddTimedEntry(1, CheckCmdDone, self, NS_BASETHRESHOLD);
|
||||||
if (! (bsppid = fork ()) )
|
if (! (bsppid = fork ()) )
|
||||||
{
|
{
|
||||||
system (expandedcmd);
|
system (expandedcmd);
|
||||||
|
@ -726,7 +763,7 @@ saveBSP
|
||||||
}
|
}
|
||||||
|
|
||||||
kill (bsppid, 9);
|
kill (bsppid, 9);
|
||||||
CheckCmdDone (cmdte, 0, NULL);
|
//CheckCmdDone (cmdte, 0, NULL);
|
||||||
[project_i addToOutput: "\n\n========= STOPPED =========\n\n"];
|
[project_i addToOutput: "\n\n========= STOPPED =========\n\n"];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -748,7 +785,7 @@ Called by open or the project panel
|
||||||
[map_i readMapFile:filename];
|
[map_i readMapFile:filename];
|
||||||
|
|
||||||
[regionbutton_i setIntValue: 0];
|
[regionbutton_i setIntValue: 0];
|
||||||
[self setTitleAsFilename:fname];
|
[self setTitleWithRepresentedFilename:[NSString stringWithCString:fname]];
|
||||||
[self updateAll];
|
[self updateAll];
|
||||||
|
|
||||||
qprintf ("%s loaded\n", fname);
|
qprintf ("%s loaded\n", fname);
|
||||||
|
@ -765,17 +802,17 @@ open
|
||||||
- open: sender;
|
- open: sender;
|
||||||
{
|
{
|
||||||
id openpanel;
|
id openpanel;
|
||||||
static char *suffixlist[] = {"map", 0};
|
NSString *suffixlist[] = {@"map"};
|
||||||
|
|
||||||
openpanel = [OpenPanel new];
|
openpanel = [NSOpenPanel new];
|
||||||
|
|
||||||
if ( [openpanel
|
if ( [openpanel
|
||||||
runModalForDirectory: [project_i getMapDirectory]
|
runModalForDirectory: [NSString stringWithCString:[project_i getMapDirectory]]
|
||||||
file: ""
|
file: @""
|
||||||
types: suffixlist] != NS_OKTAG)
|
types: [NSArray arrayWithObjects:suffixlist count:1]] != NSOKButton)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
[self doOpen: (char *)[openpanel filename]];
|
[self doOpen: (char *)[[openpanel filename] cString]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -797,7 +834,7 @@ save:
|
||||||
dirty = autodirty = NO;
|
dirty = autodirty = NO;
|
||||||
|
|
||||||
strcpy (backup, filename);
|
strcpy (backup, filename);
|
||||||
StripExtension (backup);
|
//XXX StripExtension (backup);
|
||||||
strcat (backup, ".bak");
|
strcat (backup, ".bak");
|
||||||
rename (filename, backup); // copy old to .bak
|
rename (filename, backup); // copy old to .bak
|
||||||
|
|
||||||
|
@ -817,15 +854,15 @@ saveAs
|
||||||
id panel_i;
|
id panel_i;
|
||||||
char dir[1024];
|
char dir[1024];
|
||||||
|
|
||||||
panel_i = [SavePanel new];
|
panel_i = [NSSavePanel new];
|
||||||
ExtractFileBase (filename, dir);
|
//XXX ExtractFileBase (filename, dir);
|
||||||
[panel_i setRequiredFileType: "map"];
|
[panel_i setRequiredFileType: @"map"];
|
||||||
if ( [panel_i runModalForDirectory:[project_i getMapDirectory] file: dir] != NS_OKTAG)
|
if ( [panel_i runModalForDirectory:[NSString stringWithCString:[project_i getMapDirectory]] file: [NSString stringWithCString:dir]] != NSOKButton)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
strcpy (filename, [panel_i filename]);
|
strcpy (filename, [[panel_i filename] cString]);
|
||||||
|
|
||||||
[self setTitleAsFilename:filename];
|
[self setTitleWithRepresentedFilename:[NSString stringWithCString:filename]];
|
||||||
|
|
||||||
[self save: self];
|
[self save: self];
|
||||||
|
|
||||||
|
@ -855,7 +892,7 @@ saveAs
|
||||||
if ([clipper_i hide]) // first click hides only the clipper
|
if ([clipper_i hide]) // first click hides only the clipper
|
||||||
return [self updateAll];
|
return [self updateAll];
|
||||||
|
|
||||||
[map_i setCurrentEntity: [map_i objectAt: 0]]; // make world selected
|
[map_i setCurrentEntity: [map_i objectAtIndex: 0]]; // make world selected
|
||||||
[map_i makeSelectedPerform: @selector(deselect)];
|
[map_i makeSelectedPerform: @selector(deselect)];
|
||||||
[self updateAll];
|
[self updateAll];
|
||||||
|
|
||||||
|
@ -879,7 +916,7 @@ keyDown
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
// function keys
|
// function keys
|
||||||
switch (theEvent->data.key.keyCode)
|
switch ([theEvent keyCode])
|
||||||
{
|
{
|
||||||
case 60: // F2
|
case 60: // F2
|
||||||
[cameraview_i setDrawMode: dr_wire];
|
[cameraview_i setDrawMode: dr_wire];
|
||||||
|
@ -924,7 +961,7 @@ keyDown
|
||||||
}
|
}
|
||||||
|
|
||||||
// portable things
|
// portable things
|
||||||
ch = tolower(theEvent->data.key.charCode);
|
ch = tolower([[theEvent characters] cString][0]);
|
||||||
|
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
/* Generated by the NeXT Project Builder
|
#include <AppKit/AppKit.h>
|
||||||
NOTE: Do NOT change this file -- Project Builder maintains it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <appkit/appkit.h>
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
void main(int argc, char *argv[]) {
|
{
|
||||||
|
return NSApplicationMain (argc, argv);
|
||||||
[Application new];
|
|
||||||
if ([NSApp loadNibSection:"QuakeEd.nib" owner:NSApp withNames:NO])
|
|
||||||
[NSApp run];
|
|
||||||
|
|
||||||
[NSApp free];
|
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
#include "EntityClass.h"
|
#include "EntityClass.h"
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Preferences.h"
|
#include "Preferences.h"
|
||||||
|
#include "XYView.h"
|
||||||
|
#include "ZView.h"
|
||||||
|
#include "CameraView.h"
|
||||||
|
#include "Clipper.h"
|
||||||
|
#include "QuakeEd.h"
|
||||||
|
|
||||||
@implementation SetBrush
|
@implementation SetBrush
|
||||||
|
|
||||||
|
@ -1091,7 +1096,7 @@ BOOL fakebrush;
|
||||||
copy = [copy addFace: &face];
|
copy = [copy addFace: &face];
|
||||||
if (copy)
|
if (copy)
|
||||||
{
|
{
|
||||||
[copy perform:call];
|
[copy performSelector:call];
|
||||||
[copy dealloc];
|
[copy dealloc];
|
||||||
}
|
}
|
||||||
fakebrush = NO;
|
fakebrush = NO;
|
||||||
|
@ -1720,7 +1725,7 @@ id sb_newowner;
|
||||||
parent = sb_newowner;
|
parent = sb_newowner;
|
||||||
|
|
||||||
// hack to allow them to be copied to another map
|
// hack to allow them to be copied to another map
|
||||||
if ( [parent respondsTo:@selector(valueForQKey:)])
|
if ( [parent respondsToSelector:@selector(valueForQKey:)])
|
||||||
{
|
{
|
||||||
eclass = [entity_classes_i classForName: [parent valueForQKey: "classname"]];
|
eclass = [entity_classes_i classForName: [parent valueForQKey: "classname"]];
|
||||||
c = [eclass drawColor];
|
c = [eclass drawColor];
|
||||||
|
|
85
tools/Forge/Bundles/MapEdit/Storage.h
Normal file
85
tools/Forge/Bundles/MapEdit/Storage.h
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/* Interface for Objective C NeXT-compatible Storage object
|
||||||
|
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||||
|
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||||
|
|
||||||
|
This file is part of the Gnustep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
TODO:
|
||||||
|
Does not implement methods for archiving itself.
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
|
#ifndef __Storage_h_INCLUDE_GNU
|
||||||
|
#define __Storage_h_INCLUDE_GNU
|
||||||
|
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
@interface Storage : NSObject
|
||||||
|
{
|
||||||
|
@public
|
||||||
|
void *dataPtr; /* data of the Storage object */
|
||||||
|
const char *description; /* Element description */
|
||||||
|
NSUInteger numElements; /* Actual number of elements */
|
||||||
|
NSUInteger maxElements; /* Total allocated elements */
|
||||||
|
NSUInteger elementSize; /* Element size */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creating, freeing, initializing, and emptying */
|
||||||
|
|
||||||
|
- init;
|
||||||
|
- initCount:(NSUInteger)numSlots elementSize:(NSUInteger)sizeInBytes
|
||||||
|
description:(const char*)elemDesc;
|
||||||
|
- (void)dealloc;
|
||||||
|
- empty;
|
||||||
|
- copy;
|
||||||
|
|
||||||
|
/* Manipulating the elements */
|
||||||
|
|
||||||
|
- (BOOL)isEqual: anObject;
|
||||||
|
- (const char *)description;
|
||||||
|
- (NSUInteger)count;
|
||||||
|
- (void *)elementAt:(NSUInteger)index;
|
||||||
|
- replaceElementAt:(NSUInteger)index with:(void *)anElement;
|
||||||
|
- setNumSlots:(NSUInteger)numSlots;
|
||||||
|
- setAvailableCapacity:(NSUInteger)numSlots;
|
||||||
|
- addElement:(void *)anElement;
|
||||||
|
- removeLastElement;
|
||||||
|
- insertElement:(void *)anElement at:(NSUInteger)index;
|
||||||
|
- removeElementAt:(NSUInteger)index;
|
||||||
|
|
||||||
|
/* Archiving */
|
||||||
|
|
||||||
|
- write:(TypedStream *)stream;
|
||||||
|
- read:(TypedStream *)stream;
|
||||||
|
|
||||||
|
/* old-style creation */
|
||||||
|
|
||||||
|
+ new;
|
||||||
|
+ newCount:(NSUInteger)count elementSize:(NSUInteger)sizeInBytes
|
||||||
|
description:(const char *)descriptor;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
@defs(Storage)
|
||||||
|
} NXStorageId;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __Storage_h_INCLUDE_GNU */
|
284
tools/Forge/Bundles/MapEdit/Storage.m
Normal file
284
tools/Forge/Bundles/MapEdit/Storage.m
Normal file
|
@ -0,0 +1,284 @@
|
||||||
|
/* Implementation of Objective C NeXT-compatible Storage object
|
||||||
|
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||||
|
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||||
|
|
||||||
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* #include <config.h> */
|
||||||
|
#include "Storage.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define GNU_STORAGE_NTH(x,N) \
|
||||||
|
({ GNUStorageId* __s=(GNUStorageId*)(x); \
|
||||||
|
(void*)(((char*)__s->dataPtr)+(__s->elementSize*(N))); })
|
||||||
|
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
@defs(Storage)
|
||||||
|
} GNUStorageId;
|
||||||
|
|
||||||
|
@implementation Storage
|
||||||
|
|
||||||
|
+ initialize
|
||||||
|
{
|
||||||
|
if (self == [Storage class])
|
||||||
|
[self setVersion:0]; /* beta release */
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INITIALIZING, FREEING;
|
||||||
|
|
||||||
|
- 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
- init
|
||||||
|
{
|
||||||
|
return [self initCount:1
|
||||||
|
elementSize:sizeof(id)
|
||||||
|
description:@encode(id)];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
if (dataPtr)
|
||||||
|
free(dataPtr);
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (const char*) description
|
||||||
|
{
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// COPYING;
|
||||||
|
|
||||||
|
- copy
|
||||||
|
{
|
||||||
|
Storage *c = [super copy];
|
||||||
|
c->dataPtr = (void*) objc_malloc (maxElements * elementSize);
|
||||||
|
memcpy(c->dataPtr, dataPtr, numElements * elementSize);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// COMPARING TWO STORAGES;
|
||||||
|
|
||||||
|
- (BOOL)isEqual: anObject
|
||||||
|
{
|
||||||
|
if ([anObject isKindOfClass: [Storage class]]
|
||||||
|
&& [anObject count] == [self count]
|
||||||
|
&& !memcmp(((GNUStorageId*)anObject)->dataPtr,
|
||||||
|
dataPtr, numElements*elementSize))
|
||||||
|
return YES;
|
||||||
|
else
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MANAGING THE STORAGE CAPACITY;
|
||||||
|
|
||||||
|
static inline void _makeRoomForAnotherIfNecessary(Storage *self)
|
||||||
|
{
|
||||||
|
if (self->numElements == self->maxElements)
|
||||||
|
{
|
||||||
|
self->maxElements *= 2;
|
||||||
|
self->dataPtr = (void*)
|
||||||
|
objc_realloc (self->dataPtr, self->maxElements*self->elementSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void _shrinkIfDesired(Storage *self)
|
||||||
|
{
|
||||||
|
if (self->numElements < (self->maxElements / 2))
|
||||||
|
{
|
||||||
|
self->maxElements /= 2;
|
||||||
|
self->dataPtr = (void *)
|
||||||
|
objc_realloc (self->dataPtr, self->maxElements*self->elementSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- setAvailableCapacity:(NSUInteger)numSlots
|
||||||
|
{
|
||||||
|
if (numSlots > numElements)
|
||||||
|
{
|
||||||
|
maxElements = numSlots;
|
||||||
|
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- setNumSlots:(NSUInteger)numSlots
|
||||||
|
{
|
||||||
|
if (numSlots > numElements)
|
||||||
|
{
|
||||||
|
maxElements = numSlots;
|
||||||
|
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
||||||
|
bzero(STORAGE_NTH(numElements), (maxElements-numElements)*elementSize);
|
||||||
|
}
|
||||||
|
else if (numSlots < numElements)
|
||||||
|
{
|
||||||
|
numElements = numSlots;
|
||||||
|
_shrinkIfDesired (self);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Manipulating objects by index */
|
||||||
|
|
||||||
|
#define CHECK_INDEX(IND) if (IND >= numElements) return 0
|
||||||
|
|
||||||
|
- (NSUInteger) count
|
||||||
|
{
|
||||||
|
return numElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void*) elementAt: (NSUInteger)index
|
||||||
|
{
|
||||||
|
CHECK_INDEX(index);
|
||||||
|
return STORAGE_NTH (index);
|
||||||
|
}
|
||||||
|
|
||||||
|
- addElement: (void*)anElement
|
||||||
|
{
|
||||||
|
_makeRoomForAnotherIfNecessary(self);
|
||||||
|
memcpy(STORAGE_NTH(numElements), anElement, elementSize);
|
||||||
|
numElements++;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- insertElement: (void*)anElement at: (NSUInteger)index
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
CHECK_INDEX(index);
|
||||||
|
_makeRoomForAnotherIfNecessary(self);
|
||||||
|
#ifndef STABLE_MEMCPY
|
||||||
|
for (i = numElements; i >= index; i--)
|
||||||
|
memcpy (STORAGE_NTH(i+1), STORAGE_NTH(i), elementSize);
|
||||||
|
#else
|
||||||
|
memcpy (STORAGE_NTH (index+1),
|
||||||
|
STORAGE_NTH (index),
|
||||||
|
elementSize*(numElements-index));
|
||||||
|
#endif
|
||||||
|
memcpy(STORAGE_NTH(i), anElement, elementSize);
|
||||||
|
numElements++;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- removeElementAt: (NSUInteger)index
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
CHECK_INDEX(index);
|
||||||
|
numElements--;
|
||||||
|
#ifndef STABLE_MEMCPY
|
||||||
|
for (i = index; i < numElements; i++)
|
||||||
|
memcpy(STORAGE_NTH(i),
|
||||||
|
STORAGE_NTH(i+1),
|
||||||
|
elementSize);
|
||||||
|
#else
|
||||||
|
memcpy (STORAGE_NTH (index),
|
||||||
|
STORAGE_NTH (index+1),
|
||||||
|
elementSize*(numElements-index-1));
|
||||||
|
#endif
|
||||||
|
_shrinkIfDesired(self);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- removeLastElement
|
||||||
|
{
|
||||||
|
if (numElements)
|
||||||
|
{
|
||||||
|
numElements--;
|
||||||
|
_shrinkIfDesired(self);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- replaceElementAt:(NSUInteger)index with:(void*)newElement
|
||||||
|
{
|
||||||
|
CHECK_INDEX(index);
|
||||||
|
memcpy(STORAGE_NTH(index), newElement, elementSize);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Emptying the Storage */
|
||||||
|
|
||||||
|
- empty
|
||||||
|
{
|
||||||
|
numElements = 0;
|
||||||
|
maxElements = 1;
|
||||||
|
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Archiving */
|
||||||
|
|
||||||
|
- write: (TypedStream*)aStream
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
- read: (TypedStream*)aStream
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ new
|
||||||
|
{
|
||||||
|
return [[self alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ newCount:(NSUInteger)count elementSize:(NSUInteger)sizeInBytes
|
||||||
|
description:(const char *)descriptor
|
||||||
|
{
|
||||||
|
return [[self alloc] initCount:count elementSize:sizeInBytes
|
||||||
|
description:descriptor];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -1,6 +1,17 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "QF/qendian.h"
|
#include "QF/qendian.h"
|
||||||
|
#include "QF/quakeio.h"
|
||||||
|
#include "QF/sys.h"
|
||||||
|
|
||||||
#include "TexturePalette.h"
|
#include "TexturePalette.h"
|
||||||
|
#include "Preferences.h"
|
||||||
|
#include "Map.h"
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "QuakeEd.h"
|
||||||
|
#include "SetBrush.h"
|
||||||
|
|
||||||
|
#include "Storage.h"
|
||||||
|
|
||||||
id texturepalette_i;
|
id texturepalette_i;
|
||||||
|
|
||||||
|
@ -101,18 +112,18 @@ void TEX_ImageFromMiptex (miptex_t *qtex)
|
||||||
height = LittleLong(qtex->height);
|
height = LittleLong(qtex->height);
|
||||||
|
|
||||||
bm = [[NSBitmapImageRep alloc]
|
bm = [[NSBitmapImageRep alloc]
|
||||||
initData: NULL
|
initWithBitmapDataPlanes: NULL
|
||||||
pixelsWide: width
|
pixelsWide: width
|
||||||
pixelsHigh: height
|
pixelsHigh: height
|
||||||
bitsPerSample: 8
|
bitsPerSample: 8
|
||||||
samplesPerPixel:3
|
samplesPerPixel:3
|
||||||
hasAlpha: NO
|
hasAlpha: NO
|
||||||
isPlanar: NO
|
isPlanar: NO
|
||||||
colorSpace: NS_RGBColorSpace
|
colorSpaceName: NSCalibratedRGBColorSpace
|
||||||
bytesPerRow: width*4
|
bytesPerRow: width*4
|
||||||
bitsPerPixel: 32];
|
bitsPerPixel: 32];
|
||||||
|
|
||||||
dest = (unsigned *)[bm data];
|
dest = (unsigned *)[bm bitmapData];
|
||||||
count = width*height;
|
count = width*height;
|
||||||
source = (byte *)qtex + LittleLong(qtex->offsets[0]);
|
source = (byte *)qtex + LittleLong(qtex->offsets[0]);
|
||||||
|
|
||||||
|
@ -176,6 +187,8 @@ void TEX_InitFromWad (char *path)
|
||||||
lumpinfo_t *lumpinfo;
|
lumpinfo_t *lumpinfo;
|
||||||
int numlumps;
|
int numlumps;
|
||||||
float start, stop;
|
float start, stop;
|
||||||
|
QFile *file;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
start = I_FloatTime ();
|
start = I_FloatTime ();
|
||||||
|
|
||||||
|
@ -185,21 +198,25 @@ void TEX_InitFromWad (char *path)
|
||||||
|
|
||||||
// free any textures
|
// free any textures
|
||||||
for (i=0 ; i<tex_count ; i++)
|
for (i=0 ; i<tex_count ; i++)
|
||||||
[qtextures[i].rep free];
|
[qtextures[i].rep release];
|
||||||
tex_count = 0;
|
tex_count = 0;
|
||||||
|
|
||||||
// try and use the cached wadfile
|
// try and use the cached wadfile
|
||||||
sprintf (local, "/qcache%s", newpath);
|
sprintf (local, "/qcache%s", newpath);
|
||||||
|
|
||||||
Sys_UpdateFile (local, newpath);
|
//Sys_UpdateFile (local, newpath);
|
||||||
|
//FIXME use wad functions
|
||||||
LoadFile (local, (void **)&wadfile);
|
file = Qopen (local, "rb");
|
||||||
|
size = Qfilesize (file);
|
||||||
|
wadfile = malloc (size);
|
||||||
|
Qread (file, wadfile, size);
|
||||||
|
Qclose (file);
|
||||||
wadinfo = (wadinfo_t *)wadfile;
|
wadinfo = (wadinfo_t *)wadfile;
|
||||||
|
|
||||||
if (strncmp (wadfile, "WAD2", 4))
|
if (strncmp ((char *)wadfile, "WAD2", 4))
|
||||||
{
|
{
|
||||||
unlink (local);
|
unlink (local);
|
||||||
Error ("TEX_InitFromWad: %s isn't a wadfile", newpath);
|
Sys_Error ("TEX_InitFromWad: %s isn't a wadfile", newpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
numlumps = LittleLong (wadinfo->numlumps);
|
numlumps = LittleLong (wadinfo->numlumps);
|
||||||
|
@ -208,7 +225,7 @@ void TEX_InitFromWad (char *path)
|
||||||
if (strcmp (lumpinfo->name, "PALETTE"))
|
if (strcmp (lumpinfo->name, "PALETTE"))
|
||||||
{
|
{
|
||||||
unlink (local);
|
unlink (local);
|
||||||
Error ("TEX_InitFromWad: %s doesn't have palette as 0",path);
|
Sys_Error ("TEX_InitFromWad: %s doesn't have palette as 0",path);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEX_InitPalette (wadfile + LittleLong(lumpinfo->filepos));
|
TEX_InitPalette (wadfile + LittleLong(lumpinfo->filepos));
|
||||||
|
@ -217,8 +234,8 @@ void TEX_InitFromWad (char *path)
|
||||||
for (i=1 ; i<numlumps ; i++, lumpinfo++)
|
for (i=1 ; i<numlumps ; i++, lumpinfo++)
|
||||||
{
|
{
|
||||||
if (lumpinfo->type != TYP_MIPTEX)
|
if (lumpinfo->type != TYP_MIPTEX)
|
||||||
Error ("TEX_InitFromWad: %s is not a miptex!",lumpinfo->name);
|
Sys_Error ("TEX_InitFromWad: %s is not a miptex!",lumpinfo->name);
|
||||||
CleanupName (lumpinfo->name,qtextures[tex_count].name);
|
//XXX CleanupName (lumpinfo->name,qtextures[tex_count].name);
|
||||||
TEX_ImageFromMiptex ( (miptex_t *)(wadfile +
|
TEX_ImageFromMiptex ( (miptex_t *)(wadfile +
|
||||||
LittleLong(lumpinfo->filepos) ));
|
LittleLong(lumpinfo->filepos) ));
|
||||||
}
|
}
|
||||||
|
@ -237,11 +254,11 @@ TEX_NumForName
|
||||||
*/
|
*/
|
||||||
qtexture_t *TEX_ForName (char *name)
|
qtexture_t *TEX_ForName (char *name)
|
||||||
{
|
{
|
||||||
char newname[16];
|
//XXX char newname[16];
|
||||||
int i;
|
int i;
|
||||||
qtexture_t *q;
|
qtexture_t *q;
|
||||||
|
|
||||||
CleanupName (name, newname);
|
//XXX CleanupName (name, newname);
|
||||||
|
|
||||||
for (i=0,q = qtextures ; i< tex_count ; i++, q++)
|
for (i=0,q = qtextures ; i< tex_count ; i++, q++)
|
||||||
{
|
{
|
||||||
|
@ -266,10 +283,9 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- display
|
- (void)display
|
||||||
{
|
{
|
||||||
[[textureView_i superview] display];
|
[[textureView_i superview] display];
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,7 +400,7 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
x = TEX_INDENT;
|
x = TEX_INDENT;
|
||||||
|
|
||||||
view = [textureView_i superview];
|
view = [textureView_i superview];
|
||||||
[view getBounds:&b];
|
b = [view bounds];
|
||||||
maxwidth = b.size.width;
|
maxwidth = b.size.width;
|
||||||
|
|
||||||
for (i = 0;i < max; i++)
|
for (i = 0;i < max; i++)
|
||||||
|
@ -407,9 +423,9 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
|
|
||||||
viewWidth = maxwidth;
|
viewWidth = maxwidth;
|
||||||
viewHeight = y + TEX_SPACING;
|
viewHeight = y + TEX_SPACING;
|
||||||
[textureView_i sizeTo:viewWidth :viewHeight];
|
[textureView_i setBoundsSize:NSMakeSize (viewWidth, viewHeight)];
|
||||||
pt.x = pt.y = 0;
|
pt.x = pt.y = 0;
|
||||||
[textureView_i scrollPoint:&pt];
|
[textureView_i scrollPoint:pt];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -471,11 +487,11 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
r.size.height += TEX_INDENT*2;
|
r.size.height += TEX_INDENT*2;
|
||||||
r.origin.x -= TEX_INDENT;
|
r.origin.x -= TEX_INDENT;
|
||||||
r.origin.y -= TEX_INDENT;
|
r.origin.y -= TEX_INDENT;
|
||||||
[textureView_i scrollRectToVisible:&r];
|
[textureView_i scrollRectToVisible:r];
|
||||||
[textureView_i display];
|
[textureView_i display];
|
||||||
sprintf(string,"%d x %d",(int)t->r.size.width,
|
sprintf(string,"%d x %d",(int)t->r.size.width,
|
||||||
(int)t->r.size.height - TEX_SPACING);
|
(int)t->r.size.height - TEX_SPACING);
|
||||||
[sizeField_i setStringValue:string];
|
[sizeField_i setStringValue:[NSString stringWithCString:string]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self texturedefChanged:self];
|
[self texturedefChanged:self];
|
||||||
|
@ -528,7 +544,7 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
int max;
|
int max;
|
||||||
|
|
||||||
max = [textureList_i count];
|
max = [textureList_i count];
|
||||||
CleanupName(name,name);
|
//XXX CleanupName(name,name);
|
||||||
for (i = 0;i < max;i++)
|
for (i = 0;i < max;i++)
|
||||||
{
|
{
|
||||||
t = [textureList_i elementAt:i];
|
t = [textureList_i elementAt:i];
|
||||||
|
@ -556,7 +572,7 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
int len;
|
int len;
|
||||||
char name[32];
|
char name[32], *n;
|
||||||
texpal_t *t;
|
texpal_t *t;
|
||||||
|
|
||||||
if (selectedTexture == -1)
|
if (selectedTexture == -1)
|
||||||
|
@ -564,7 +580,9 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
|
|
||||||
max = [textureList_i count];
|
max = [textureList_i count];
|
||||||
strcpy(name,(const char *)[sender stringValue]);
|
strcpy(name,(const char *)[sender stringValue]);
|
||||||
[sender setStringValue:strupr(name)];
|
for (n = name; *n; n++)
|
||||||
|
*n = toupper (*n);
|
||||||
|
[sender setStringValue:[NSString stringWithCString:name]];
|
||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
|
|
||||||
for (i = selectedTexture-1;i >= 0; i--)
|
for (i = selectedTexture-1;i >= 0; i--)
|
||||||
|
@ -779,11 +797,11 @@ qtexture_t *TEX_ForName (char *name)
|
||||||
for (i = 0;i < max; i++)
|
for (i = 0;i < max; i++)
|
||||||
[self setDisplayFlag:i to:0];
|
[self setDisplayFlag:i to:0];
|
||||||
|
|
||||||
brushes = [map_i objectAt:0];
|
brushes = [map_i objectAtIndex:0];
|
||||||
max = [brushes count];
|
max = [brushes count];
|
||||||
for (i = 0;i < max; i++)
|
for (i = 0;i < max; i++)
|
||||||
{
|
{
|
||||||
b = (SetBrush *)[brushes objectAt:i];
|
b = (SetBrush *)[brushes objectAtIndex:i];
|
||||||
numfaces = [b getNumBrushFaces];
|
numfaces = [b getNumBrushFaces];
|
||||||
for (j = 0; j < numfaces; j++)
|
for (j = 0; j < numfaces; j++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef TextureView_h
|
#ifndef TextureView_h
|
||||||
#define TextureView_h
|
#define TextureView_h
|
||||||
|
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
@interface TextureView:NSView
|
@interface TextureView:NSView
|
||||||
{
|
{
|
||||||
id parent_i;
|
id parent_i;
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
|
|
||||||
#include "qedefs.h"
|
#include "KeypairView.h"
|
||||||
|
#include "TextureView.h"
|
||||||
|
#include "TexturePalette.h"
|
||||||
|
|
||||||
|
#include "Storage.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@ -40,10 +44,10 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
|
|
||||||
selected = [parent_i getSelectedTexture];
|
selected = [parent_i getSelectedTexture];
|
||||||
list_i = [parent_i getList];
|
list_i = [parent_i getList];
|
||||||
PSselectfont("Helvetica-Medium",FONTSIZE);
|
GSSetFont (DEFCTXT, [NSFont fontWithName:@"Helvetica-Medium" size:FONTSIZE]);
|
||||||
PSrotate(0);
|
PSrotate(0);
|
||||||
|
|
||||||
PSsetgray(NS_LTGRAY);
|
PSsetgray(NSLightGray);
|
||||||
PSrectfill(rects->origin.x, rects->origin.y,
|
PSrectfill(rects->origin.x, rects->origin.y,
|
||||||
rects->size.width, rects->size.height);
|
rects->size.width, rects->size.height);
|
||||||
|
|
||||||
|
@ -59,12 +63,12 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
r.size.width += TEX_INDENT*2;
|
r.size.width += TEX_INDENT*2;
|
||||||
r.size.height += TEX_INDENT*2;
|
r.size.height += TEX_INDENT*2;
|
||||||
|
|
||||||
PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
//XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||||
PSrectfill(r.origin.x, r.origin.y,
|
PSrectfill(r.origin.x, r.origin.y,
|
||||||
r.size.width, r.size.height);
|
r.size.width, r.size.height);
|
||||||
p = t->r.origin;
|
p = t->r.origin;
|
||||||
p.y += TEX_SPACING;
|
p.y += TEX_SPACING;
|
||||||
[t->image drawAt:&p];
|
[t->image drawAtPoint:p fromRect:r operation:NSCompositeCopy fraction:1.0];
|
||||||
PSsetgray(0);
|
PSsetgray(0);
|
||||||
x = t->r.origin.x;
|
x = t->r.origin.x;
|
||||||
y = t->r.origin.y + 7;
|
y = t->r.origin.y + 7;
|
||||||
|
@ -84,7 +88,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
r.origin.x -= TEX_INDENT/2;
|
r.origin.x -= TEX_INDENT/2;
|
||||||
r.size.width += TEX_INDENT;
|
r.size.width += TEX_INDENT;
|
||||||
r.origin.y += 4;
|
r.origin.y += 4;
|
||||||
if (NSIntersectsRect(&rects[0],&r) == YES &&
|
if (NSIntersectsRect(rects[0],r) == YES &&
|
||||||
t->display)
|
t->display)
|
||||||
{
|
{
|
||||||
if (selected == i)
|
if (selected == i)
|
||||||
|
@ -100,7 +104,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
|
|
||||||
p = t->r.origin;
|
p = t->r.origin;
|
||||||
p.y += TEX_SPACING;
|
p.y += TEX_SPACING;
|
||||||
[t->image drawAt:&p];
|
[t->image drawAtPoint:p fromRect:r operation:NSCompositeCopy fraction:1.0];
|
||||||
x = t->r.origin.x;
|
x = t->r.origin.x;
|
||||||
y = t->r.origin.y + 7;
|
y = t->r.origin.y + 7;
|
||||||
PSmoveto(x,y);
|
PSmoveto(x,y);
|
||||||
|
@ -122,14 +126,14 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
NSPoint loc;
|
NSPoint loc;
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
int oldwindowmask;
|
//int oldwindowmask;
|
||||||
texpal_t *t;
|
texpal_t *t;
|
||||||
id list;
|
id list;
|
||||||
NSRect r;
|
NSRect r;
|
||||||
|
|
||||||
oldwindowmask = [window addToEventMask:NS_LMOUSEDRAGGEDMASK];
|
//oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
||||||
loc = theEvent->location;
|
loc = [theEvent locationInWindow];
|
||||||
[self convertPoint:&loc fromView:NULL];
|
[self convertPoint:loc fromView:NULL];
|
||||||
|
|
||||||
list = [parent_i getList];
|
list = [parent_i getList];
|
||||||
max = [list count];
|
max = [list count];
|
||||||
|
@ -137,7 +141,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
{
|
{
|
||||||
t = [list elementAt:i];
|
t = [list elementAt:i];
|
||||||
r = t->r;
|
r = t->r;
|
||||||
if (NSPointInRect(&loc,&r) == YES)
|
if (NSPointInRect(loc,r) == YES)
|
||||||
{
|
{
|
||||||
[self deselect];
|
[self deselect];
|
||||||
[parent_i setSelectedTexture:i];
|
[parent_i setSelectedTexture:i];
|
||||||
|
@ -145,7 +149,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[window setEventMask:oldwindowmask];
|
//[window setEventMask:oldwindowmask];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue