/Volumes/Plantain/MyDocuments/Projects/MacTrek/MacTrek/Views/MapView.m

00001 //
00002 //  MapView.m
00003 //  MacTrek
00004 //
00005 //  Created by Aqua on 02/06/2006.
00006 //  Copyright 2006 __MyCompanyName__. All rights reserved.
00007 //
00008 
00009 #import "MapView.h"
00010 
00011 
00012 @implementation MapView
00013 
00014 NSRect gameBounds;
00015 
00016 - (void) awakeFromNib {
00017     [super awakeFromNib];
00018     
00019     // use larger steps to zoom
00020     step *= 2; // twice
00021     
00022     [self setScaleFullView];
00023     // should disable torps etc
00024     
00025     // find out what are the gameBounds
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     // use simpler drawing (eg omit weapons)
00034     [painter setSimplifyDrawing:YES];
00035 }
00036 
00037 - (NSPoint) gamePointRepresentingCentreOfView {
00038     return centerPoint;
00039 }
00040 
00041 // draw the view 
00042 // without locking the read thread !!
00043 - (void)drawRect:(NSRect)aRect {
00044     [painter drawRect:aRect ofViewBounds:[self bounds] whichRepresentsGameBounds:gameBounds withScale:scale];
00045 }
00046 
00047 - (void) mouseDown:(NSEvent *)theEvent {
00048     // where you click becomes the center
00049     centerPoint = [painter gamePointFromViewPoint:[self mousePos] 
00050                                              viewRect:[self bounds]
00051                                 gamePosInCentreOfView:[self gamePointRepresentingCentreOfView] 
00052                                             withScale:scale]; 
00053     
00054     // set up the gamebounds based on my position
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     // set up the gamebounds based on my position AND SCALE
00064     gameBounds = [painter gameRectAround:[self gamePointRepresentingCentreOfView]
00065                                  forView:[self bounds]
00066                                withScale:scale]; 
00067 }
00068 
00069 
00070 - (void) otherMouseDown:(NSEvent *)theEvent {
00071     // no phaser
00072 }
00073 
00074 @end

Generated on Fri Jul 28 19:15:24 2006 for MacTrek by  doxygen 1.4.7