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 [painter setSimplifyDrawing:YES];
00035 }
00036
00037 - (NSPoint) gamePointRepresentingCentreOfView {
00038 return centerPoint;
00039 }
00040
00041
00042
00043 - (void)drawRect:(NSRect)aRect {
00044 [painter drawRect:aRect ofViewBounds:[self bounds] whichRepresentsGameBounds:gameBounds withScale:scale];
00045 }
00046
00047 - (void) mouseDown:(NSEvent *)theEvent {
00048
00049 centerPoint = [painter gamePointFromViewPoint:[self mousePos]
00050 viewRect:[self bounds]
00051 gamePosInCentreOfView:[self gamePointRepresentingCentreOfView]
00052 withScale:scale];
00053
00054
00055 gameBounds = [painter gameRectAround:[self gamePointRepresentingCentreOfView]
00056 forView:[self bounds]
00057 withScale:scale];
00058 }
00059
00060 - (void) scrollWheel:(NSEvent *)theEvent {
00061
00062 [super scrollWheel:theEvent];
00063
00064 gameBounds = [painter gameRectAround:[self gamePointRepresentingCentreOfView]
00065 forView:[self bounds]
00066 withScale:scale];
00067 }
00068
00069
00070 - (void) otherMouseDown:(NSEvent *)theEvent {
00071
00072 }
00073
00074 @end