2010-09-11 08:35:25 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
|
|
#include "QF/quakeio.h"
|
2010-09-11 23:43:55 +00:00
|
|
|
#include "QF/sys.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
#include "QuakeEd.h"
|
2010-09-11 08:35:25 +00:00
|
|
|
#include "Clipper.h"
|
|
|
|
#include "XYView.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "CameraView.h"
|
|
|
|
#include "ZView.h"
|
|
|
|
#include "Preferences.h"
|
|
|
|
#include "InspectorControl.h"
|
|
|
|
#include "Project.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
id quakeed_i;
|
|
|
|
id entclasses_i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
extern NSBezierPath *path;
|
2010-09-11 10:03:41 +00:00
|
|
|
id g_cmd_out_i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
BOOL autodirty;
|
|
|
|
BOOL filter_light, filter_path, filter_entities;
|
|
|
|
BOOL filter_clip_brushes, filter_water_brushes, filter_world;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
BOOL running;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
int bsppid;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
// example command strings
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
char *fullviscmd =
|
|
|
|
"rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis $2\"";
|
|
|
|
char *fastviscmd =
|
|
|
|
"rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis -fast $2\"";
|
|
|
|
char *noviscmd =
|
|
|
|
"rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2\"";
|
|
|
|
char *relightcmd = "rsh satan \"/LocalApps/light $2\"";
|
|
|
|
char *leakcmd = "rsh satan \"/LocalApps/qbsp -mark -notjunc $1 $2\"";
|
2003-03-18 19:48:24 +00:00
|
|
|
#endif
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
NopSound (void)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
NSBeep ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
My_Malloc_Error (int code)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
// recursive toast Error ("Malloc error: %i\n", code);
|
|
|
|
write (1, "malloc error!\n", strlen ("malloc error!\n") + 1);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
DisplayCmdOutput (void)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
char *buffer;
|
2010-09-11 08:35:25 +00:00
|
|
|
QFile *file;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
file = Qopen (FN_CMDOUT, "rt");
|
2010-09-19 08:04:03 +00:00
|
|
|
if (!file)
|
|
|
|
return;
|
2010-09-11 08:35:25 +00:00
|
|
|
size = Qfilesize (file);
|
|
|
|
buffer = malloc (size + 1);
|
|
|
|
size = Qread (file, buffer, size);
|
|
|
|
Qclose (file);
|
2003-03-18 19:48:24 +00:00
|
|
|
unlink (FN_CMDOUT);
|
|
|
|
[project_i addToOutput:buffer];
|
|
|
|
free (buffer);
|
|
|
|
|
|
|
|
if ([preferences_i getShowBSP])
|
|
|
|
[inspcontrol_i changeInspectorTo:i_output];
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[preferences_i playBspSound];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
CheckCmdDone
|
|
|
|
|
|
|
|
See if the BSP is done
|
|
|
|
===============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
//DPSTimedEntry cmdte;
|
|
|
|
void
|
|
|
|
CheckCmdDone ( /* DPSTimedEntry tag, */ double now, void *userData)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
union wait statusp;
|
|
|
|
struct rusage rusage;
|
|
|
|
|
|
|
|
if (!wait4 (bsppid, &statusp, WNOHANG, &rusage))
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
|
|
|
DisplayCmdOutput ();
|
|
|
|
bsppid = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
// DPSRemoveTimedEntry( cmdte );
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
@implementation QuakeEd
|
2010-09-11 08:35:25 +00:00
|
|
|
/*
|
|
|
|
===============
|
|
|
|
AutoSave
|
|
|
|
|
|
|
|
Every five minutes, save a modified map
|
|
|
|
===============
|
|
|
|
*/
|
2010-09-12 07:25:25 +00:00
|
|
|
- (void) AutoSave {
|
2010-09-11 08:35:25 +00:00
|
|
|
// automatic backup
|
2010-09-11 10:03:41 +00:00
|
|
|
if (autodirty) {
|
2010-09-11 08:35:25 +00:00
|
|
|
autodirty = NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
|
|
|
[map_i writeMapFile: FN_AUTOSAVE useRegion:NO];
|
2010-09-11 08:35:25 +00:00
|
|
|
}
|
|
|
|
[map_i writeStats];
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
#define FN_TEMPSAVE "/qcache/temp.map"
|
2010-09-11 10:03:41 +00:00
|
|
|
-setDefaultFilename
|
|
|
|
{
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (filename, FN_TEMPSAVE);
|
2010-09-11 10:03:41 +00:00
|
|
|
[self setTitleWithRepresentedFilename: [NSString stringWithCString:filename]];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) dirty
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
DISPLAY UPDATING (handles both camera and XYView)
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
BOOL updateinflight;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
BOOL clearinstance;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
BOOL updatexy;
|
|
|
|
BOOL updatez;
|
|
|
|
BOOL updatecamera;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
postappdefined (void)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSEvent *ev;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (updateinflight)
|
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// post an event at the end of the que
|
2010-09-11 10:03:41 +00:00
|
|
|
ev =[NSEvent otherEventWithType: NSApplicationDefined location: NSZeroPoint modifierFlags: 0 timestamp:[[NSDate date]
|
|
|
|
timeIntervalSinceReferenceDate]
|
|
|
|
windowNumber: 0 context:[NSApp context]
|
|
|
|
subtype: 0 data1: 0 data2:0];
|
|
|
|
[NSApp postEvent: ev atStart:NO];
|
2010-09-12 05:31:59 +00:00
|
|
|
Sys_Printf ("posted\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
updateinflight = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
int c_updateall;
|
|
|
|
|
|
|
|
-updateAll // when a model has been changed
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
updatecamera = updatexy = updatez = YES;
|
|
|
|
c_updateall++;
|
|
|
|
postappdefined ();
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-updateAll:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[self updateAll];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-updateCamera // when the camera has moved
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
updatecamera = YES;
|
|
|
|
clearinstance = YES;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
postappdefined ();
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-updateXY
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
updatexy = YES;
|
|
|
|
postappdefined ();
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-updateZ
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
updatez = YES;
|
|
|
|
postappdefined ();
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-newinstance
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
clearinstance = YES;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-redrawInstance
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
clearinstance = YES;
|
|
|
|
[self flushWindow];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
flushWindow
|
|
|
|
|
|
|
|
instance draw the brush after each flush
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
-flushWindow
|
|
|
|
{
|
|
|
|
[super flushWindow];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
if (!running)
|
2010-09-11 10:03:41 +00:00
|
|
|
return self; // don't lock focus before nib is
|
|
|
|
// finished loading
|
|
|
|
|
|
|
|
// if (_flushDisabled)
|
|
|
|
// return self;
|
|
|
|
|
|
|
|
[cameraview_i lockFocus];
|
|
|
|
if (clearinstance) {
|
|
|
|
// XXX PSnewinstance ();
|
2003-03-18 19:48:24 +00:00
|
|
|
clearinstance = NO;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX PSsetinstance (1);
|
|
|
|
linestart (0, 0, 0);
|
|
|
|
[map_i makeSelectedPerform:@selector (CameraDrawSelf)];
|
2003-03-18 19:48:24 +00:00
|
|
|
[clipper_i cameraDrawSelf];
|
|
|
|
lineflush ();
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX PSsetinstance (0);
|
|
|
|
[cameraview_i unlockFocus];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
[xyview_i lockFocus];
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX PSsetinstance (1);
|
|
|
|
linestart (0, 0, 0);
|
|
|
|
[map_i makeSelectedPerform:@selector (XYDrawSelf)];
|
2003-03-18 19:48:24 +00:00
|
|
|
lineflush ();
|
|
|
|
[cameraview_i XYDrawSelf];
|
|
|
|
[zview_i XYDrawSelf];
|
|
|
|
[clipper_i XYDrawSelf];
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX PSsetinstance (0);
|
2003-03-18 19:48:24 +00:00
|
|
|
[xyview_i unlockFocus];
|
|
|
|
|
|
|
|
[zview_i lockFocus];
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX PSsetinstance (1);
|
|
|
|
[map_i makeSelectedPerform:@selector (ZDrawSelf)];
|
2003-03-18 19:48:24 +00:00
|
|
|
[cameraview_i ZDrawSelf];
|
|
|
|
[clipper_i ZDrawSelf];
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX PSsetinstance (0);
|
2003-03-18 19:48:24 +00:00
|
|
|
[zview_i unlockFocus];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
App delegate methods
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-applicationDefined:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 08:35:25 +00:00
|
|
|
NSEvent *evp;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
updateinflight = NO;
|
|
|
|
|
2010-09-12 05:31:59 +00:00
|
|
|
Sys_Printf ("serviced\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// update screen
|
2010-09-12 05:31:59 +00:00
|
|
|
evp = [NSApp nextEventMatchingMask: NSAnyEventMask
|
|
|
|
untilDate: [NSDate distantPast]
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
dequeue: NO];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (evp) {
|
|
|
|
postappdefined ();
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-12 13:40:50 +00:00
|
|
|
Sys_Printf ("updating %d %d %p %d %p %d\n",
|
|
|
|
(int)[map_i count],
|
|
|
|
(int)[[map_i currentEntity] count],
|
|
|
|
entitycount_i, [entitycount_i intValue],
|
|
|
|
brushcount_i, [brushcount_i intValue]);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[self disableFlushWindow];
|
|
|
|
|
2010-09-12 05:31:59 +00:00
|
|
|
if ([map_i count] != [entitycount_i intValue])
|
2010-09-11 10:03:41 +00:00
|
|
|
[entitycount_i setIntValue:[map_i count]];
|
2010-09-12 05:31:59 +00:00
|
|
|
if ([[map_i currentEntity] count] != [brushcount_i intValue])
|
2010-09-11 10:03:41 +00:00
|
|
|
[brushcount_i setIntValue:[[map_i currentEntity] count]];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (updatecamera)
|
|
|
|
[cameraview_i display];
|
|
|
|
if (updatexy)
|
|
|
|
[xyview_i display];
|
|
|
|
if (updatez)
|
|
|
|
[zview_i display];
|
|
|
|
|
|
|
|
updatecamera = updatexy = updatez = NO;
|
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
[self enableFlushWindow];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self flushWindow];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// NSPing ();
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-12 05:31:59 +00:00
|
|
|
-(void)awakeFromNib
|
|
|
|
{
|
|
|
|
// XXX [self addToEventMask:
|
|
|
|
// XXX NSRightMouseDragged|NSLeftMouseDragged];
|
|
|
|
|
|
|
|
// XXX malloc_error(My_Malloc_Error);
|
|
|
|
|
|
|
|
quakeed_i = self;
|
|
|
|
dirty = autodirty = NO;
|
|
|
|
|
|
|
|
[NSTimer timerWithTimeInterval: 5 * 60 target: self selector:@selector
|
|
|
|
(AutoSave)
|
|
|
|
userInfo: nil repeats:YES];
|
|
|
|
|
|
|
|
path =[NSBezierPath new];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)applicationDidFinishLaunching:(NSNotification *) notification
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 08:35:25 +00:00
|
|
|
NSArray *screens;
|
|
|
|
NSScreen *scrn;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
running = YES;
|
2010-09-11 10:03:41 +00:00
|
|
|
g_cmd_out_i = cmd_out_i; // for qprintf
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[preferences_i readDefaults];
|
|
|
|
[project_i initProject];
|
|
|
|
|
|
|
|
[xyview_i setModeRadio:xy_drawmode_i];
|
2010-09-12 05:31:59 +00:00
|
|
|
// because xy view is inside
|
2010-09-11 10:03:41 +00:00
|
|
|
// scrollview and can't be
|
|
|
|
// connected directly in IB
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
[self setFrameAutosaveName:@"EditorWinFrame"];
|
2010-09-11 10:03:41 +00:00
|
|
|
[self clear:self];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// go to my second monitor
|
2010-09-11 10:03:41 +00:00
|
|
|
screens =[NSScreen screens];
|
2010-09-11 08:35:25 +00:00
|
|
|
if ([screens count] == 2) {
|
2010-09-11 10:03:41 +00:00
|
|
|
scrn =[screens objectAtIndex:1];
|
|
|
|
// XXX [self moveTopLeftTo:0 : [scrn frame].size.height
|
|
|
|
// XXX screen:scrn];
|
2010-09-11 08:35:25 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[self makeKeyAndOrderFront:self];
|
|
|
|
|
|
|
|
//[self doOpen: "/raid/quake/id1_/maps/amlev1.map"]; // DEBUG
|
2003-03-18 19:48:24 +00:00
|
|
|
[map_i newMap];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("ready.\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
//malloc_debug(-1); // DEBUG
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-appWillTerminate:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
// FIXME: save dialog if dirty
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-textCommand:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
char const *t;
|
|
|
|
|
|
|
|
t =[[sender stringValue] cString];
|
|
|
|
|
|
|
|
if (!strcmp (t, "texname")) {
|
|
|
|
texturedef_t *td;
|
|
|
|
id b;
|
|
|
|
|
|
|
|
b =[map_i selectedBrush];
|
|
|
|
if (!b) {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("nothing selected\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
td =[b texturedef];
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("%s\n", td->texture);
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
2010-09-11 10:03:41 +00:00
|
|
|
} else
|
2010-09-11 23:43:55 +00:00
|
|
|
Sys_Printf ("Unknown command\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-openProject:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[project_i openProject];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-clear:sender
|
|
|
|
{
|
2003-03-18 19:48:24 +00:00
|
|
|
[map_i newMap];
|
|
|
|
|
|
|
|
[self updateAll];
|
2010-09-11 10:03:41 +00:00
|
|
|
[regionbutton_i setIntValue:0];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self setDefaultFilename];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-centerCamera:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect sbounds;
|
|
|
|
|
|
|
|
sbounds =[[xyview_i superview] bounds];
|
|
|
|
|
|
|
|
sbounds.origin.x += sbounds.size.width / 2;
|
|
|
|
sbounds.origin.y += sbounds.size.height / 2;
|
|
|
|
|
|
|
|
[cameraview_i setXYOrigin:&sbounds.origin];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self updateAll];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-centerZChecker:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect sbounds;
|
|
|
|
|
|
|
|
sbounds =[[xyview_i superview] bounds];
|
|
|
|
|
|
|
|
sbounds.origin.x += sbounds.size.width / 2;
|
|
|
|
sbounds.origin.y += sbounds.size.height / 2;
|
|
|
|
|
|
|
|
[zview_i setPoint:&sbounds.origin];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self updateAll];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-changeXYLookUp:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([sender intValue]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
xy_viewnormal[2] = 1;
|
2010-09-11 10:03:41 +00:00
|
|
|
} else {
|
2003-03-18 19:48:24 +00:00
|
|
|
xy_viewnormal[2] = -1;
|
|
|
|
}
|
|
|
|
[self updateAll];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
REGION MODIFICATION
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
applyRegion:
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-applyRegion:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
filter_clip_brushes =[filter_clip_i intValue];
|
|
|
|
filter_water_brushes =[filter_water_i intValue];
|
|
|
|
filter_light =[filter_light_i intValue];
|
|
|
|
filter_path =[filter_path_i intValue];
|
|
|
|
filter_entities =[filter_entities_i intValue];
|
|
|
|
filter_world =[filter_world_i intValue];
|
|
|
|
|
|
|
|
if (![regionbutton_i intValue]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
region_min[0] = region_min[1] = region_min[2] = -9999;
|
|
|
|
region_max[0] = region_max[1] = region_max[2] = 9999;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i makeGlobalPerform:@selector (newRegion)];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setBrushRegion:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id b;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// get the bounds of the current selection
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if ([map_i numSelected] != 1) {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("must have a single brush selected\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
2010-09-11 10:03:41 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
b =[map_i selectedBrush];
|
|
|
|
[b getMins: region_min maxs:region_max];
|
2003-03-18 19:48:24 +00:00
|
|
|
[b remove];
|
|
|
|
|
|
|
|
// turn region on
|
2010-09-11 10:03:41 +00:00
|
|
|
[regionbutton_i setIntValue:1];
|
|
|
|
[self applyRegion:self];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setXYRegion:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect bounds;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// get xy size
|
2010-09-11 10:03:41 +00:00
|
|
|
bounds =[[xyview_i superview] bounds];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
region_min[0] = bounds.origin.x;
|
|
|
|
region_min[1] = bounds.origin.y;
|
|
|
|
region_min[2] = -99999;
|
|
|
|
region_max[0] = bounds.origin.x + bounds.size.width;
|
|
|
|
region_max[1] = bounds.origin.y + bounds.size.height;
|
|
|
|
region_max[2] = 99999;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// turn region on
|
2010-09-11 10:03:41 +00:00
|
|
|
[regionbutton_i setIntValue:1];
|
|
|
|
[self applyRegion:self];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// UI querie for other objects
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) showCoordinates
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
return[show_coordinates_i intValue];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) showNames
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
return[show_names_i intValue];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
BSP PROCESSING
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
ExpandCommand (char *in, char *out, char *src, char *dest)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
while (*in) {
|
|
|
|
if (in[0] == '$') {
|
|
|
|
if (in[1] == '1') {
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (out, src);
|
2010-09-11 10:03:41 +00:00
|
|
|
out += strlen (src);
|
|
|
|
} else if (in[1] == '2') {
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (out, dest);
|
2010-09-11 10:03:41 +00:00
|
|
|
out += strlen (dest);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
in += 2;
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*out++ = *in++;
|
|
|
|
}
|
|
|
|
*out = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
saveBSP
|
|
|
|
=============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-saveBSP:(char *)
|
|
|
|
cmdline dialog:(BOOL) wt
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
char expandedcmd[1024];
|
|
|
|
char mappath[1024];
|
|
|
|
char bsppath[1024];
|
|
|
|
int oldLightFilter;
|
|
|
|
int oldPathFilter;
|
|
|
|
char *destdir;
|
|
|
|
|
|
|
|
if (bsppid) {
|
|
|
|
NSBeep ();
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// turn off the filters so all entities get saved
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
oldLightFilter =[filter_light_i intValue];
|
|
|
|
oldPathFilter =[filter_path_i intValue];
|
2003-03-18 19:48:24 +00:00
|
|
|
[filter_light_i setIntValue:0];
|
|
|
|
[filter_path_i setIntValue:0];
|
2010-09-11 10:03:41 +00:00
|
|
|
[self applyRegion:self];
|
|
|
|
|
|
|
|
if ([regionbutton_i intValue]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (mappath, filename);
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX StripExtension (mappath);
|
2003-03-18 19:48:24 +00:00
|
|
|
strcat (mappath, ".reg");
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i writeMapFile: mappath useRegion:YES];
|
|
|
|
wt = YES; // allways pop the dialog on region ops
|
|
|
|
} else
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (mappath, filename);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// save the entire thing, just in case there is a problem
|
2010-09-11 10:03:41 +00:00
|
|
|
[self save:self];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
[filter_light_i setIntValue:oldLightFilter];
|
|
|
|
[filter_path_i setIntValue:oldPathFilter];
|
2010-09-11 10:03:41 +00:00
|
|
|
[self applyRegion:self];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// write the command to the bsp host
|
2010-09-11 10:03:41 +00:00
|
|
|
//
|
|
|
|
destdir =[project_i getFinalMapDirectory];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
strcpy (bsppath, destdir);
|
|
|
|
strcat (bsppath, "/");
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX ExtractFileBase (mappath, bsppath + strlen(bsppath));
|
2003-03-18 19:48:24 +00:00
|
|
|
strcat (bsppath, ".bsp");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
ExpandCommand (cmdline, expandedcmd, mappath, bsppath);
|
|
|
|
|
|
|
|
strcat (expandedcmd, " > ");
|
|
|
|
strcat (expandedcmd, FN_CMDOUT);
|
|
|
|
strcat (expandedcmd, "\n");
|
|
|
|
printf ("system: %s", expandedcmd);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[project_i addToOutput:"\n\n========= BUSY =========\n\n"];
|
|
|
|
[project_i addToOutput:expandedcmd];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if ([preferences_i getShowBSP])
|
|
|
|
[inspcontrol_i changeInspectorTo:i_output];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (wt) {
|
|
|
|
id panel;
|
2010-09-19 08:05:34 +00:00
|
|
|
NSModalSession session;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
panel = NSGetAlertPanel (@"BSP In Progress",[NSString stringWithCString:expandedcmd], NULL, NULL, NULL);
|
2010-09-19 08:05:34 +00:00
|
|
|
session = [NSApp beginModalSessionForWindow: panel];
|
2010-09-11 10:03:41 +00:00
|
|
|
system (expandedcmd);
|
2010-09-19 08:05:34 +00:00
|
|
|
[NSApp endModalSession: session];
|
|
|
|
[panel close];
|
|
|
|
NSReleaseAlertPanel (panel);
|
2003-03-18 19:48:24 +00:00
|
|
|
DisplayCmdOutput ();
|
2010-09-11 10:03:41 +00:00
|
|
|
} else {
|
|
|
|
// cmdte = DPSAddTimedEntry(1, CheckCmdDone, self, NS_BASETHRESHOLD);
|
|
|
|
if (!(bsppid = fork ())) {
|
2003-03-18 19:48:24 +00:00
|
|
|
system (expandedcmd);
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-BSP_Full:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[self saveBSP: [project_i getFullVisCmd] dialog:NO];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-BSP_FastVis:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[self saveBSP: [project_i getFastVisCmd] dialog:NO];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-BSP_NoVis:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[self saveBSP: [project_i getNoVisCmd] dialog:NO];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-BSP_relight:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[self saveBSP: [project_i getRelightCmd] dialog:NO];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-BSP_entities:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[self saveBSP: [project_i getEntitiesCmd] dialog:NO];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-BSP_stop:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!bsppid) {
|
|
|
|
NSBeep ();
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
kill (bsppid, 9);
|
2010-09-11 10:03:41 +00:00
|
|
|
// CheckCmdDone (cmdte, 0, NULL);
|
|
|
|
[project_i addToOutput:"\n\n========= STOPPED =========\n\n"];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
doOpen:
|
|
|
|
|
|
|
|
Called by open or the project panel
|
|
|
|
==============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-doOpen:(char *) fname;
|
|
|
|
{
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (filename, fname);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[map_i readMapFile:filename];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[regionbutton_i setIntValue:0];
|
|
|
|
[self setTitleWithRepresentedFilename: [NSString stringWithCString:fname]];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self updateAll];
|
|
|
|
|
2010-09-11 23:43:55 +00:00
|
|
|
Sys_Printf ("%s loaded\n", fname);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
open
|
|
|
|
==============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-open:sender;
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id openpanel;
|
|
|
|
NSString *suffixlist[] = { @"map" };
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
openpanel =[NSOpenPanel new];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([openpanel runModalForDirectory: [NSString stringWithCString:[project_i
|
|
|
|
getMapDirectory]]
|
|
|
|
file: @"" types: [NSArray arrayWithObjects: suffixlist count:1]] !=
|
|
|
|
NSOKButton)
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[self doOpen:(char *)[[openpanel filename] cString]];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
save:
|
|
|
|
==============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-save:sender;
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
char backup[1024];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// force a name change if using tempname
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strcmp (filename, FN_TEMPSAVE))
|
|
|
|
return[self saveAs:self];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
dirty = autodirty = NO;
|
|
|
|
|
|
|
|
strcpy (backup, filename);
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX StripExtension (backup);
|
2003-03-18 19:48:24 +00:00
|
|
|
strcat (backup, ".bak");
|
2010-09-11 10:03:41 +00:00
|
|
|
rename (filename, backup); // copy old to .bak
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i writeMapFile: filename useRegion:NO];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
saveAs
|
|
|
|
==============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-saveAs:sender;
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id panel_i;
|
|
|
|
char dir[1024];
|
|
|
|
|
|
|
|
panel_i =[NSSavePanel new];
|
|
|
|
// XXX ExtractFileBase (filename, dir);
|
|
|
|
[panel_i setRequiredFileType:@"map"];
|
|
|
|
if ([panel_i runModalForDirectory: [NSString stringWithCString: [project_i getMapDirectory]] file: [NSString stringWithCString:dir]] !=
|
|
|
|
NSOKButton)
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
strcpy (filename,[[panel_i filename] cString]);
|
|
|
|
|
|
|
|
[self setTitleWithRepresentedFilename: [NSString stringWithCString:filename]];
|
|
|
|
|
|
|
|
[self save:self];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
OTHER METHODS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// AJR - added this for Project info
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
-(char *) currentFilename
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-deselect:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([clipper_i hide]) // first click hides only the clipper
|
|
|
|
return[self updateAll];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i setCurrentEntity: [map_i objectAtIndex:0]];
|
|
|
|
// make world selected
|
|
|
|
[map_i makeSelectedPerform:@selector (deselect)];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self updateAll];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
keyDown
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define KEY_RIGHTARROW 0xae
|
|
|
|
#define KEY_LEFTARROW 0xac
|
|
|
|
#define KEY_UPARROW 0xad
|
|
|
|
#define KEY_DOWNARROW 0xaf
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-keyDown:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int ch;
|
2010-09-12 05:31:59 +00:00
|
|
|
const char *chars;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// function keys
|
2010-09-11 10:03:41 +00:00
|
|
|
switch ([theEvent keyCode]) {
|
|
|
|
case 60: // F2
|
|
|
|
[cameraview_i setDrawMode:dr_wire];
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("wire draw mode\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
|
|
|
case 61: // F3
|
|
|
|
[cameraview_i setDrawMode:dr_flat];
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("flat draw mode\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
|
|
|
case 62: // F4
|
|
|
|
[cameraview_i setDrawMode:dr_texture];
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("texture draw mode\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
case 63: // F5
|
|
|
|
[xyview_i setDrawMode:dr_wire];
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("wire draw mode\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
|
|
|
case 64: // F6
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("texture draw mode\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
case 66: // F8
|
|
|
|
[cameraview_i homeView:self];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
case 88: // F12
|
|
|
|
[map_i subtractSelection:self];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
case 106: // page up
|
|
|
|
[cameraview_i upFloor:self];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
case 107: // page down
|
|
|
|
[cameraview_i downFloor:self];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
case 109: // end
|
|
|
|
[self deselect:self];
|
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// portable things
|
2010-09-12 05:31:59 +00:00
|
|
|
chars = [[theEvent characters] cString];
|
|
|
|
ch = chars ? tolower (chars[0]) : 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
switch (ch) {
|
|
|
|
case KEY_RIGHTARROW:
|
|
|
|
case KEY_LEFTARROW:
|
|
|
|
case KEY_UPARROW:
|
|
|
|
case KEY_DOWNARROW:
|
|
|
|
case 'a':
|
|
|
|
case 'z':
|
|
|
|
case 'd':
|
|
|
|
case 'c':
|
|
|
|
case '.':
|
|
|
|
case ',':
|
|
|
|
[cameraview_i _keyDown:theEvent];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 27: // escape
|
|
|
|
autodirty = dirty = YES;
|
|
|
|
[self deselect:self];
|
|
|
|
return self;
|
|
|
|
|
|
|
|
case 127: // delete
|
|
|
|
autodirty = dirty = YES;
|
|
|
|
[map_i makeSelectedPerform:@selector (remove)];
|
|
|
|
[clipper_i hide];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/':
|
|
|
|
[clipper_i flipNormal];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 13: // enter
|
|
|
|
[clipper_i carve];
|
|
|
|
[self updateAll];
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("carved brush\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
[map_i cloneSelection:self];
|
|
|
|
break;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// move selection keys
|
2010-09-11 10:03:41 +00:00
|
|
|
//
|
|
|
|
case '2':
|
|
|
|
VectorCopy (vec3_origin, sb_translate);
|
|
|
|
sb_translate[1] = -[xyview_i gridsize];
|
|
|
|
[map_i makeSelectedPerform:@selector (translate)];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
case '8':
|
|
|
|
VectorCopy (vec3_origin, sb_translate);
|
|
|
|
sb_translate[1] =[xyview_i gridsize];
|
|
|
|
[map_i makeSelectedPerform:@selector (translate)];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '4':
|
|
|
|
VectorCopy (vec3_origin, sb_translate);
|
|
|
|
sb_translate[0] = -[xyview_i gridsize];
|
|
|
|
[map_i makeSelectedPerform:@selector (translate)];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
case '6':
|
|
|
|
VectorCopy (vec3_origin, sb_translate);
|
|
|
|
sb_translate[0] =[xyview_i gridsize];
|
|
|
|
[map_i makeSelectedPerform:@selector (translate)];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '-':
|
|
|
|
VectorCopy (vec3_origin, sb_translate);
|
|
|
|
sb_translate[2] = -[xyview_i gridsize];
|
|
|
|
[map_i makeSelectedPerform:@selector (translate)];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
VectorCopy (vec3_origin, sb_translate);
|
|
|
|
sb_translate[2] =[xyview_i gridsize];
|
|
|
|
[map_i makeSelectedPerform:@selector (translate)];
|
|
|
|
[self updateAll];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("undefined keypress\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
NopSound ();
|
|
|
|
break;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|