2010-09-11 23:43:55 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
#include "XYView.h"
|
|
|
|
#include "ZView.h"
|
|
|
|
#include "CameraView.h"
|
|
|
|
#include "Clipper.h"
|
|
|
|
#include "QuakeEd.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "PopScrollView.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
id xyview_i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
id scrollview_i, gridbutton_i, scalebutton_i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t xy_viewnormal; // v_forward for xy view
|
|
|
|
float xy_viewdist; // clip behind this plane
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
@implementation XYView
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
initWithFrame:
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
- initWithFrame:(NSRect) frameRect
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[super initWithFrame:frameRect];
|
|
|
|
[self allocateGState];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
realbounds = NSMakeRect (0, 0, 0, 0);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
gridsize = 16;
|
|
|
|
scale = 1.0;
|
|
|
|
xyview_i = self;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
xy_viewnormal[2] = -1;
|
|
|
|
xy_viewdist = -1024;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
//
|
2003-03-18 19:48:24 +00:00
|
|
|
// initialize the pop up menus
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
scalebutton_i =[[NSPopUpButton alloc] init];
|
|
|
|
[scalebutton_i setTarget:self];
|
|
|
|
[scalebutton_i setAction: @selector (scaleMenuTarget:)];
|
|
|
|
[scalebutton_i addItemWithTitle:@"12.5%"];
|
|
|
|
[scalebutton_i addItemWithTitle:@"25%"];
|
|
|
|
[scalebutton_i addItemWithTitle:@"50%"];
|
|
|
|
[scalebutton_i addItemWithTitle:@"75%"];
|
|
|
|
[scalebutton_i addItemWithTitle:@"100%"];
|
|
|
|
[scalebutton_i addItemWithTitle:@"200%"];
|
|
|
|
[scalebutton_i addItemWithTitle:@"300%"];
|
|
|
|
[scalebutton_i selectItemAtIndex:4];
|
|
|
|
|
|
|
|
|
|
|
|
gridbutton_i =[[NSPopUpButton alloc] init];
|
|
|
|
[gridbutton_i setTarget:self];
|
|
|
|
[gridbutton_i setAction: @selector (gridMenuTarget:)];
|
|
|
|
|
|
|
|
[gridbutton_i addItemWithTitle:@"grid 1"];
|
|
|
|
[gridbutton_i addItemWithTitle:@"grid 2"];
|
|
|
|
[gridbutton_i addItemWithTitle:@"grid 4"];
|
|
|
|
[gridbutton_i addItemWithTitle:@"grid 8"];
|
|
|
|
[gridbutton_i addItemWithTitle:@"grid 16"];
|
|
|
|
[gridbutton_i addItemWithTitle:@"grid 32"];
|
|
|
|
[gridbutton_i addItemWithTitle:@"grid 64"];
|
|
|
|
|
|
|
|
[gridbutton_i selectItemAtIndex:4];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// initialize the scroll view
|
2010-09-11 10:03:41 +00:00
|
|
|
scrollview_i =[[PopScrollView alloc]
|
|
|
|
initWithFrame: frameRect button1: scalebutton_i button2:gridbutton_i];
|
|
|
|
[scrollview_i setLineScroll:64];
|
|
|
|
[scrollview_i setAutoresizingMask:(NSViewWidthSizable |
|
|
|
|
NSViewHeightSizable)];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// link objects together
|
2010-09-11 10:03:41 +00:00
|
|
|
[scrollview_i setDocumentView:self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return scrollview_i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) acceptsFirstResponder
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setModeRadio:m
|
|
|
|
{ // this should be set from IB, but
|
|
|
|
// because I toss myself in a
|
|
|
|
// popscrollview
|
2003-03-18 19:48:24 +00:00
|
|
|
// the connection gets lost
|
|
|
|
mode_radio_i = m;
|
2010-09-11 10:03:41 +00:00
|
|
|
[mode_radio_i setTarget:self];
|
|
|
|
[mode_radio_i setAction: @selector (drawMode:)];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawMode:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
drawmode =[sender selectedColumn];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateXY];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-setDrawMode:(drawmode_t) mode
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
drawmode = mode;
|
2010-09-11 10:03:41 +00:00
|
|
|
[mode_radio_i selectCellAtRow: 0 column:mode];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateXY];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(float) currentScale
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-09-09 11:46:38 +00:00
|
|
|
v
|
2003-03-18 19:48:24 +00:00
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-setOrigin:(NSPoint *)
|
|
|
|
pt scale:(float) sc
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect sframe;
|
|
|
|
NSRect newbounds;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// calculate the area visible in the cliprect
|
|
|
|
//
|
|
|
|
scale = sc;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
sframe =[[self superview] frame];
|
|
|
|
newbounds =[[self superview] frame];
|
2003-03-18 19:48:24 +00:00
|
|
|
newbounds.origin = *pt;
|
2010-09-11 10:03:41 +00:00
|
|
|
newbounds.size.width /= scale;
|
|
|
|
newbounds.size.height /= scale;
|
|
|
|
sframe.size.width /= scale;
|
|
|
|
sframe.size.height /= scale;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// union with the realbounds
|
|
|
|
//
|
2010-09-09 11:46:38 +00:00
|
|
|
newbounds = NSUnionRect (realbounds, newbounds);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// redisplay everything
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX[quakeed_i disableDisplay];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// size this view
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
[self setBoundsSize:newbounds.size];
|
|
|
|
[self setBoundsOrigin:newbounds.origin];
|
|
|
|
// XXX[self moveTo: newbounds.origin.x : newbounds.origin.y];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// scroll and scale the clip view
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
[[self superview] setBoundsSize:sframe.size];
|
|
|
|
[[self superview] setBoundsOrigin:*pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX[quakeed_i reenableDisplay];
|
2003-03-18 19:48:24 +00:00
|
|
|
[scrollview_i display];
|
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
|
|
|
-centerOn:(vec3_t) org
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect sbounds;
|
|
|
|
NSPoint mid, delta;
|
|
|
|
|
|
|
|
sbounds =[[xyview_i superview] bounds];
|
|
|
|
|
|
|
|
mid.x = sbounds.origin.x + sbounds.size.width / 2;
|
|
|
|
mid.y = sbounds.origin.y + sbounds.size.height / 2;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
delta.x = org[0] - mid.x;
|
|
|
|
delta.y = org[1] - mid.y;
|
|
|
|
|
|
|
|
sbounds.origin.x += delta.x;
|
|
|
|
sbounds.origin.y += delta.y;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[self setOrigin: &sbounds.origin scale:scale];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
newSuperBounds
|
|
|
|
|
|
|
|
When superview is resized
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-newSuperBounds
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect r;
|
|
|
|
|
|
|
|
r =[[self superview] bounds];
|
|
|
|
[self newRealBounds:&r];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
newRealBounds
|
|
|
|
|
|
|
|
Called when the realbounds rectangle is changed.
|
|
|
|
Should only change the scroll bars, not cause any redraws.
|
|
|
|
If realbounds has shrunk, nothing will change.
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-newRealBounds:(NSRect *) nb
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect sbounds;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
realbounds = *nb;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// calculate the area visible in the cliprect
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
sbounds =[[self superview] bounds];
|
2010-09-09 11:46:38 +00:00
|
|
|
sbounds = NSUnionRect (*nb, sbounds);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// size this view
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX[quakeed_i disableDisplay];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
[self setPostsBoundsChangedNotifications:NO];
|
2010-09-11 10:03:41 +00:00
|
|
|
[self setBoundsSize:sbounds.size];
|
|
|
|
[self setBoundsOrigin:sbounds.origin];
|
|
|
|
// XXX[self moveTo: sbounds.origin.x : sbounds.origin.y];
|
2010-09-09 11:46:38 +00:00
|
|
|
[self setPostsBoundsChangedNotifications:YES];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[scrollview_i reflectScrolledClipView:[scrollview_i contentView]];
|
|
|
|
// XXX[quakeed_i reenableDisplay];
|
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
[[scrollview_i horizontalScroller] display];
|
|
|
|
[[scrollview_i verticalScroller] display];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
scaleMenuTarget:
|
|
|
|
|
|
|
|
Called when the scaler popup on the window is used
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-scaleMenuTarget:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
char const *item;
|
|
|
|
NSRect visrect, sframe;
|
|
|
|
float nscale;
|
|
|
|
|
|
|
|
item =[[[sender selectedCell] title] cString];
|
|
|
|
sscanf (item, "%f", &nscale);
|
2003-03-18 19:48:24 +00:00
|
|
|
nscale /= 100;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (nscale == scale)
|
|
|
|
return NULL;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// keep the center of the view constant
|
2010-09-11 10:03:41 +00:00
|
|
|
visrect =[[self superview] bounds];
|
|
|
|
sframe =[[self superview] frame];
|
|
|
|
visrect.origin.x += visrect.size.width / 2;
|
|
|
|
visrect.origin.y += visrect.size.height / 2;
|
|
|
|
|
|
|
|
visrect.origin.x -= sframe.size.width / 2 / nscale;
|
|
|
|
visrect.origin.y -= sframe.size.height / 2 / nscale;
|
|
|
|
|
|
|
|
[self setOrigin: &visrect.origin scale:nscale];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
zoomIn
|
|
|
|
==============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-zoomIn:(NSPoint *) constant
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id itemlist, selectedItem;
|
|
|
|
int selected, numrows;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect visrect;
|
|
|
|
NSPoint ofs, new;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// set the popup
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
itemlist =[scalebutton_i itemArray];
|
|
|
|
numrows =[itemlist count];
|
2010-09-09 11:46:38 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
selectedItem =[scalebutton_i selectedItem];
|
|
|
|
selected =[itemlist indexOfObject:selectedItem] + 1;
|
2003-03-18 19:48:24 +00:00
|
|
|
if (selected >= numrows)
|
|
|
|
return NULL;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[scalebutton_i selectItemAtIndex:selected];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// zoom the view
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
visrect =[[self superview] bounds];
|
2003-03-18 19:48:24 +00:00
|
|
|
ofs.x = constant->x - visrect.origin.x;
|
|
|
|
ofs.y = constant->y - visrect.origin.y;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
new.x = constant->x - ofs.x / 2;
|
|
|
|
new.y = constant->y - ofs.y / 2;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[self setOrigin: &new scale:scale * 2];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
zoomOut
|
|
|
|
==============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-zoomOut:(NSPoint *) constant
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id itemlist, selectedItem;
|
|
|
|
int selected;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect visrect;
|
|
|
|
NSPoint ofs, new;
|
2010-09-09 11:46:38 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// set the popup
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
itemlist =[scalebutton_i itemArray];
|
2010-09-09 11:46:38 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
selectedItem =[scalebutton_i selectedItem];
|
|
|
|
selected =[itemlist indexOfObject:selectedItem] - 1;
|
2003-03-18 19:48:24 +00:00
|
|
|
if (selected < 0)
|
|
|
|
return NULL;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[scalebutton_i selectItemAtIndex:selected];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// zoom the view
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
visrect =[[self superview] bounds];
|
2003-03-18 19:48:24 +00:00
|
|
|
ofs.x = constant->x - visrect.origin.x;
|
|
|
|
ofs.y = constant->y - visrect.origin.y;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
new.x = constant->x - ofs.x * 2;
|
|
|
|
new.y = constant->y - ofs.y * 2;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[self setOrigin: &new scale:scale / 2];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
gridMenuTarget:
|
|
|
|
|
|
|
|
Called when the scaler popup on the window is used
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-gridMenuTarget:sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
char const *item;
|
|
|
|
int grid;
|
|
|
|
|
|
|
|
item =[[[sender selectedCell] title] cString];
|
|
|
|
sscanf (item, "grid %d", &grid);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (grid == gridsize)
|
|
|
|
return NULL;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
gridsize = grid;
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
snapToGrid
|
|
|
|
====================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-(float) snapToGrid:(float) f
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
i = rint (f / gridsize);
|
|
|
|
|
|
|
|
return i * gridsize;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(int) gridsize
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return gridsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
addToScrollRange::
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-addToScrollRange: (float) x:(float) y;
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
if (x < newrect.origin.x) {
|
2003-03-18 19:48:24 +00:00
|
|
|
newrect.size.width += newrect.origin.x - x;
|
|
|
|
newrect.origin.x = x;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (y < newrect.origin.y) {
|
2003-03-18 19:48:24 +00:00
|
|
|
newrect.size.height += newrect.origin.y - y;
|
|
|
|
newrect.origin.y = y;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (x > newrect.origin.x + newrect.size.width)
|
2010-09-11 10:03:41 +00:00
|
|
|
newrect.size.width += x - (newrect.origin.x + newrect.size.width);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (y > newrect.origin.y + newrect.size.height)
|
2010-09-11 10:03:41 +00:00
|
|
|
newrect.size.height += y - (newrect.origin.y + newrect.size.height);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
superviewChanged
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-superviewChanged
|
|
|
|
{
|
|
|
|
[self newRealBounds:&realbounds];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
DRAWING METHODS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t cur_linecolor;
|
2010-09-09 11:46:38 +00:00
|
|
|
NSBezierPath *path;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
linestart (float r, float g, float b)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-09 11:46:38 +00:00
|
|
|
[path removeAllPoints];
|
|
|
|
VectorSet (r, g, b, cur_linecolor);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
lineflush (void)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-09 11:46:38 +00:00
|
|
|
if ([path isEmpty])
|
2003-03-18 19:48:24 +00:00
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
// endUserPath (upath, dps_ustroke);
|
2003-03-18 19:48:24 +00:00
|
|
|
PSsetrgbcolor (cur_linecolor[0], cur_linecolor[1], cur_linecolor[2]);
|
2010-09-09 11:46:38 +00:00
|
|
|
[path stroke];
|
|
|
|
[path removeAllPoints];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
linecolor (float r, float g, float b)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (cur_linecolor[0] == r && cur_linecolor[1] == g && cur_linecolor[2] == b)
|
2010-09-11 10:03:41 +00:00
|
|
|
return; // do nothing
|
2003-03-18 19:48:24 +00:00
|
|
|
lineflush ();
|
2010-09-09 11:46:38 +00:00
|
|
|
VectorSet (r, g, b, cur_linecolor);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
XYmoveto (vec3_t pt)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint point = { pt[0], pt[1] };
|
2010-09-09 11:46:38 +00:00
|
|
|
if ([path elementCount] > 2048)
|
2003-03-18 19:48:24 +00:00
|
|
|
lineflush ();
|
2010-09-11 10:03:41 +00:00
|
|
|
[path moveToPoint:point];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
XYlineto (vec3_t pt)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint point = { pt[0], pt[1] };
|
|
|
|
[path lineToPoint:point];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
drawGrid
|
|
|
|
|
|
|
|
Draws tile markings every 64 units, and grid markings at the grid scale if
|
|
|
|
the grid lines are greater than or equal to 4 pixels apart
|
|
|
|
|
|
|
|
Rect is in global world (unscaled) coordinates
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawGrid:(NSRect) rect
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int x, y, stopx, stopy;
|
|
|
|
float top, bottom, right, left;
|
|
|
|
char text[10];
|
|
|
|
BOOL showcoords;
|
|
|
|
NSPoint point;
|
|
|
|
|
|
|
|
showcoords =[quakeed_i showCoordinates];
|
|
|
|
|
|
|
|
left = rect.origin.x - 1;
|
|
|
|
bottom = rect.origin.y - 1;
|
|
|
|
right = rect.origin.x + rect.size.width + 2;
|
|
|
|
top = rect.origin.y + rect.size.height + 2;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
PSsetlinewidth (0.15);
|
|
|
|
|
|
|
|
//
|
|
|
|
// grid
|
|
|
|
//
|
|
|
|
// can't just divide by grid size because of negetive coordinate
|
|
|
|
// truncating direction
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (gridsize >= 4 / scale) {
|
|
|
|
y = floor (bottom / gridsize);
|
|
|
|
stopy = floor (top / gridsize);
|
|
|
|
x = floor (left / gridsize);
|
|
|
|
stopx = floor (right / gridsize);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
y *= gridsize;
|
|
|
|
stopy *= gridsize;
|
|
|
|
x *= gridsize;
|
|
|
|
stopx *= gridsize;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (y < bottom)
|
|
|
|
y += gridsize;
|
|
|
|
if (x < left)
|
|
|
|
x += gridsize;
|
2003-03-18 19:48:24 +00:00
|
|
|
if (stopx >= right)
|
|
|
|
stopx -= gridsize;
|
|
|
|
if (stopy >= top)
|
|
|
|
stopy -= gridsize;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
[path removeAllPoints];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (; y <= stopy; y += gridsize)
|
|
|
|
if (y & 63) {
|
2010-09-09 11:46:38 +00:00
|
|
|
point.x = left;
|
|
|
|
point.y = y;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path moveToPoint:point];
|
2010-09-09 11:46:38 +00:00
|
|
|
point.x = right;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path lineToPoint:point];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (; x <= stopx; x += gridsize)
|
|
|
|
if (x & 63) {
|
2010-09-09 11:46:38 +00:00
|
|
|
point.x = x;
|
|
|
|
point.y = top;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path moveToPoint:point];
|
2010-09-09 11:46:38 +00:00
|
|
|
point.y = bottom;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path lineToPoint:point];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
// endUserPath (upath, dps_ustroke);
|
|
|
|
PSsetrgbcolor (0.8, 0.8, 1.0); // thin grid color
|
2010-09-09 11:46:38 +00:00
|
|
|
[path stroke];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// tiles
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
PSsetgray (0); // for text
|
|
|
|
|
|
|
|
if (scale > 4.0 / 64) {
|
|
|
|
y = floor (bottom / 64);
|
|
|
|
stopy = floor (top / 64);
|
|
|
|
x = floor (left / 64);
|
|
|
|
stopx = floor (right / 64);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
y *= 64;
|
|
|
|
stopy *= 64;
|
|
|
|
x *= 64;
|
|
|
|
stopx *= 64;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (y < bottom)
|
|
|
|
y += 64;
|
|
|
|
if (x < left)
|
|
|
|
x += 64;
|
2003-03-18 19:48:24 +00:00
|
|
|
if (stopx >= right)
|
|
|
|
stopx -= 64;
|
|
|
|
if (stopy >= top)
|
|
|
|
stopy -= 64;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
[path removeAllPoints];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (; y <= stopy; y += 64) {
|
|
|
|
if (showcoords) {
|
|
|
|
sprintf (text, "%i", y);
|
2010-09-09 11:46:38 +00:00
|
|
|
PSmoveto (left, y);
|
|
|
|
PSshow (text);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
[path moveToPoint:point];
|
2010-09-09 11:46:38 +00:00
|
|
|
point.x = right;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path lineToPoint:point];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (; x <= stopx; x += 64) {
|
|
|
|
if (showcoords) {
|
|
|
|
sprintf (text, "%i", x);
|
2010-09-09 11:46:38 +00:00
|
|
|
PSmoveto (x, bottom + 2);
|
|
|
|
PSshow (text);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-09 11:46:38 +00:00
|
|
|
point.x = x;
|
|
|
|
point.y = top;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path moveToPoint:point];
|
2010-09-09 11:46:38 +00:00
|
|
|
point.y = bottom;
|
2010-09-11 10:03:41 +00:00
|
|
|
[path lineToPoint:point];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// endUserPath (upath, dps_ustroke);
|
|
|
|
PSsetgray (12.0 / 16);
|
2010-09-09 11:46:38 +00:00
|
|
|
[path stroke];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
drawWire
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawWire:(NSRect) rects
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect visRect;
|
|
|
|
int i, j, c, c2;
|
|
|
|
id ent, brush;
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
BOOL drawnames;
|
|
|
|
|
|
|
|
drawnames =[quakeed_i showNames];
|
|
|
|
|
|
|
|
if ([quakeed_i showCoordinates]) // if coords are showing, update
|
|
|
|
// everything
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
visRect =[self visibleRect];
|
2010-09-09 11:46:38 +00:00
|
|
|
rects = visRect;
|
|
|
|
xy_draw_rect = rects;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
NSRectClip (rects);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// erase window
|
|
|
|
NSEraseRect (rects);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// draw grid
|
2010-09-11 10:03:41 +00:00
|
|
|
[self drawGrid:rects];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// draw all entities, world first so entities take priority
|
2010-09-11 10:03:41 +00:00
|
|
|
linestart (0, 0, 0);
|
|
|
|
|
|
|
|
c =[map_i count];
|
|
|
|
for (i = 0; i < c; i++) {
|
|
|
|
ent =[map_i objectAtIndex:i];
|
|
|
|
c2 =[ent count];
|
|
|
|
for (j = c2 - 1; j >= 0; j--) {
|
|
|
|
brush =[ent objectAtIndex:j];
|
|
|
|
if ([brush selected])
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
|
|
|
if ([brush regioned])
|
|
|
|
continue;
|
|
|
|
[brush XYDrawSelf];
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
if (i > 0 && drawnames) { // draw entity names
|
|
|
|
brush =[ent objectAtIndex:0];
|
|
|
|
if (![brush regioned]) {
|
|
|
|
[brush getMins: mins maxs:maxs];
|
|
|
|
PSmoveto (mins[0], mins[1]);
|
|
|
|
PSsetrgbcolor (0, 0, 0);
|
|
|
|
PSshow ([ent valueForQKey:"classname"]);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lineflush ();
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// resize if needed
|
|
|
|
newrect.origin.x -= gridsize;
|
|
|
|
newrect.origin.y -= gridsize;
|
2010-09-11 10:03:41 +00:00
|
|
|
newrect.size.width += 2 * gridsize;
|
|
|
|
newrect.size.height += 2 * gridsize;
|
2010-09-09 11:46:38 +00:00
|
|
|
if (!NSEqualRects (newrect, realbounds))
|
2010-09-11 10:03:41 +00:00
|
|
|
[self newRealBounds:&newrect];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
drawSolid
|
|
|
|
=============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-drawSolid
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
const unsigned char *planes[5];
|
|
|
|
NSRect visRect;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
visRect =[self visibleRect];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// draw the image into imagebuffer
|
|
|
|
//
|
|
|
|
r_origin[0] = visRect.origin.x;
|
|
|
|
r_origin[1] = visRect.origin.y;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
r_origin[2] = scale / 2; // using Z as a scale for the 2D
|
|
|
|
// projection
|
|
|
|
|
|
|
|
r_width = visRect.size.width * r_origin[2];
|
|
|
|
r_height = visRect.size.height * r_origin[2];
|
|
|
|
|
|
|
|
if (r_width != xywidth || r_height != xyheight) {
|
2003-03-18 19:48:24 +00:00
|
|
|
xywidth = r_width;
|
|
|
|
xyheight = r_height;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (xypicbuffer) {
|
2003-03-18 19:48:24 +00:00
|
|
|
free (xypicbuffer);
|
|
|
|
free (xyzbuffer);
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
xypicbuffer = malloc (r_width * (r_height + 1) * 4);
|
|
|
|
xyzbuffer = malloc (r_width * (r_height + 1) * 4);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
r_picbuffer = xypicbuffer;
|
|
|
|
r_zbuffer = xyzbuffer;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
REN_BeginXY ();
|
|
|
|
REN_ClearBuffers ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// render the entities
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i makeAllPerform:@selector (XYRenderSelf)];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// display the output
|
|
|
|
//
|
|
|
|
[self lockFocus];
|
2010-09-09 11:46:38 +00:00
|
|
|
[[self window] setBackingType:NSBackingStoreRetained];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
planes[0] = (unsigned char *) r_picbuffer;
|
|
|
|
NSDrawBitmap (visRect,
|
|
|
|
r_width,
|
|
|
|
r_height,
|
|
|
|
8,
|
|
|
|
3,
|
|
|
|
32, r_width * 4, NO, NO, NSCalibratedRGBColorSpace, planes);
|
|
|
|
|
|
|
|
// NSPing ();
|
2010-09-09 11:46:38 +00:00
|
|
|
[[self window] setBackingType:NSBackingStoreBuffered];
|
2003-03-18 19:48:24 +00:00
|
|
|
[self unlockFocus];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
drawSelf
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect xy_draw_rect;
|
|
|
|
|
2010-09-12 05:31:59 +00:00
|
|
|
-drawRect: (NSRect) rects
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
static float drawtime; // static to shut up compiler warning
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (timedrawing)
|
2010-09-11 23:43:55 +00:00
|
|
|
drawtime = Sys_DoubleTime ();
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
xy_draw_rect = rects;
|
2003-03-18 19:48:24 +00:00
|
|
|
newrect.origin.x = newrect.origin.y = 99999;
|
2010-09-11 10:03:41 +00:00
|
|
|
newrect.size.width = newrect.size.height = -2 * 99999;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// setup for text
|
2010-09-11 10:03:41 +00:00
|
|
|
// PSselectfont("Helvetica-Medium",10/scale);
|
2010-09-14 13:17:35 +00:00
|
|
|
[[NSFont systemFontOfSize: 10 / scale] set];
|
2010-09-11 10:03:41 +00:00
|
|
|
PSrotate (0);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (drawmode == dr_texture || drawmode == dr_flat)
|
|
|
|
[self drawSolid];
|
|
|
|
else
|
2010-09-11 10:03:41 +00:00
|
|
|
[self drawWire:rects];
|
|
|
|
|
|
|
|
if (timedrawing) {
|
|
|
|
// NSPing ();
|
2010-09-11 23:43:55 +00:00
|
|
|
drawtime = Sys_DoubleTime () - drawtime;
|
2003-03-18 19:48:24 +00:00
|
|
|
printf ("CameraView drawtime: %5.3f\n", drawtime);
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
USER INTERACTION
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
dragLoop:
|
|
|
|
================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
static NSPoint oldreletive;
|
|
|
|
|
|
|
|
-dragFrom: (NSEvent *) startevent useGrid: (BOOL) ug callback:(void (*)(float dx, float dy)) callback
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSEvent *event;
|
|
|
|
NSPoint startpt, newpt;
|
|
|
|
NSPoint reletive, delta;
|
|
|
|
|
|
|
|
startpt =[startevent locationInWindow];
|
|
|
|
startpt =[self convertPoint: startpt fromView:NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
oldreletive.x = oldreletive.y = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (ug) {
|
|
|
|
startpt.x =[self snapToGrid:startpt.x];
|
|
|
|
startpt.y =[self snapToGrid:startpt.y];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
while (1) {
|
2010-09-09 11:46:38 +00:00
|
|
|
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
2010-09-11 10:03:41 +00:00
|
|
|
| NSRightMouseUpMask | NSRightMouseDraggedMask
|
|
|
|
| NSApplicationDefinedMask;
|
|
|
|
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate
|
|
|
|
distantFuture]
|
|
|
|
inMode: NSEventTrackingRunLoopMode dequeue:YES];
|
2010-09-09 11:46:38 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([event type] == NSLeftMouseUp ||[event type] == NSRightMouseUp)
|
2003-03-18 19:48:24 +00:00
|
|
|
break;
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([event type] == NSApplicationDefined) { // doesn't work. grrr.
|
|
|
|
// [quakeed_i applicationDefined:event];
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
newpt =[event locationInWindow];
|
|
|
|
newpt =[self convertPoint: newpt fromView:NULL];
|
|
|
|
|
|
|
|
if (ug) {
|
|
|
|
newpt.x =[self snapToGrid:newpt.x];
|
|
|
|
newpt.y =[self snapToGrid:newpt.y];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
reletive.x = newpt.x - startpt.x;
|
|
|
|
reletive.y = newpt.y - startpt.y;
|
|
|
|
if (reletive.x == oldreletive.x && reletive.y == oldreletive.y)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
delta.x = reletive.x - oldreletive.x;
|
|
|
|
delta.y = reletive.y - oldreletive.y;
|
2010-09-11 10:03:41 +00:00
|
|
|
oldreletive = reletive;
|
|
|
|
|
|
|
|
callback (delta.x, delta.y);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
DragCallback (float dx, float dy)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
sb_translate[0] = dx;
|
|
|
|
sb_translate[1] = dy;
|
|
|
|
sb_translate[2] = 0;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i makeSelectedPerform:@selector (translate)];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i redrawInstance];
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-selectionDragFrom:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("dragging selection\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
[self dragFrom: theEvent useGrid: YES callback:DragCallback];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateAll];
|
|
|
|
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
|
|
|
void
|
|
|
|
ScrollCallback (float dx, float dy)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect basebounds;
|
|
|
|
NSPoint neworg;
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
basebounds =[[xyview_i superview] bounds];
|
|
|
|
[xyview_i convertRect: basebounds fromView:[xyview_i superview]];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
neworg.x = basebounds.origin.x - dx;
|
|
|
|
neworg.y = basebounds.origin.y - dy;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
scale =[xyview_i currentScale];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
oldreletive.x -= dx;
|
|
|
|
oldreletive.y -= dy;
|
2010-09-11 10:03:41 +00:00
|
|
|
[xyview_i setOrigin: &neworg scale:scale];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-scrollDragFrom:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("scrolling view\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
[self dragFrom: theEvent useGrid: YES callback:ScrollCallback];
|
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
|
|
|
vec3_t direction;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
DirectionCallback (float dx, float dy)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t org;
|
|
|
|
float ya;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
direction[0] += dx;
|
|
|
|
direction[1] += dy;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[cameraview_i getOrigin:org];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (direction[0] == org[0] && direction[1] == org[1])
|
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
ya = atan2 (direction[1] - org[1], direction[0] - org[0]);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[cameraview_i setOrigin: org angle:ya];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i newinstance];
|
|
|
|
[cameraview_i display];
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-directionDragFrom:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint pt;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("changing camera direction\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
direction[0] = pt.x;
|
|
|
|
direction[1] = pt.y;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
DirectionCallback (0, 0);
|
|
|
|
|
|
|
|
[self dragFrom: theEvent useGrid: NO callback:DirectionCallback];
|
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
id newbrush;
|
|
|
|
vec3_t neworg, newdrag;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
NewCallback (float dx, float dy)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t min, max;
|
|
|
|
int i;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
newdrag[0] += dx;
|
|
|
|
newdrag[1] += dy;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (neworg[i] < newdrag[i]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
min[i] = neworg[i];
|
|
|
|
max[i] = newdrag[i];
|
2010-09-11 10:03:41 +00:00
|
|
|
} else {
|
2003-03-18 19:48:24 +00:00
|
|
|
min[i] = newdrag[i];
|
|
|
|
max[i] = neworg[i];
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[newbrush setMins: min maxs:max];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i redrawInstance];
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-newBrushDragFrom:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id owner;
|
|
|
|
texturedef_t td;
|
|
|
|
NSPoint pt;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("sizing new brush\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
|
|
|
|
|
|
|
neworg[0] =[self snapToGrid:pt.x];
|
|
|
|
neworg[1] =[self snapToGrid:pt.y];
|
|
|
|
neworg[2] =[map_i currentMinZ];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
newdrag[0] = neworg[0];
|
|
|
|
newdrag[1] = neworg[1];
|
2010-09-11 10:03:41 +00:00
|
|
|
newdrag[2] =[map_i currentMaxZ];
|
|
|
|
|
|
|
|
owner =[map_i currentEntity];
|
|
|
|
|
|
|
|
[texturepalette_i getTextureDef:&td];
|
|
|
|
|
|
|
|
newbrush =[[SetBrush alloc] initOwner: owner mins: neworg maxs: newdrag texture:&td];
|
|
|
|
[owner addObject:newbrush];
|
|
|
|
|
|
|
|
[newbrush setSelected:YES];
|
|
|
|
|
|
|
|
[self dragFrom: theEvent useGrid: YES callback:NewCallback];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[newbrush removeIfInvalid];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateCamera];
|
|
|
|
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
|
|
|
void
|
|
|
|
ControlCallback (float dx, float dy)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < numcontrolpoints; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
controlpoints[i][0] += dx;
|
|
|
|
controlpoints[i][1] += dy;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[[map_i selectedBrush] calcWindings];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i redrawInstance];
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) planeDragFrom:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint pt;
|
|
|
|
vec3_t dragpoint;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if ([map_i numSelected] != 1)
|
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
dragpoint[0] = pt.x;
|
|
|
|
dragpoint[1] = pt.y;
|
|
|
|
dragpoint[2] = 2048;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
[[map_i selectedBrush] getXYdragface:dragpoint];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!numcontrolpoints)
|
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("dragging brush plane\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
|
|
|
|
|
|
|
[self dragFrom: theEvent useGrid: YES callback:ControlCallback];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[[map_i selectedBrush] removeIfInvalid];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
-(BOOL) shearDragFrom:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint pt;
|
|
|
|
vec3_t dragpoint;
|
|
|
|
vec3_t p1, p2;
|
|
|
|
float time;
|
|
|
|
id br;
|
|
|
|
int face;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if ([map_i numSelected] != 1)
|
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
br =[map_i selectedBrush];
|
|
|
|
|
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// if the XY point is inside the brush, make the point on top
|
|
|
|
p1[0] = pt.x;
|
|
|
|
p1[1] = pt.y;
|
|
|
|
VectorCopy (p1, p2);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
p1[2] = -2048 * xy_viewnormal[2];
|
|
|
|
p2[2] = 2048 * xy_viewnormal[2];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
VectorCopy (p1, dragpoint);
|
2010-09-11 10:03:41 +00:00
|
|
|
[br hitByRay: p1: p2: &time:&face];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (time > 0) {
|
|
|
|
dragpoint[2] = p1[2] + (time - 0.01) * xy_viewnormal[2];
|
|
|
|
} else {
|
|
|
|
[br getMins: p1 maxs:p2];
|
|
|
|
dragpoint[2] = (p1[2] + p2[2]) / 2;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[br getXYShearPoints:dragpoint];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!numcontrolpoints)
|
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("dragging brush plane\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
|
|
|
|
|
|
|
[self dragFrom: theEvent useGrid: YES callback:ControlCallback];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[br removeIfInvalid];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateAll];
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
INPUT METHODS
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
mouseDown
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-mouseDown:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint pt;
|
|
|
|
id ent;
|
|
|
|
vec3_t p1, p2;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
p1[0] = p2[0] = pt.x;
|
|
|
|
p1[1] = p2[1] = pt.y;
|
|
|
|
p1[2] = xy_viewnormal[2] * -4096;
|
|
|
|
p2[2] = xy_viewnormal[2] * 4096;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
flags =
|
|
|
|
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
|
|
|
NSAlternateKeyMask | NSCommandKeyMask);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// shift click to select / deselect a brush from the world
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == NSShiftKeyMask) {
|
|
|
|
[map_i selectRay: p1: p2:YES];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// cmd-shift click to set a target/targetname entity connection
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == (NSShiftKeyMask | NSCommandKeyMask)) {
|
|
|
|
[map_i entityConnect: p1:p2];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// bare click to either drag selection, or rubber band a new brush
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == 0) {
|
|
|
|
// if double click, position Z checker
|
|
|
|
if ([theEvent clickCount] > 1) {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("positioned Z checker\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
[zview_i setPoint:&pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i newinstance];
|
|
|
|
[quakeed_i updateZ];
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
// check eye
|
|
|
|
if ([cameraview_i XYmouseDown: &pt flags:[theEvent
|
|
|
|
modifierFlags]])
|
|
|
|
return self; // camera move
|
|
|
|
|
|
|
|
// check z post
|
|
|
|
if ([zview_i XYmouseDown:&pt])
|
|
|
|
return self; // z view move
|
|
|
|
|
|
|
|
// check clippers
|
|
|
|
if ([clipper_i XYDrag:&pt])
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// check single plane dragging
|
|
|
|
if ([self planeDragFrom:theEvent])
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// check selection
|
|
|
|
ent =[map_i grabRay: p1:p2];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (ent)
|
2010-09-11 10:03:41 +00:00
|
|
|
return[self selectionDragFrom:theEvent];
|
|
|
|
|
|
|
|
if ([map_i numSelected]) {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("missed\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
return[self newBrushDragFrom:theEvent];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// control click = position and drag camera
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == NSControlKeyMask) {
|
|
|
|
[cameraview_i setXYOrigin:&pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i newinstance];
|
|
|
|
[cameraview_i display];
|
2010-09-11 10:03:41 +00:00
|
|
|
[cameraview_i XYmouseDown: &pt flags:[theEvent modifierFlags]];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// command click = drag Z checker
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == NSCommandKeyMask) {
|
2003-03-18 19:48:24 +00:00
|
|
|
// check single plane dragging
|
2010-09-11 10:03:41 +00:00
|
|
|
[self shearDragFrom:theEvent];
|
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("moving Z checker\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
[zview_i setXYOrigin:&pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateAll];
|
2010-09-11 10:03:41 +00:00
|
|
|
[zview_i XYmouseDown:&pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// alt click = set entire brush texture
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == NSAlternateKeyMask) {
|
|
|
|
if (drawmode != dr_texture) {
|
2010-09-11 23:43:55 +00:00
|
|
|
Sys_Printf ("No texture setting except in texture mode!\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i setTextureRay: p1: p2:YES];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateAll];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// ctrl-alt click = set single face texture
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == (NSControlKeyMask | NSAlternateKeyMask)) {
|
|
|
|
if (drawmode != dr_texture) {
|
2010-09-11 23:43:55 +00:00
|
|
|
Sys_Printf ("No texture setting except in texture mode!\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
[map_i setTextureRay: p1: p2:NO];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateAll];
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("bad flags for click %x\n", flags);
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
rightMouseDown
|
|
|
|
===================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
-rightMouseDown:(NSEvent *) theEvent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
NSPoint pt;
|
|
|
|
int flags;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
pt =[theEvent locationInWindow];
|
|
|
|
pt =[self convertPoint: pt fromView:NULL];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
flags =
|
|
|
|
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
|
|
|
|
NSAlternateKeyMask | NSCommandKeyMask);
|
|
|
|
|
|
|
|
if (flags == NSCommandKeyMask) {
|
|
|
|
return[self scrollDragFrom:theEvent];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (flags == NSAlternateKeyMask) {
|
|
|
|
return[clipper_i XYClick:pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (flags == 0 || flags == NSControlKeyMask) {
|
|
|
|
return[self directionDragFrom:theEvent];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("bad flags for click\n");
|
2003-03-18 19:48:24 +00:00
|
|
|
NopSound ();
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|