/[hegemonie]/hegemonie/ModelViewer/OpenFileControl.m
ViewVC logotype

Diff of /hegemonie/ModelViewer/OpenFileControl.m

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

revision 1.1 by ano, Tue Aug 5 09:54:46 2003 UTC revision 1.2 by ano, Mon Aug 18 10:09:08 2003 UTC
# Line 2  Line 2 
2    
3  #include <AppKit/AppKit.h>  #include <AppKit/AppKit.h>
4  #include "OpenFileControl.h"  #include "OpenFileControl.h"
5    #include "Model/MdlModel.h"
6    #include "MdlAnimatedModelForViewer.h"
7    #include "CameraControl.h"
8    
9    #include <GL/gl.h>
10    #include <GL/glut.h>
11    
12  @implementation OpenFileControl  @implementation OpenFileControl
13    
# Line 10  Line 16 
16  {  {
17    NSArray *fileTypes = [NSArray arrayWithObject:@"cfg"];    NSArray *fileTypes = [NSArray arrayWithObject:@"cfg"];
18        
19    NSOpenPanel *oPanel = [NSOpenPanel openPanel];    NSOpenPanel *oPanel = [NSOpenPanel openPanel];  
20      [oPanel setAllowsMultipleSelection: NO];
21    
22    int result = [oPanel runModalForTypes:fileTypes];    int result = [oPanel runModalForTypes:fileTypes];
23          [oPanel update ];
24    
25    if (result == NSOKButton)    if (result == NSOKButton)
26      {      {
27        printf("lo\n");        [_confName setStringValue: [[oPanel filenames] objectAtIndex: 0]];
28          [_paletteFile makeKeyAndOrderFront: _paletteFile];
29          [_paletteOpen makeKeyAndOrderFront: _paletteOpen];
30        }
31      if (result == NSCancelButton)
32        {
33          [_paletteFile makeKeyAndOrderFront: _paletteFile];
34          [_paletteOpen makeKeyAndOrderFront: _paletteOpen];
35      }      }
36  }  }
37    
38    
39  - (void) _loadFileMd3: (id)sender  - (void) _loadFileMd3: (id)sender
40  {  {
41    /* insert your code here */    NSArray *fileTypes = [NSArray arrayWithObject:@"md3"];
42      
43      NSOpenPanel *oPanel = [NSOpenPanel openPanel];
44    
45      [oPanel setAllowsMultipleSelection: NO];
46    
47      int result = [oPanel runModalForTypes:fileTypes];
48        
49      if (result == NSOKButton)
50        {
51          [_md3Name setStringValue: [[oPanel filenames] objectAtIndex: 0]];
52          [_paletteFile makeKeyAndOrderFront: _paletteFile];
53          [_paletteOpen makeKeyAndOrderFront: _paletteOpen];
54        }
55      if (result == NSCancelButton)
56        {
57          [_paletteFile makeKeyAndOrderFront: _paletteFile];
58          [_paletteOpen makeKeyAndOrderFront: _paletteOpen];
59        }
60  }  }
61    
62    
63  - (void) _loadFileSkin: (id)sender  - (void) _loadFileSkin: (id)sender
64  {  {
65    /* insert your code here */   NSArray *fileTypes = [NSArray arrayWithObject:@"skin"];
66      
67      NSOpenPanel *oPanel = [NSOpenPanel openPanel];
68    
69      [oPanel setAllowsMultipleSelection: NO];
70    
71      int result = [oPanel runModalForTypes:fileTypes];
72        
73      if (result == NSOKButton)
74        {
75          [_texName setStringValue: [[oPanel filenames] objectAtIndex: 0]];
76          [_paletteFile makeKeyAndOrderFront: _paletteFile];
77          [_paletteOpen makeKeyAndOrderFront: _paletteOpen];
78        }
79      if (result == NSCancelButton)
80        {
81          [_paletteFile makeKeyAndOrderFront: _paletteFile];
82          [_paletteOpen makeKeyAndOrderFront: _paletteOpen];
83        }
84  }  }
85    
86  - (void) ok: (id)sender  - (void) ok: (id)sender
87  {  {
88    [_paletteOpen performClose: _paletteOpen];    [_paletteOpen performClose: _paletteOpen];
89    
90      NSArray* objs = [NSArray  arrayWithObjects:
91                                [ _modelName stringValue],
92                              [_md3Name stringValue],
93                              [_texName stringValue],
94                              [_confName stringValue],
95                              [_tagName stringValue],nil];
96    
97      NSArray* keys = [NSArray  arrayWithObjects: @"0",@"1",@"2",@"3",@"4",nil];
98    
99      NSMutableDictionary* dico = [NSMutableDictionary dictionaryWithObjects: objs
100                                                       forKeys: keys];
101    
102      [_modelData addObject: dico];
103    
104    [_paletteFile makeKeyAndOrderFront: _paletteFile];    [_paletteFile makeKeyAndOrderFront: _paletteFile];
105      [_tableFile reloadData];
106       if ([_modelData count] > 0)
107        {
108          [_tableFile selectRow: 0
109                      byExtendingSelection: NO];
110        }
111    
112    }
113    
114    - (void) okSelf: (id)sender
115    {
116      int i = 0;
117      RELEASE(_tagNames);
118      RELEASE(_modelsAnimations);
119      RELEASE(_modelsNames);
120      RELEASE(_modelBase);
121    
122      _tagNames = [NSMutableArray new];
123      _modelsAnimations = [NSMutableArray new];
124      _modelsNames = [NSMutableArray new];
125      _modelBase = [NSMutableArray new];
126    
127      for (i = 0; i < [_modelData count]; i++)
128        {
129            
130          NSMutableDictionary* dico =  [_modelData objectAtIndex: i];
131    
132          MdlModel* modelTmp = [MdlModel alloc] ;
133          modelTmp = [modelTmp initWithName: [dico objectForKey: @"1"]
134                               withTexName: [dico objectForKey: @"2"]
135                               withConfigName: [dico objectForKey: @"3"]];
136    
137          NSArray* animTmp = [modelTmp animationsName];
138          [_modelsAnimations addObject: animTmp];
139          [_tagNames addObject: [dico objectForKey: @"4"]];
140    
141          MdlAnimatedModelForViewer* animeModelTmp =
142            [[MdlAnimatedModelForViewer alloc]
143              initWithModel: modelTmp
144              animation: [animTmp objectAtIndex: 0]
145              mode:LECTURE];
146          [_modelBase addObject: animeModelTmp];
147          [_modelsNames addObject: [dico objectForKey: @"0"]];
148        }
149      [_paletteFile performClose: _paletteFile];
150      [_windowFile makeKeyAndOrderFront: _windowFile];
151      [_controllerAnimation update];
152      [_controllerCamera update];
153  }  }
154    
155  - (void) suppr: (id)sender  - (void) suppr: (id)sender
156  {  {
157    /* insert your code here */    if([_modelData count] > 0)
158         [_modelData removeObjectAtIndex: [_tableFile selectedRow]];
159      [_tableFile reloadData];
160  }  }
161    
162  - (int) numberOfRowsInTableView: (NSTableView *) view  - (int) numberOfRowsInTableView: (NSTableView *) view
# Line 58  Line 174 
174  - (id) init  - (id) init
175  {  {
176    self = [super init];    self = [super init];
177      _tagNames = [NSMutableArray new];
178      _modelsAnimations = [NSMutableArray new];
179      _modelsNames = [NSMutableArray new];
180    _modelData = [NSMutableArray new];    _modelData = [NSMutableArray new];
181      _modelBase = [NSMutableArray new];
182    return self;    return self;
183  }  }
184    
185  - (void) dealloc  - (void) dealloc
186  {  {
187      RELEASE(_tagNames);
188      RELEASE(_modelsAnimations);
189      RELEASE(_modelsNames);
190      RELEASE(_modelData);
191    RELEASE(_modelData);    RELEASE(_modelData);
192    [super dealloc];    [super dealloc];
193  }  }
194    
195    - (NSMutableArray*) modelBase
196    {
197      return _modelBase;
198    }
199    
200    - (NSMutableArray*) modelsNames
201    {
202      return _modelsNames;
203    }
204    
205    - (void) setModeAnim: (int)mode
206      forModelNumber: (int)numModel
207    {
208      [[_modelBase objectAtIndex: numModel] setModeA: mode];
209    }
210    
211    - (NSArray*) animForModelNumber: (int)numModel
212    {
213      return [_modelsAnimations objectAtIndex: numModel];
214    }
215    
216    - (NSString*) tagNameForModelNumber: (int) numModel
217    {
218      return [_tagNames objectAtIndex: numModel];
219    }
220    
221    - (void) changeAnimeForModelNumber: (int)numModel
222                              withAnim: (NSString*)name
223    {
224      [[_modelBase objectAtIndex: numModel] setCurrentAnimation: name];
225    }
226    
227    - (void) update
228    {
229      [_controllerAnimation update];
230      [_controllerCamera update];
231    }
232  @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