/[hegemonie]/hegemonie/MapEditor/MapController.m
ViewVC logotype

Diff of /hegemonie/MapEditor/MapController.m

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

revision 1.4 by gabby, Thu Jul 24 13:53:14 2003 UTC revision 1.5 by gabby, Fri Jul 25 16:12:23 2003 UTC
# Line 67  Line 67 
67  }  }
68    
69  /**  /**
70   * Create the Map Open panel.   * Create the Map Open panel and instanciate the MapModel.
71   */   */
72  - (void) openMap: (id)sender  - (void) openMap: (id)sender
73  {  {
74    [NSBundle loadNibNamed: @"MapOpenPanel.gorm" owner: self];    NSOpenPanel* panel = [NSOpenPanel openPanel];
75    [_panelOpenMap makeFirstResponder: _fieldOpenMap];    [panel setAllowsMultipleSelection: NO];
76    [NSApp runModalForWindow: _panelOpenMap];    [panel setDirectory: [[NSFileManager defaultManager] currentDirectoryPath]];
 }  
77    
78  /**    int ret = [panel runModalForTypes: [NSArray arrayWithObject: @"map"]];
79   * Instanciate the map model with the _fieldOpenMap.    if (ret == NSOKButton)
  */  
 - (void) openMapOkButton: (id)sender  
 {  
   if ([_fieldOpenMap stringValue] != @"")  
80      {      {
81        _display = NO;         if ([[panel filenames]objectAtIndex: 0] != @"")
       [_mapView displayTerrain: _display];  
       //NSLog (@"_windows %@\n", _window);  
       //[_window makeFirstResponder: self];  
   
       if (!_mapModel)  
         _mapModel = [[MapModel alloc] init];  
   
       [_mapModel openMap: [_fieldOpenMap stringValue]];  
         
       [NSApp stopModal];  
       [_panelOpenMap close];  
   
       if ([_mapModel getTerrain] == nil)  
82          {          {
83            NSRunAlertPanel(@"Warning!",            _display = NO;
84                            @"Incorrect name of map !!",            [_mapView displayTerrain: _display];
85                            @"OK", nil, nil);            
86              if (!_mapModel)
87              _mapModel = [[MapModel alloc] init];
88              
89              [_mapModel openMap: [[panel filenames]objectAtIndex: 0]];
90              
91              if ([_mapModel getTerrain] == nil)
92                {
93                  NSRunAlertPanel(@"Warning!",
94                                  @"Incorrect name of map !!",
95                                  @"OK", nil, nil);
96              }
97              else
98                [self _initView];
99          }          }
100        else        
         [self _initView];  
101      }      }
102  }  }
103    
104  /**  /**
105   * Close the map open panel.   * Create the color panel.
106   */   */
107  - (void) openMapCancelButton: (id)sender  - (void) setColors: (id)sender
108  {  {
109    [NSApp abortModal];    NSOpenPanel* panel = [NSOpenPanel openPanel];
110    [_panelOpenMap close];    [panel setAllowsMultipleSelection: NO];
111      [panel setDirectory: [[NSFileManager defaultManager] currentDirectoryPath]];
112    
113      int ret = [panel runModalForTypes: [NSArray arrayWithObject: @"tiff"]];
114      if (ret == NSOKButton)
115        {
116          if ((_mapModel != nil) & ([[panel filenames]objectAtIndex: 0] != @""))
117            {
118              [_mapView displayTerrain: NO];
119          
120              if (![_mapModel setColorsImageName: [[panel filenames]objectAtIndex: 0]])
121                {
122                  NSRunAlertPanel(@"Warning!",
123                                  @"Incorrect color name file !!",
124                                  @"OK", nil, nil);
125                }
126              
127              if (_enableTexture)
128                {
129                  [_mapModel setTexturesImageName: @""];
130                  _enableTexture = NO;
131                }
132    
133              [_mapView displayTerrain: YES];
134            }
135        }
136  }  }
137    
138  /**  /**
# Line 129  Line 148 
148  /**  /**
149   * Instanciate the map model with a randomize terrain.   * Instanciate the map model with a randomize terrain.
150   */   */
151  - (void) randomMapOkButton: (id)sender;  - (void) randomMapOkButton: (id)sender
152  {  {
153    if (([_xFieldRandomMap stringValue] != @"")    if (([_xFieldRandomMap stringValue] != @"")
154        & ([_zFieldRandomMap stringValue] != @""))        & ([_zFieldRandomMap stringValue] != @""))
# Line 142  Line 161 
161        if (!_mapModel)        if (!_mapModel)
162          _mapModel = [[MapModel alloc] init];          _mapModel = [[MapModel alloc] init];
163    
       //[_mapModel openMapWithXLength: 255  
       //                withZLength: 255];  
164        [_mapModel openMapWithXLength: [[_xFieldRandomMap stringValue] intValue]        [_mapModel openMapWithXLength: [[_xFieldRandomMap stringValue] intValue]
165                          withZLength: [[_zFieldRandomMap stringValue] intValue]];                          withZLength: [[_zFieldRandomMap stringValue] intValue]];
166    
# Line 218  Line 235 
235    
236  - (void) setTexture: (id)sender  - (void) setTexture: (id)sender
237  {  {
238      [_mapView displayTerrain: NO];
239    _enableTexture = !_enableTexture;    _enableTexture = !_enableTexture;
240    
241    if (_enableTexture)    if (_enableTexture)
242      [_mapModel setTexturesImageName: @"Tex2.png"]; //stocker le nom de la texture      [_mapModel setTexturesImageName: @"Tex0.png"]; //stocker le nom de la texture
243    else    else
244      [_mapModel setTexturesImageName: @""];      [_mapModel setTexturesImageName: @""];
 }  
   
 /**  
  * Create the color panel.  
  */  
 - (void) setColors: (id)sender  
 {  
   [NSBundle loadNibNamed: @"MapColorsPanel.gorm" owner: self];  
   [_panelColor makeFirstResponder: _fieldColor];  
   [NSApp runModalForWindow: _panelColor];  
 }  
   
 /**  
  * Instanciate the map model with the _fielColor.  
  */  
 - (void) colorOkButton: (id)sender;  
 {  
   if ((_mapModel != nil) & ([_fieldColor stringValue] != @""))  
     {  
       //_display = NO;  
       //[_mapView displayTerrain: _display];  
       //NSLog (@"_windows %@\n", _window);  
       //[_window makeFirstResponder: self];  
         
       if (![_mapModel setColorsImageName: [_fieldColor stringValue]])  
         {  
           NSRunAlertPanel(@"Warning!",  
                           @"Incorrect color name file !!",  
                           @"OK", nil, nil);  
         }  
245    
246        if (_enableTexture)    [_mapView displayTerrain: YES];
         {  
           [_mapModel setTexturesImageName: @""];  
           _enableTexture = NO;  
         }  
   
       [NSApp stopModal];  
       [_panelColor close];  
     }  
 }  
   
 /**  
  * Close the color panel.  
  */  
 - (void) colorCancelButton: (id)sender;  
 {  
   [NSApp abortModal];  
   [_panelColor close];  
247  }  }
248    
249  - (void) editMap: (id)sender  - (void) editMap: (id)sender

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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