diff --git a/tools/Forge/Headers/Brush.h b/tools/Forge/Headers/Brush.h index 94b449fec..26bd11652 100644 --- a/tools/Forge/Headers/Brush.h +++ b/tools/Forge/Headers/Brush.h @@ -22,12 +22,12 @@ extern BOOL brushdraw; // YES when drawing cutbrushes and ents - deselect; - (BOOL)isSelected; -- (BOOL)XYmouseDown: (NXPoint *)pt; // return YES if brush handled -- (BOOL)ZmouseDown: (NXPoint *)pt; // return YES if brush handled +- (BOOL)XYmouseDown: (NSPoint *)pt; // return YES if brush handled +- (BOOL)ZmouseDown: (NSPoint *)pt; // return YES if brush handled -- _keyDown:(NXEvent *)theEvent; +- _keyDown:(NSEvent *)theEvent; -- (NXPoint)centerPoint; // for camera flyby mode +- (NSPoint)centerPoint; // for camera flyby mode - InstanceSize; - XYDrawSelf; diff --git a/tools/Forge/Headers/Project.h b/tools/Forge/Headers/Project.h index 016a23ba6..8a9750750 100644 --- a/tools/Forge/Headers/Project.h +++ b/tools/Forge/Headers/Project.h @@ -1,99 +1,94 @@ - #import #include -#define BASEPATHKEY "basepath" -#define MAPNAMESKEY "maps" -#define DESCKEY "desc" -#define WADSKEY "wads" -#define BSPFULLVIS "bspfullvis" -#define BSPFASTVIS "bspfastvis" -#define BSPNOVIS "bspnovis" -#define BSPRELIGHT "bsprelight" -#define BSPLEAKTEST "bspleaktest" -#define BSPENTITIES "bspentities" +#define EntSubdir @"progs" +#define MapSubdir @"maps" -#define SUBDIR_ENT "progs" // subdir names in heirarchy -#define SUBDIR_MAPS "maps" -#define SUBDIR_GFX "gfx" - -extern id project_i; +#define MapNames @"mapNames" +#define Descriptions @"descriptions" +#define WadFiles @"wadFiles" +#define BSPFullVis @"bspFullVisCommand" +#define BSPFastVis @"bspFastVisCommand" +#define BSPNoVis @"bspNoVisCommand" +#define BSPRelight @"bspRelightCommand" +#define BSPLeakTest @"bspLeakTestCommand" +#define BSPEntities @"bspEntitiesCommand" @interface Project: NSObject { - id projectInfo; // dictionary storage of project info + id projectInfo; // NSDictionary storage of project info - id basepathinfo_i; // outlet to base path info textfield - id mapbrowse_i; // outlet to QuakeEd Maps browser - id currentmap_i; // outlet to current map textfield - id mapList; // list of map names (Storage) - id descList; // list of map descriptions (Storage) - id wadList; // list of wad names (Storage) + id mapNames; // Array of map names (NSString) + id descriptions; // Array of map descriptions (NSString) + id wadNames; // Array of wad names (NSString) + + id pBasePathField; // outlet to base path info (NSTextField) + id pCurrentMapField; // outlet to current map textfield + id pBSPOutputView; // outlet to a command output NSTextView + id pMapBrowser; // outlet to Forge Maps browser - id pis_panel_i; // outlet to Project Info Settings (PIS) panel + id projectPrefsPanel; // outlet to Project Preferences panel - id pis_basepath_i; // outlet to PIS->base path - id pis_wads_i; // outlet to PIS->wad browser - id pis_fullvis_i; // outlet to PIS->full vis command - id pis_fastvis_i; // outlet to PIS->fast vis command - id pis_novis_i; // outlet to PIS->no vis command - id pis_relight_i; // outlet to PIS->relight command - id pis_leaktest_i; // outlet to PIS->leak test command - - id BSPoutput_i; // outlet to Text + id ppBasePath; // outlet to PPanel->"Base Path" + id ppWadBrowser; // outlet to PPanel->"WAD Browser" + id ppFullVisField; // outlet to PPanel->"Full VIS Compile" + id ppFastVisField; // outlet to PPanel->"Fast VIS Compile" + id ppNoVisField; // outlet to PPanel->"No VIS Compile" + id ppRelightField; // outlet to PPanel->"Relighting Compile" + id ppLeakTestField; // outlet to PPanel->"Leak Check Compile" - NSString *path_projectinfo; // path of QE_Project file + NSString *_projectPath; // path to *.forge file - NSString *path_basepath; // base path of heirarchy + NSString *_basePath; // base path of heirarchy + NSString *_progsPath; // derived from basepath + NSString *_mapPath; // derived from basepath + NSString *_finalMapPath; // derived from basepath - NSString *path_progdir; // derived from basepath - NSString *path_mapdirectory; // derived from basepath - NSString *path_finalmapdir; // derived from basepath + NSString *_wad8; // path of texture WAD for cmd-8 key + NSString *_wad9; // path of texture WAD for cmd-9 key + NSString *_wad0; // path of texture WAD for cmd-0 key - NSString *path_wad8; // path of texture WAD for cmd-8 key - NSString *path_wad9; // path of texture WAD for cmd-9 key - NSString *path_wad0; // path of texture WAD for cmd-0 key - - NSString *string_fullvis; // cmd-line parm - NSString *string_fastvis; // cmd-line parm - NSString *string_novis; // cmd-line parm - NSString *string_relight; // cmd-line parm - NSString *string_leaktest; // cmd-line parm - NSString *string_entities; // cmd-line parm + NSString *_fullVisCommand; // cmd-line parm + NSString *_fastVisCommand; // cmd-line parm + NSString *_noVisCommand; // cmd-line parm + NSString *_relightCommand; // cmd-line parm + NSString *_leakTestCommand; // cmd-line parm + NSString *_entitiesCommand; // cmd-line parm int showDescriptions; // 1 = show map descs in browser time_t lastModified; // last time project file was modified } -- initProject; -- initVars; +- (id) initProject; +- (id) initVars; +- (void) initProjectSettings; -- (char *)currentProjectFile; +- (void) setTextureWad: (NSString *) wadFile; -- setTextureWad: (char *)wf; +- (void) addToOutput: (NSString *) string; -- addToOutput: (NSString *) string; -- clearBspOutput: sender; -- initProjSettings; -- changeChar: (char) f to: (char) t in: (id) obj; -- (int) searchForString: (NSString *) str in: (id) obj; +- (void) changeString: (NSString *) f to: (NSString *) t in: (id) obj; +- (BOOL) searchForString: (NSString *) str in: (id) obj; -- parseProjectFile; // read defaultsdatabase for project path -- openProjectFile: (NSString *) path; // called by openProject and newProject -- openProject; -- clickedOnMap:sender; // called if clicked on map in browser -- clickedOnWad:sender; // called if clicked on wad in browser +- (void) parseProjectFile; // read database for project path +- (void) openProjectWithFile: (NSString *) path; // called by openProject and newProject +- (id) openProject; + +- (void) wadWasClicked: (id) sender; // called if clicked on wad in browser +- (void) mapWasClicked: (id) sender; // called if clicked on map in browser +- (void) clearBspOutput: (id) sender; // Called if the BSP output view should + // be cleared // methods to query the project file - +- (NSString *) currentProject; - (NSString *) mapDirectory; - (NSString *) finalMapDirectory; - (NSString *) progDirectory; -- (NSString *) WAD8; -- (NSString *) WAD9; -- (NSString *) WAD0; +- (NSString *) wad8; +- (NSString *) wad9; +- (NSString *) wad0; - (NSString *) fullVisCommand; - (NSString *) fastVisCommand; diff --git a/tools/Forge/Headers/TexturePalette.h b/tools/Forge/Headers/TexturePalette.h index 0a346bced..4fc4a2440 100644 --- a/tools/Forge/Headers/TexturePalette.h +++ b/tools/Forge/Headers/TexturePalette.h @@ -1,24 +1,20 @@ -typedef union -{ +typedef union pixel32_u { byte chan[4]; unsigned p; } pixel32_t; -typedef struct -{ +typedef struct texturedef_s { char texture[16]; float rotate; float shift[2]; float scale[2]; } texturedef_t; - -typedef struct -{ +typedef struct qtexture_s { char name[16]; - + int width; int height; NSBitmapImageRep *rep; @@ -34,9 +30,7 @@ extern qtexture_t qtextures[MAX_TEXTURES]; void TEX_InitFromWad (char *path); qtexture_t *TEX_ForName (char *name); - -typedef struct -{ +typedef struct { id image; // NXImage NSRect r; char *name; @@ -68,46 +62,46 @@ extern id texturepalette_i; int selectedTexture; } -- (char*)currentWad; -- initPaletteFromWadfile:(char *)wf; +- (NSString *) currentWad; +- initPaletteFromWadfile:(NSString *) wadFile; - computeTextureViewSize; - alphabetize; - getList; -- (int)getSelectedTexture; -- setSelectedTexture:(int)which; -- (int)getSelectedTexIndex; +- (int) getSelectedTexture; +- setSelectedTexture: (int) which; +- (int) getSelectedTexIndex; // Called externally -- (char *)getSelTextureName; -- setTextureByName:(char *)name; +- (NSString *) selectedTextureName; +- selectTextureByName: (NSString *) name; // New methods to replace the 2 above ones -- setTextureDef:(texturedef_t *)td; -- getTextureDef:(texturedef_t *)td; +- (texturedef_t *) textureDef; +- setTextureDef: (texturedef_t *) td; // Action methods -- searchForTexture:sender; +- searchForTexture: (id) sender; -- clearTexinfo: sender; +- clearTexinfo: (id) sender; -- incXShift:sender; -- decXShift:sender; +- incXShift: (id) sender; +- decXShift: (id) sender; -- incYShift:sender; -- decYShift:sender; +- incYShift: (id) sender; +- decYShift: (id) sender; -- incRotate: sender; -- decRotate: sender; +- incRotate: (id) sender; +- decRotate: (id) sender; -- incXScale:sender; -- decXScale:sender; +- incXScale: (id) sender; +- decXScale: (id) sender; -- incYScale:sender; -- decYScale:sender; +- incYScale: (id) sender; +- decYScale: (id) sender; -- texturedefChanged: sender; -- onlyShowMapTextures:sender; -- (int) searchForTextureInPalette:(char *)texture; -- setDisplayFlag:(int)index to:(int)value; +- texturedefChanged: (id) sender; +- onlyShowMapTextures: (id) sender; +- (int) searchForTextureInPalette: (NSString *) texture; +- setDisplayFlag: (int) index to: (int) value; @end diff --git a/tools/Forge/Project.m b/tools/Forge/Project.m index e9b36b35a..03c204998 100644 --- a/tools/Forge/Project.m +++ b/tools/Forge/Project.m @@ -6,6 +6,7 @@ #import "qedefs.h" +#import "Preferences.h" id project_i; @@ -25,148 +26,112 @@ id project_i; //=========================================================== - initVars { - char *s; - - s = [preferences_i getProjectPath]; - StripFilename(s); - strcpy(path_basepath,s); - - strcpy(path_progdir,s); - strcat(path_progdir,"/"SUBDIR_ENT); - - strcpy(path_mapdirectory,s); - strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir + NSString *s = [[Preferences sharedInstance] objectForKey: ProjectPath]; - strcpy(path_finalmapdir,s); - strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir - - [basepathinfo_i setStringValue:s]; // in Project Inspector - - #if 0 - if ((s = [projectInfo getStringFor:BASEPATHKEY])) - { - strcpy(path_basepath,s); - - strcpy(path_progdir,s); - strcat(path_progdir,"/"SUBDIR_ENT); - - strcpy(path_mapdirectory,s); - strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir + _basePath = [s stringByDeletingLastPathComponent]; - strcpy(path_finalmapdir,s); - strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir - - [basepathinfo_i setStringValue:s]; // in Project Inspector - } - #endif - - if ((s = [projectInfo getStringFor:BSPFULLVIS])) - { - strcpy(string_fullvis,s); - changeString('@','\"',string_fullvis); + _progsPath = [_basePath stringByAppendingPathComponent: EntSubdir]; + _mapPath = [_basePath stringByAppendingPathComponent: MapSubdir]; + _finalMapPath = [_basePath stringByAppendingPathComponent: MapSubdir]; + + [pBasePathField setStringValue: s]; // in Project Inspector + + if ((s = [projectInfo objectForKey: BSPFullVis])) { + _fullVisCommand = [[[s componentsSeparatedByString: @"@"] + componentsJoinedByString: @"\""] retain]; } - if ((s = [projectInfo getStringFor:BSPFASTVIS])) - { - strcpy(string_fastvis,s); - changeString('@','\"',string_fastvis); + if ((s = [projectInfo objectForKey: BSPFastVis])) { + _fastVisCommand = [[[s componentsSeparatedByString: @"@"] + componentsJoinedByString: @"\""] retain]; } - if ((s = [projectInfo getStringFor:BSPNOVIS])) - { - strcpy(string_novis,s); - changeString('@','\"',string_novis); + if ((s = [projectInfo objectForKey: BSPNoVis])) { + _noVisCommand = [[[s componentsSeparatedByString: @"@"] + componentsJoinedByString: @"\""] retain]; } - if ((s = [projectInfo getStringFor:BSPRELIGHT])) - { - strcpy(string_relight,s); - changeString('@','\"',string_relight); + if ((s = [projectInfo objectForKey: BSPRelight])) { + _relightCommand = [[[s componentsSeparatedByString: @"@"] + componentsJoinedByString: @"\""] retain]; } - if ((s = [projectInfo getStringFor:BSPLEAKTEST])) - { - strcpy(string_leaktest,s); - changeString('@','\"',string_leaktest); + if ((s = [projectInfo objectForKey: BSPLeakTest])) { + _leakTestCommand = [[[s componentsSeparatedByString: @"@"] + componentsJoinedByString: @"\""] retain]; } - if ((s = [projectInfo getStringFor:BSPENTITIES])) - { - strcpy(string_entities,s); - changeString('@','\"', string_entities); + if ((s = [projectInfo objectForKey: BSPEntities])) { + _entitiesCommand = [[[s componentsSeparatedByString: @"@"] + componentsJoinedByString: @"\""] retain]; } - // Build list of wads - wadList = [projectInfo parseMultipleFrom:WADSKEY]; + // Build list of wads + wadNames = [projectInfo objectForKey: WadFiles]; // Build list of maps & descriptions - mapList = [projectInfo parseMultipleFrom:MAPNAMESKEY]; - descList = [projectInfo parseMultipleFrom:DESCKEY]; - [self changeChar:'_' to:' ' in:descList]; + mapNames = [projectInfo objectForKey: MapNames]; + descriptions = [projectInfo objectForKey: Descriptions]; + [self changeString: @"_" to: @" " in: descriptions]; - [self initProjSettings]; + [self initProjectSettings]; return self; } -// -// Init Project Settings fields -// -- initProjSettings +- (void) initProjectSettings { - [pis_basepath_i setStringValue:path_basepath]; - [pis_fullvis_i setStringValue:string_fullvis]; - [pis_fastvis_i setStringValue:string_fastvis]; - [pis_novis_i setStringValue:string_novis]; - [pis_relight_i setStringValue:string_relight]; - [pis_leaktest_i setStringValue:string_leaktest]; + [ppBasePath setStringValue: _basePath]; + [ppFullVisField setStringValue: _fullVisCommand]; + [ppFullVisField setStringValue: _fastVisCommand]; + [ppNoVisField setStringValue: _noVisCommand]; + [ppRelightField setStringValue: _relightCommand]; + [ppLeakTestField setStringValue: _leakTestCommand]; - return self; + return; } // // Add text to the BSP Output window // -- addToOutput:(char *)string +- (void) addToOutput: (NSString *) string { - int end; + NSRange range = NSMakeRange([pBSPOutputView textLength], 0); + + [pBSPOutputView replaceCharactersInRange: range withString: string]; - end = [BSPoutput_i textLength]; - [BSPoutput_i setSel:end :end]; - [BSPoutput_i replaceSel:string]; + range = NSMakeRange([pBSPOutputView textLength], 0); + [pBSPOutputView scrollRangeToVisible: range]; - end = [BSPoutput_i textLength]; - [BSPoutput_i setSel:end :end]; - [BSPoutput_i scrollSelToVisible]; - - return self; + return; } -- clearBspOutput:sender +- (void) clearBspOutput: (id) sender { - [BSPoutput_i selectAll:self]; - [BSPoutput_i replaceSel:"\0"]; + [pBSPOutputView selectAll: self]; + [pBSPOutputView delete: self]; - return self; + return; } -- print -{ - [BSPoutput_i printPSCode:self]; - return self; -} +//- (void) print +//{ +// [pBSPOutputView printPSCode: self]; +// return; +//} - initProject { [self parseProjectFile]; - if (projectInfo == NULL) + if (!projectInfo) return self; + [self initVars]; - [mapbrowse_i reuseColumns:YES]; - [mapbrowse_i loadColumnZero]; - [pis_wads_i reuseColumns:YES]; - [pis_wads_i loadColumnZero]; +// [pMapBrowser reuseColumns: YES]; + [pMapBrowser loadColumnZero]; +// [ppWadBrowser reuseColumns: YES]; + [ppWadBrowser loadColumnZero]; [things_i initEntities]; @@ -176,333 +141,269 @@ id project_i; // // Change a character to another in a Storage list of strings // -- changeChar:(char)f to:(char)t in:(id)obj +- (void) changeString: (NSString *) f to: (NSString *) t in: (id) obj { - int i; - int max; - char *string; + NSMutableArray *newObj = [[NSMutableArray alloc] initWithCapacity: 10]; + NSEnumerator *enumerator = [obj objectEnumerator]; + id currentString; - max = [obj count]; - for (i = 0;i < max;i++) - { - string = [obj elementAt:i]; - changeString(f,t,string); + while ((currentString = [enumerator nextObject])) { + [newObj addObject: [[currentString componentsSeparatedByString: f] + componentsJoinedByString: t]]; + [currentString release]; } - return self; + + [obj release]; + obj = newObj; } -// -// Fill the QuakeEd Maps or wads browser +// Fill the Maps or Wads browser // (Delegate method - delegated in Interface Builder) -// -- (int)browser:sender fillMatrix:matrix inColumn:(int)column +- (int) browser: (id) sender fillMatrix: (id) matrix inColumn: (int) column { - id cell, list; - int max; - char *name; - int i; + NSString *name; + NSArray *list; + NSCell *cell; + int max; + int i; - if (sender == mapbrowse_i) - list = mapList; - else if (sender == pis_wads_i) - list = wadList; - else - { - list = nil; - Error ("Project: unknown browser to fill"); + if (sender == pMapBrowser) { + list = mapNames; + } else { + if (sender == ppWadBrowser) { + list = wadNames; + } else { + list = nil; + NSLog (@"Project: Unknown browser to fill"); + } } - + max = [list count]; - for (i = 0 ; i.QE_Project file // -- parseProjectFile +- (void) parseProjectFile { - char *path; - int rtn; + NSString *path; + int rtn; - path = [preferences_i getProjectPath]; - if (!path || !path[0] || access(path,0)) - { - rtn = NXRunAlertPanel("Project Error!", - "A default project has not been found.\n" - , "Open Project", NULL, NULL); + if (!(path = [[Preferences sharedInstance] objectForKey: ProjectPath])) { + rtn = NSRunAlertPanel (@"Project Error", + @"A default project has not been found.\n" + , @"Open Project", nil, nil); if ([self openProject] == nil) while (1) // can't run without a project - [NXApp terminate: self]; - return self; + [NSApp terminate: self]; + return; } - [self openProjectFile:path]; - return self; + [self openProjectWithFile: path]; + return; } // // Loads and parses a project file // -- openProjectFile:(char *)path +- (void) openProjectWithFile: (NSString *) path { - FILE *fp; - struct stat s; + [_projectPath release]; + _projectPath = path; - strcpy(path_projectinfo,path); - - projectInfo = NULL; - fp = fopen(path,"r+t"); - if (fp == NULL) - return self; - - stat(path,&s); - lastModified = s.st_mtime; - - projectInfo = [(Dict *)[Dict alloc] initFromFile:fp]; - fclose(fp); + [projectInfo release]; - return self; + projectInfo = [NSMutableDictionary dictionaryWithContentsOfFile: path]; + + return; } -- (char *)currentProjectFile -{ - return path_projectinfo; -} - -// // Open a project file -// -- openProject +- (id) openProject { - char path[128]; - id openpanel; - int rtn; - char *projtypes[2] = {"qpr",NULL}; - char **filenames; - char *dir; - - openpanel = [OpenPanel new]; - [openpanel allowMultipleFiles:NO]; - [openpanel chooseDirectories:NO]; - rtn = [openpanel runModalForTypes:projtypes]; - if (rtn == NX_OKTAG) - { - (const char *const *)filenames = [openpanel filenames]; - dir = (char *)[openpanel directory]; - sprintf(path,"%s/%s",dir,filenames[0]); - strcpy(path_projectinfo,path); - [self openProjectFile:path]; - return self; + int result; + NSArray *fileTypes = [NSArray arrayWithObject: @"forge"]; + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + + [openPanel setAllowsMultipleSelection: NO]; + [openPanel setCanChooseDirectories: NO]; + + result = [openPanel runModalForTypes: fileTypes]; + if (result == NSOKButton) { + NSArray *filenames = [[openPanel filenames] autorelease]; + NSString *directory = [[openPanel directory] autorelease]; + NSString *path = [directory stringByAppendingPathComponent: [filenames objectAtIndex: 0]]; + + [self openProjectWithFile: path]; + + return self; } - + return nil; } // -// Search for a string in a List of strings +// Search for a string in an array // -- (int)searchForString:(char *)str in:(id)obj +- (BOOL) searchForString: (NSString *) str in: (NSArray *) obj { - int i; - int max; - char *s; + NSEnumerator *enumerator = [obj objectEnumerator]; + id name; - max = [obj count]; - for (i = 0;i < max; i++) - { - s = (char *)[obj elementAt:i]; - if (!strcmp(s,str)) - return 1; + while ((name = [enumerator nextObject])) { + if ([[name stringValue] isEqualToString: str]) + return YES; } - return 0; + return NO; } -- (char *)getMapDirectory +- (NSString *) currentProject { - return path_mapdirectory; + return _projectPath; } -- (char *)getFinalMapDirectory +- (NSString *) mapDirectory { - return path_finalmapdir; + return _mapPath; } -- (char *)getProgDirectory +- (NSString *) finalMapDirectory { - return path_progdir; + return _finalMapPath; } - -// -// Return the WAD name for cmd-8 -// -- (char *)getWAD8 +- (NSString *) progDirectory { - if (!path_wad8[0]) - return NULL; - return path_wad8; + return _progsPath; } -// -// Return the WAD name for cmd-9 -// -- (char *)getWAD9 +- (NSString *) wad8 { - if (!path_wad9[0]) - return NULL; - return path_wad9; + return _wad8 ? _wad8 : nil; } -// -// Return the WAD name for cmd-0 -// -- (char *)getWAD0 +- (NSString *) wad9 { - if (!path_wad0[0]) - return NULL; - return path_wad0; + return _wad9 ? _wad9 : nil; } -// -// Return the FULLVIS cmd string -// -- (char *)getFullVisCmd +- (NSString *) wad0 { - if (!string_fullvis[0]) - return NULL; - return string_fullvis; + return _wad0 ? _wad0 : nil; } -// -// Return the FASTVIS cmd string -// -- (char *)getFastVisCmd +- (NSString *) fullVisCommand { - if (!string_fastvis[0]) - return NULL; - return string_fastvis; + return _fullVisCommand ? _fullVisCommand : nil; } -// -// Return the NOVIS cmd string -// -- (char *)getNoVisCmd +- (NSString *) fastVisCommand { - if (!string_novis[0]) - return NULL; - return string_novis; + return _fastVisCommand ? _fastVisCommand : nil; } -// -// Return the RELIGHT cmd string -// -- (char *)getRelightCmd +- (NSString *) noVisCommand { - if (!string_relight[0]) - return NULL; - return string_relight; + return _noVisCommand ? _noVisCommand : nil; } -// -// Return the LEAKTEST cmd string -// -- (char *)getLeaktestCmd +- (NSString *) relightCommand { - if (!string_leaktest[0]) - return NULL; - return string_leaktest; + return _relightCommand ? _relightCommand : nil; } -- (char *)getEntitiesCmd +- (NSString *) leakTestCommand { - if (!string_entities[0]) - return NULL; - return string_entities; + return _leakTestCommand ? _leakTestCommand : nil; +} + +- (NSString *) entitiesCommand +{ + return _entitiesCommand ? _entitiesCommand : nil; } @end diff --git a/tools/Forge/XYView.m b/tools/Forge/XYView.m index 2fb1e9cd2..aee9da990 100644 --- a/tools/Forge/XYView.m +++ b/tools/Forge/XYView.m @@ -14,12 +14,12 @@ float xy_viewdist; // clip behind this plane initFrame: ================== */ -- initFrame:(const NXRect *)frameRect +- initFrame:(const NSRect *)frameRect { [super initFrame:frameRect]; [self allocateGState]; - NXSetRect (&realbounds, 0,0,0,0); + NSSetRect (&realbounds, 0,0,0,0); gridsize = 16; scale = 1.0; @@ -119,10 +119,10 @@ initFrame: setOrigin:scale: =================== */ -- setOrigin: (NXPoint *)pt scale: (float)sc +- setOrigin: (NSPoint *)pt scale: (float)sc { - NXRect sframe; - NXRect newbounds; + NSRect sframe; + NSRect newbounds; // // calculate the area visible in the cliprect @@ -138,7 +138,7 @@ setOrigin:scale: // // union with the realbounds // - NXUnionRect (&realbounds, &newbounds); + NSUnionRect (&realbounds, &newbounds); // // redisplay everything @@ -168,8 +168,8 @@ setOrigin:scale: - centerOn: (vec3_t)org { - NXRect sbounds; - NXPoint mid, delta; + NSRect sbounds; + NSPoint mid, delta; [[xyview_i superview] getBounds: &sbounds]; @@ -195,7 +195,7 @@ When superview is resized */ - newSuperBounds { - NXRect r; + NSRect r; [superview getBounds: &r]; [self newRealBounds: &r]; @@ -212,9 +212,9 @@ Should only change the scroll bars, not cause any redraws. If realbounds has shrunk, nothing will change. =================== */ -- newRealBounds: (NXRect *)nb +- newRealBounds: (NSRect *)nb { - NXRect sbounds; + NSRect sbounds; realbounds = *nb; @@ -222,7 +222,7 @@ If realbounds has shrunk, nothing will change. // calculate the area visible in the cliprect // [superview getBounds: &sbounds]; - NXUnionRect (nb, &sbounds); + NSUnionRect (nb, &sbounds); // // size this view @@ -256,7 +256,7 @@ Called when the scaler popup on the window is used - scaleMenuTarget: sender { char const *item; - NXRect visrect, sframe; + NSRect visrect, sframe; float nscale; item = [[sender selectedCell] title]; @@ -285,13 +285,13 @@ Called when the scaler popup on the window is used zoomIn ============== */ -- zoomIn: (NXPoint *)constant +- zoomIn: (NSPoint *)constant { id itemlist; int selected, numrows, numcollumns; - NXRect visrect; - NXPoint ofs, new; + NSRect visrect; + NSPoint ofs, new; // // set the popup @@ -327,13 +327,13 @@ zoomIn zoomOut ============== */ -- zoomOut: (NXPoint *)constant +- zoomOut: (NSPoint *)constant { id itemlist; int selected, numrows, numcollumns; - NXRect visrect; - NXPoint ofs, new; + NSRect visrect; + NSPoint ofs, new; // // set the popup @@ -513,7 +513,7 @@ Rect is in global world (unscaled) coordinates ============ */ -- drawGrid: (const NXRect *)rect +- drawGrid: (const NSRect *)rect { int x,y, stopx, stopy; float top,bottom,right,left; @@ -640,9 +640,9 @@ PSsetrgbcolor (0.8,0.8,1.0); // thin grid color drawWire ================== */ -- drawWire: (const NXRect *)rects +- drawWire: (const NSRect *)rects { - NXRect visRect; + NSRect visRect; int i,j, c, c2; id ent, brush; vec3_t mins, maxs; @@ -658,7 +658,7 @@ drawWire } - NXRectClip(rects); + NSRectClip(rects); // erase window NXEraseRect (rects); @@ -703,7 +703,7 @@ drawWire newrect.origin.y -= gridsize; newrect.size.width += 2*gridsize; newrect.size.height += 2*gridsize; - if (!NXEqualRect (&newrect, &realbounds)) + if (!NSEqualRect (&newrect, &realbounds)) [self newRealBounds: &newrect]; return self; @@ -718,7 +718,7 @@ drawSolid - drawSolid { unsigned char *planes[5]; - NXRect visRect; + NSRect visRect; [self getVisibleRect:&visRect]; @@ -765,7 +765,7 @@ drawSolid [[self window] setBackingType:NX_RETAINED]; planes[0] = (unsigned char *)r_picbuffer; - NXDrawBitmap( + NSDrawBitmap( &visRect, r_width, r_height, @@ -779,7 +779,7 @@ drawSolid planes ); - NXPing (); + NSPing (); [[self window] setBackingType:NX_BUFFERED]; [self unlockFocus]; @@ -791,8 +791,8 @@ drawSolid drawSelf =================== */ -NXRect xy_draw_rect; -- drawSelf:(const NXRect *)rects :(int)rectCount +NSRect xy_draw_rect; +- drawSelf:(const NSRect *)rects :(int)rectCount { static float drawtime; // static to shut up compiler warning @@ -814,7 +814,7 @@ NXRect xy_draw_rect; if (timedrawing) { - NXPing (); + NSPing (); drawtime = I_FloatTime() - drawtime; printf ("CameraView drawtime: %5.3f\n", drawtime); } @@ -837,14 +837,14 @@ NXRect xy_draw_rect; dragLoop: ================ */ -static NXPoint oldreletive; -- dragFrom: (NXEvent *)startevent +static NSPoint oldreletive; +- dragFrom: (NSEvent *)startevent useGrid: (BOOL)ug callback: (void (*) (float dx, float dy)) callback { - NXEvent *event; - NXPoint startpt, newpt; - NXPoint reletive, delta; + NSEvent *event; + NSPoint startpt, newpt; + NSPoint reletive, delta; startpt = startevent->location; [self convertPoint:&startpt fromView:NULL]; @@ -859,12 +859,12 @@ static NXPoint oldreletive; while (1) { - event = [NXApp getNextEvent: NX_LMOUSEUPMASK | NX_LMOUSEDRAGGEDMASK - | NX_RMOUSEUPMASK | NX_RMOUSEDRAGGEDMASK | NX_APPDEFINEDMASK]; + event = [NSApp getNextEvent: NSLeftMouseUpMask | NSLeftMouseDraggedMask + | NSRightMouseUpMask | NSRightMouseDraggedMask | NSApplicationDefinedMask]; - if (event->type == NX_LMOUSEUP || event->type == NX_RMOUSEUP) + if (event->type == NSLeftMouseUp || event->type == NSRightMouseUp) break; - if (event->type == NX_APPDEFINED) + if (event->type == NSApplicationDefined) { // doesn't work. grrr. [quakeed_i applicationDefined:event]; continue; @@ -909,7 +909,7 @@ void DragCallback (float dx, float dy) [quakeed_i redrawInstance]; } -- selectionDragFrom: (NXEvent*)theEvent +- selectionDragFrom: (NSEvent*)theEvent { qprintf ("dragging selection"); [self dragFrom: theEvent @@ -925,8 +925,8 @@ void DragCallback (float dx, float dy) void ScrollCallback (float dx, float dy) { - NXRect basebounds; - NXPoint neworg; + NSRect basebounds; + NSPoint neworg; float scale; [ [xyview_i superview] getBounds: &basebounds]; @@ -942,7 +942,7 @@ void ScrollCallback (float dx, float dy) [xyview_i setOrigin: &neworg scale: scale]; } -- scrollDragFrom: (NXEvent*)theEvent +- scrollDragFrom: (NSEvent*)theEvent { qprintf ("scrolling view"); [self dragFrom: theEvent @@ -977,9 +977,9 @@ void DirectionCallback (float dx, float dy) [cameraview_i display]; } -- directionDragFrom: (NXEvent*)theEvent +- directionDragFrom: (NSEvent*)theEvent { - NXPoint pt; + NSPoint pt; qprintf ("changing camera direction"); @@ -1030,11 +1030,11 @@ void NewCallback (float dx, float dy) [quakeed_i redrawInstance]; } -- newBrushDragFrom: (NXEvent*)theEvent +- newBrushDragFrom: (NSEvent*)theEvent { id owner; texturedef_t td; - NXPoint pt; + NSPoint pt; qprintf ("sizing new brush"); @@ -1087,9 +1087,9 @@ void ControlCallback (float dx, float dy) [quakeed_i redrawInstance]; } -- (BOOL)planeDragFrom: (NXEvent*)theEvent +- (BOOL)planeDragFrom: (NSEvent*)theEvent { - NXPoint pt; + NSPoint pt; vec3_t dragpoint; if ([map_i numSelected] != 1) @@ -1123,9 +1123,9 @@ void ControlCallback (float dx, float dy) return YES; } -- (BOOL)shearDragFrom: (NXEvent*)theEvent +- (BOOL)shearDragFrom: (NSEvent*)theEvent { - NXPoint pt; + NSPoint pt; vec3_t dragpoint; vec3_t p1, p2; float time; @@ -1196,9 +1196,9 @@ void ControlCallback (float dx, float dy) mouseDown =================== */ -- mouseDown:(NXEvent *)theEvent +- mouseDown:(NSEvent *)theEvent { - NXPoint pt; + NSPoint pt; id ent; vec3_t p1, p2; int flags; @@ -1211,12 +1211,12 @@ mouseDown p1[2] = xy_viewnormal[2] * -4096; p2[2] = xy_viewnormal[2] * 4096; - flags = theEvent->flags & (NX_SHIFTMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_COMMANDMASK); + flags = theEvent->flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask); // // shift click to select / deselect a brush from the world // - if (flags == NX_SHIFTMASK) + if (flags == NSShiftKeyMask) { [map_i selectRay: p1 : p2 : YES]; return self; @@ -1225,7 +1225,7 @@ mouseDown // // cmd-shift click to set a target/targetname entity connection // - if (flags == (NX_SHIFTMASK|NX_COMMANDMASK) ) + if (flags == (NSShiftKeyMask|NSCommandKeyMask) ) { [map_i entityConnect: p1 : p2]; return self; @@ -1279,7 +1279,7 @@ mouseDown // // control click = position and drag camera // - if (flags == NX_CONTROLMASK) + if (flags == NSControlKeyMask) { [cameraview_i setXYOrigin: &pt]; [quakeed_i newinstance]; @@ -1292,7 +1292,7 @@ mouseDown // // command click = drag Z checker // - if (flags == NX_COMMANDMASK) + if (flags == NSCommandKeyMask) { // check single plane dragging [self shearDragFrom: theEvent]; @@ -1309,7 +1309,7 @@ return self; // // alt click = set entire brush texture // - if (flags == NX_ALTERNATEMASK) + if (flags == NSAlternateKeyMask) { if (drawmode != dr_texture) { @@ -1325,7 +1325,7 @@ return self; // // ctrl-alt click = set single face texture // - if (flags == (NX_CONTROLMASK | NX_ALTERNATEMASK) ) + if (flags == (NSControlKeyMask | NSAlternateKeyMask) ) { if (drawmode != dr_texture) { @@ -1348,27 +1348,27 @@ return self; rightMouseDown =================== */ -- rightMouseDown:(NXEvent *)theEvent +- rightMouseDown:(NSEvent *)theEvent { - NXPoint pt; + NSPoint pt; int flags; pt= theEvent->location; [self convertPoint:&pt fromView:NULL]; - flags = theEvent->flags & (NX_SHIFTMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_COMMANDMASK); + flags = theEvent->flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask); - if (flags == NX_COMMANDMASK) + if (flags == NSCommandKeyMask) { return [self scrollDragFrom: theEvent]; } - if (flags == NX_ALTERNATEMASK) + if (flags == NSAlternateKeyMask) { return [clipper_i XYClick: pt]; } - if (flags == 0 || flags == NX_CONTROLMASK) + if (flags == 0 || flags == NSControlKeyMask) { return [self directionDragFrom: theEvent]; } diff --git a/tools/Forge/ZScrollView.m b/tools/Forge/ZScrollView.m index 479d80eea..9e45914a3 100644 --- a/tools/Forge/ZScrollView.m +++ b/tools/Forge/ZScrollView.m @@ -10,7 +10,7 @@ Initizes a scroll view with a button at it's lower right corner ==================== */ -- initFrame:(const NXRect *)frameRect button1:b1 +- initFrame:(const NSRect *)frameRect button1:b1 { [super initFrame: frameRect]; @@ -37,7 +37,7 @@ Adjust the size for the pop up scale menu - tile { - NXRect scrollerframe; + NSRect scrollerframe; [super tile]; [hScroller getFrame: &scrollerframe]; @@ -56,7 +56,7 @@ Adjust the size for the pop up scale menu return YES; } -- superviewSizeChanged:(const NXSize *)oldSize +- superviewSizeChanged:(const NSSize *)oldSize { [super superviewSizeChanged: oldSize]; diff --git a/tools/Forge/ZView.m b/tools/Forge/ZView.m index b59bb2bc5..093d466ea 100644 --- a/tools/Forge/ZView.m +++ b/tools/Forge/ZView.m @@ -15,9 +15,9 @@ float zplanedir; initFrame: ================== */ -- initFrame:(const NXRect *)frameRect +- initFrame:(const NSRect *)frameRect { - NXPoint pt; + NSPoint pt; origin[0] = 0.333; origin[1] = 0.333; @@ -72,7 +72,7 @@ initFrame: return zscrollview_i; } -- setXYOrigin: (NXPoint *)pt +- setXYOrigin: (NSPoint *)pt { origin[0] = pt->x + 0.333; origin[1] = pt->y + 0.333; @@ -89,10 +89,10 @@ initFrame: setOrigin:scale: =================== */ -- setOrigin: (NXPoint *)pt scale: (float)sc +- setOrigin: (NSPoint *)pt scale: (float)sc { - NXRect sframe; - NXRect newbounds; + NSRect sframe; + NSRect newbounds; // // calculate the area visible in the cliprect @@ -156,7 +156,7 @@ Called when the scaler popup on the window is used - scaleMenuTarget: sender { char const *item; - NXRect visrect, sframe; + NSRect visrect, sframe; float nscale; item = [[sender selectedCell] title]; @@ -238,7 +238,7 @@ If realbounds has shrunk, nothing will change. */ - newRealBounds { - NXRect sbounds; + NSRect sbounds; float vistop, visbottom; if (minheight == oldminheight && maxheight == oldmaxheight) @@ -299,7 +299,7 @@ Rect is in global world (unscaled) coordinates ============ */ -- drawGrid: (const NXRect *)rect +- drawGrid: (const NSRect *)rect { int y, stopy; float top,bottom; @@ -441,9 +441,9 @@ drawSelf =============================================================================== */ -- drawSelf:(const NXRect *)rects :(int)rectCount +- drawSelf:(const NSRect *)rects :(int)rectCount { - NXRect visRect; + NSRect visRect; minheight = 999999; maxheight = -999999; @@ -453,7 +453,7 @@ drawSelf rects = &visRect; // erase window - NXEraseRect (&rects[0]); + NSEraseRect (&rects[0]); // draw grid [self drawGrid: &rects[0]]; @@ -491,17 +491,17 @@ XYDrawSelf /* ============== -getPoint: (NXPoint *)pt +getPoint: (NSPoint *)pt ============== */ -- getPoint: (NXPoint *)pt +- getPoint: (NSPoint *)pt { pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases pt->y = origin[1] + 0.333; return self; } -- setPoint: (NXPoint *)pt +- setPoint: (NSPoint *)pt { origin[0] = pt->x; origin[1] = pt->y; @@ -523,14 +523,14 @@ MOUSE CLICKING dragLoop: ================ */ -static NXPoint oldreletive; -- dragFrom: (NXEvent *)startevent +static NSPoint oldreletive; +- dragFrom: (NSEvent *)startevent useGrid: (BOOL)ug callback: (void (*) (float dy)) callback { - NXEvent *event; - NXPoint startpt, newpt; - NXPoint reletive, delta; + NSEvent *event; + NSPoint startpt, newpt; + NSPoint reletive, delta; int gridsize; gridsize = [xyview_i gridsize]; @@ -542,10 +542,10 @@ static NXPoint oldreletive; while (1) { - event = [NXApp getNextEvent: - NX_LMOUSEUPMASK | NX_LMOUSEDRAGGEDMASK - | NX_RMOUSEUPMASK | NX_RMOUSEDRAGGEDMASK]; - if (event->type == NX_LMOUSEUP || event->type == NX_RMOUSEUP) + event = [NSApp getNextEvent: + NSLeftMouseUpMask | NSLeftMouseDraggedMask + | NSRightMouseUpMask | NSRightMouseDraggedMask]; + if (event->type == NSLeftMouseUp || event->type == NSRightMouseUp) break; newpt = event->location; @@ -583,7 +583,7 @@ void ZDragCallback (float dy) [quakeed_i redrawInstance]; } -- selectionDragFrom: (NXEvent*)theEvent +- selectionDragFrom: (NSEvent*)theEvent { qprintf ("dragging selection"); [self dragFrom: theEvent @@ -599,8 +599,8 @@ void ZDragCallback (float dy) void ZScrollCallback (float dy) { - NXRect basebounds; - NXPoint neworg; + NSRect basebounds; + NSPoint neworg; float scale; [ [zview_i superview] getBounds: &basebounds]; @@ -614,7 +614,7 @@ void ZScrollCallback (float dy) [zview_i setOrigin: &neworg scale: scale]; } -- scrollDragFrom: (NXEvent*)theEvent +- scrollDragFrom: (NSEvent*)theEvent { qprintf ("scrolling view"); [self dragFrom: theEvent @@ -637,9 +637,9 @@ void ZControlCallback (float dy) [quakeed_i redrawInstance]; } -- (BOOL)planeDragFrom: (NXEvent*)theEvent +- (BOOL)planeDragFrom: (NSEvent*)theEvent { - NXPoint pt; + NSPoint pt; vec3_t dragpoint; if ([map_i numSelected] != 1) @@ -680,9 +680,9 @@ void ZControlCallback (float dy) mouseDown =================== */ -- mouseDown:(NXEvent *)theEvent +- mouseDown:(NSEvent *)theEvent { - NXPoint pt; + NSPoint pt; int flags; vec3_t p1; @@ -693,12 +693,12 @@ mouseDown p1[1] = origin[1]; p1[2] = pt.y; - flags = theEvent->flags & (NX_SHIFTMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_COMMANDMASK); + flags = theEvent->flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask); // // shift click to select / deselect a brush from the world // - if (flags == NX_SHIFTMASK) + if (flags == NSShiftKeyMask) { [map_i selectRay: p1 : p1 : NO]; return self; @@ -707,7 +707,7 @@ mouseDown // // alt click = set entire brush texture // - if (flags == NX_ALTERNATEMASK) + if (flags == NSAlternateKeyMask) { [map_i setTextureRay: p1 : p1 : YES]; return self; @@ -716,7 +716,7 @@ mouseDown // // control click = position view // - if (flags == NX_CONTROLMASK) + if (flags == NSControlKeyMask) { [cameraview_i setZOrigin: pt.y]; [quakeed_i updateAll]; @@ -756,15 +756,15 @@ mouseDown rightMouseDown =================== */ -- rightMouseDown:(NXEvent *)theEvent +- rightMouseDown:(NSEvent *)theEvent { - NXPoint pt; + NSPoint pt; int flags; pt= theEvent->location; [self convertPoint:&pt fromView:NULL]; - flags = theEvent->flags & (NX_SHIFTMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_COMMANDMASK); + flags = theEvent->flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask); // @@ -795,11 +795,11 @@ rightMouseDown modalMoveLoop ================ */ -- modalMoveLoop: (NXPoint *)basept :(vec3_t)movemod : converter +- modalMoveLoop: (NSPoint *)basept :(vec3_t)movemod : converter { vec3_t originbase; - NXEvent *event; - NXPoint newpt; + NSEvent *event; + NSPoint newpt; vec3_t delta; int i; @@ -811,7 +811,7 @@ modalMoveLoop // goto drawentry; - while (event->type != NX_LMOUSEUP) + while (event->type != NSLeftMouseUp) { // // calculate new point @@ -833,10 +833,10 @@ drawentry: // [quakeed_i newinstance]; [self display]; - NXPing (); + NSPing (); - event = [NXApp getNextEvent: - NX_LMOUSEUPMASK | NX_LMOUSEDRAGGEDMASK]; + event = [NSApp getNextEvent: + NSLeftMouseUpMask | NSLeftMouseDraggedMask]; } // @@ -852,7 +852,7 @@ drawentry: XYmouseDown =============== */ -- (BOOL)XYmouseDown: (NXPoint *)pt +- (BOOL)XYmouseDown: (NSPoint *)pt { vec3_t movemod; diff --git a/tools/Forge/misc.m b/tools/Forge/misc.m index 99eea5fff..8d9186bdf 100644 --- a/tools/Forge/misc.m +++ b/tools/Forge/misc.m @@ -104,7 +104,7 @@ void qprintf (char *fmt, ...) // prints text to cmd_out_i va_end (argptr); [g_cmd_out_i setStringValue: string]; - NXPing (); + NSPing (); return; } @@ -124,7 +124,7 @@ void Error (char *error, ...) static char string[1024]; if (in_error) - [NXApp terminate: NULL]; + [NSApp terminate: NULL]; in_error = YES; va_start (argptr,error); @@ -134,9 +134,9 @@ void Error (char *error, ...) strcat (string, "\nmap saved to "FN_CRASHSAVE); [map_i writeMapFile: FN_CRASHSAVE useRegion: NO]; - NXRunAlertPanel ("Error",string,NULL,NULL,NULL); + NSRunAlertPanel ("Error",string,NULL,NULL,NULL); - [NXApp terminate: NULL]; + [NSApp terminate: NULL]; } @@ -158,7 +158,7 @@ void CleanupName (char *in, char *out) } -void PrintRect (NXRect *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,