00001
00002
00003
00004
00005
00006
00007
00008
00009 #import "MapView.h"
00010
00011
00012 @implementation MapView
00013
00014 NSRect gameBounds;
00015
00016 - (void) awakeFromNib {
00017 [super awakeFromNib];
00018
00019
00020 step *= 2;
00021
00022 [self setScaleFullView];
00023
00024
00025
00026 gameBounds.origin.x = 0;
00027 gameBounds.origin.y = 0;
00028 gameBounds.size.width = UNIVERSE_PIXEL_SIZE;
00029 gameBounds.size.height = UNIVERSE_PIXEL_SIZE;
00030
00031 centerPoint = NSMakePoint(UNIVERSE_PIXEL_SIZE/2, UNIVERSE_PIXEL_SIZE/2);
00032
00033
00034
00035 painter = [[PainterFactory alloc] init];
00036
00037
00038 [painter setSimplifyDrawing:YES];
00039 }
00040
00041 - (NSPoint) gamePointRepresentingCentreOfView {
00042 return centerPoint;
00043 }
00044
00045 - (void) keyDown:(NSEvent *)theEvent {
00046 NSLog(@"MapView.keyDown entered");
00047 [super keyDown:theEvent];
00048 }
00049
00050
00051
00052 - (void)drawRect:(NSRect)aRect {
00053 [painter drawRect:aRect ofViewBounds:[self bounds] whichRepresentsGameBounds:gameBounds withScale:scale];
00054 }
00055
00056 - (void) mouseDown:(NSEvent *)theEvent {
00057
00058 centerPoint = [painter gamePointFromViewPoint:[self mousePos]
00059 viewRect:[self bounds]
00060 gamePosInCentreOfView:[self gamePointRepresentingCentreOfView]
00061 withScale:scale];
00062
00063
00064 gameBounds = [painter gameRectAround:[self gamePointRepresentingCentreOfView]
00065 forView:[self bounds]
00066 withScale:scale];
00067 }
00068
00069 - (void) scrollWheel:(NSEvent *)theEvent {
00070
00071 [super scrollWheel:theEvent];
00072
00073 gameBounds = [painter gameRectAround:[self gamePointRepresentingCentreOfView]
00074 forView:[self bounds]
00075 withScale:scale];
00076 }
00077
00078
00079 - (void) otherMouseDown:(NSEvent *)theEvent {
00080
00081 }
00082
00083 @end