home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Games / Empire-0.6-MIS / MapPathView.m < prev    next >
Encoding:
Text File  |  1997-10-30  |  2.2 KB  |  93 lines

  1. //
  2. // $Id: MapPathView.m,v 1.7 1997/10/31 04:51:51 nygard Exp $
  3. //
  4.  
  5. //
  6. //  This file is a part of Empire, a game of exploration and conquest.
  7. //  Copyright (C) 1996  Steve Nygard
  8. //
  9. //  This program is free software; you can redistribute it and/or modify
  10. //  it under the terms of the GNU General Public License as published by
  11. //  the Free Software Foundation; either version 2 of the License, or
  12. //  (at your option) any later version.
  13. //
  14. //  This program is distributed in the hope that it will be useful,
  15. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. //  GNU General Public License for more details.
  18. //
  19. //  You should have received a copy of the GNU General Public License
  20. //  along with this program; if not, write to the Free Software
  21. //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. //
  23. //  You may contact the author by:
  24. //     e-mail:  nygard@telusplanet.net
  25. //
  26.  
  27. #import "Empire.h"
  28.  
  29. RCSID ("$Id: MapPathView.m,v 1.7 1997/10/31 04:51:51 nygard Exp $");
  30.  
  31. #import "MapPathView.h"
  32. #import "PathSegment.h"
  33.  
  34. //======================================================================
  35. // This adds the ability to show a set of paths on top of the map.
  36. //======================================================================
  37.  
  38. @implementation MapPathView
  39.  
  40. - initWithFrame:(NSRect)frameRect
  41. {
  42.     [super initWithFrame:frameRect];
  43.  
  44.     pathList = nil;
  45.  
  46.     return self;
  47. }
  48.  
  49. //----------------------------------------------------------------------
  50.  
  51. - (void) dealloc
  52. {
  53.     SNRelease (pathList);
  54.  
  55.     [super dealloc];
  56. }
  57.  
  58. //----------------------------------------------------------------------
  59.  
  60. - (void) drawRect:(NSRect)rect
  61. {
  62.     [super drawRect:rect];
  63.  
  64.     if (pathList != nil)
  65.     {
  66.         NSEnumerator *enumerator = [pathList objectEnumerator];
  67.         id object;
  68.  
  69.         PSsetgray (NSWhite);
  70.         PSsetlinewidth (0);
  71.         
  72.         while (object = [enumerator nextObject])
  73.         {
  74.             [object drawPath];
  75.         }
  76.  
  77.         PSstroke ();
  78.     }
  79. }
  80.  
  81. //----------------------------------------------------------------------
  82.  
  83. - (void) usePathList:(NSArray *)newPathList
  84. {
  85.     SNRelease (pathList);
  86.  
  87.     pathList = [newPathList retain];
  88.  
  89.     [self setNeedsDisplay:YES];
  90. }
  91.  
  92. @end
  93.