/[hegemonie]/hegemonie/Map/MapLoader.m
ViewVC logotype

Diff of /hegemonie/Map/MapLoader.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by gabby, Thu Jul 24 13:29:00 2003 UTC revision 1.2 by dam, Tue Jul 29 12:49:51 2003 UTC
# Line 22  Line 22 
22   */   */
23    
24  #include <Foundation/NSDictionary.h>  #include <Foundation/NSDictionary.h>
25    #include <Foundation/NSString.h>
26    #include <Foundation/NSException.h>
27    
28    #include "Map/MapDisplay.h"
29  #include "Map/MapLoader.h"  #include "Map/MapLoader.h"
30    
31  /**  /**
# Line 42  Line 45 
45    
46  @implementation MapLoader  @implementation MapLoader
47    
48  + (void) loadMap: (NSString *)mapName  + (MapDisplay *) loadMap: (NSString *)mapName
               to: (MapDisplay *)terrain  
49  {  {
50    NSParameterAssert (mapName);    NSParameterAssert (mapName);
51    NSParameterAssert ([mapName length] != 0);    NSParameterAssert ([mapName length] != 0);
   NSAssert (terrain, @"terrain no instanciate\n");  
52    
53    NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile: mapName];    NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile: mapName];
54    
55    int seaLevel = [[dic objectForKey: @"seaLevel"] intValue];    /* FIXME - sould store the objects of the map */
   
   // FIXME sould store the objects of the map  
56    
57   [terrain initWithMapImageName: [dic objectForKey: @"terrain"]    NSString *path = [mapName stringByDeletingLastPathComponent];
58                 colorsImageName: [dic objectForKey: @"colors"]    NSString *terrainName
59                shadowsImageName: [dic objectForKey: @"shadows"]      = [path stringByAppendingPathComponent: [dic objectForKey: @"terrain"]];
60               texturesImageName: [dic objectForKey: @"textures"]];    NSString *colorsName
61        = [path stringByAppendingPathComponent: [dic objectForKey: @"colors"]];
62      NSString *shadowsName
63        = [path stringByAppendingPathComponent: [dic objectForKey: @"shadows"]];
64      NSString *texturesName
65        = [path stringByAppendingPathComponent: [dic objectForKey: @"textures"]];
66    
67      MapDisplay *map = [MapDisplay alloc];  
68      [map initWithMapImageName: terrainName
69                colorsImageName: colorsName
70               shadowsImageName: shadowsName
71              texturesImageName: texturesName];
72    
73   [terrain setSeaLevel: (u_int8_t)seaLevel];    [map setSeaLevel: [[dic objectForKey: @"seaLevel"] intValue]];
74    
75      return map;
76  }  }
77    
78  @end  @end

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26