Nilorea Library

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
n_ressource.c
Go to the documentation of this file.
1
15 #include "n_ressource.h"
16
17
18
28 int create_new_map( MAP **map )
29 {
30
31 static char name[ 50 ] = "nom_par_defaut" ,
32 strX[ 10 ] = "100" ,
33 strY[ 10 ] = "200" ,
34 strW[ 10 ] = "64" ,
35 strH[ 10 ] = "32" ;
36
37
38 DIALOG_PLAYER *player;
39
40 /* here it comes - the big bad ugly DIALOG array for our dialog */
41 DIALOG the_dialog[] =
42 {
43 /* (dialog proc) (x) (y) (w) (h) (fg)(bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
44
45 /* this element just clears the screen, therefore it should come before the others */
46 {
47 d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL , NULL, NULL
48 },
49
50 {
51 d_text_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "CREATION D'UNE NOUVELLE MAP" , NULL, NULL
52 },
53
54 {
55 d_text_proc, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, "NOM:" , NULL, NULL
56 },
57
58 {
59 d_edit_proc, 0, 30, 160, 8, 0, 0, 0, 0, 50, 0, name , NULL, NULL
60 },
61
62 {
63 d_text_proc, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, "TAILLE X:" , NULL, NULL
64 },
65
66 {
67 d_edit_proc, 0, 60, 160, 8, 0, 0, 0, 0, 10, 0, strX , NULL, NULL
68 },
69
70 {
71 d_text_proc, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, "TAILLE Y:" , NULL, NULL
72 },
73
74 {
75 d_edit_proc, 0, 90, 160, 8, 0, 0, 0, 0, 10, 0, strY , NULL, NULL
76 },
77
78 {
79 d_text_proc, 0, 110, 0, 0, 0, 0, 0, 0, 0, 0, "TAILLE TILE X:" , NULL, NULL
80 },
81
82 {
83 d_edit_proc, 0, 120, 160, 8, 0, 0, 0, 0, 10, 0, strW , NULL, NULL
84 },
85
86 {
87 d_text_proc, 0, 140, 0, 0, 0, 0, 0, 0, 0, 0, "TAILLE TILE Y:" , NULL, NULL
88 },
89
90 {
91 d_edit_proc, 0, 150, 160, 8, 0, 0, 0, 0, 10, 0, strH , NULL, NULL
92 },
93
94 {
95 d_button_proc, 165, 170, 160, 20, 0, 0, 'a', D_CLOSE, 0, 0, "&Annuler" , NULL, NULL
96 },
97
98 {
99 d_button_proc, 0, 170, 160, 20, 0, 0, 'o', D_CLOSE , 0, 0, "&Ok" , NULL, NULL
100 },
101
102 {
103 NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL , NULL, NULL
104 }
105 };
106
107 gui_fg_color = makecol( 0, 0, 0 );
108 gui_mg_color = makecol( 128, 128, 128 );
109 gui_bg_color = makecol( 180, 180, 180 );
110
111 set_dialog_color ( the_dialog, gui_fg_color, gui_bg_color );
112
113 centre_dialog ( the_dialog );
114 player = init_dialog( the_dialog, -1 );
115
116 if ( gfx_status( GET , 0 ) == MODE_DX )
117 show_mouse( screen );
118
119 while ( update_dialog( player ) )
120 {
121
122 if ( gfx_status( GET , 0 ) == MODE_OGL )
123 {
124 line( screen, mouse_x - 5, mouse_y, mouse_x + 5, mouse_y, makecol( 255, 0, 0 ) );
125 line( screen, mouse_x, mouse_y - 5, mouse_x, mouse_y + 5, makecol( 255, 0, 0 ) );
126 allegro_gl_flip();
127 player->res = D_REDRAW_ALL ;
128 }
129
130 rest( 0 );
131
132 }
133
134 if ( gfx_status( GET , 0 ) == MODE_DX )
135 show_mouse( NULL );
136
137 TRACE( "Allocating space for MAP *map\n" );
138
139 if ( player -> obj != 12 && shutdown_dialog( player ) != -1 ) {
140 if ( ( *map ) )
141 free_map( &( *map ) );
142
143 if ( create_empty_map( &( *map ) , name ,
144 atoi( strX ) , atoi( strY ) ,
145 atoi( strW ) , atoi( strH ) ,
146 2000 , 2000 , 2000 , 2000 , 1000 ) == FALSE ) {
147
148 TRACE( "Error allocating space for MAP *map\n" );
149 return FALSE;
150 }
151
152 TRACE( "SUCCESS: Allocating space for MAP *map\n" );
153
154 }
155
156 do {}
157 while ( key[ KEY_ESC ] );
158
159 return TRUE;
160 }
161
162
163
174 int make_sprite_lib( ANIM **lib , char *name )
175 {
176 /* IMGS
177 ANIM
178 [NAME OF THE ANIM]
179 image and txt files for the animation
180
181 FX
182 [Type of the FX]
183 [Fx name]
184 image and txt files for the current FX animation
185
186 ITEM
187 [Type of item]
188 [ATTACK]
189 [STOP]
190 [RUN]
191 [ATTACK WITH BOW]
192 PJ
193 [TYPE OF PJ]
194 [ATTACK]
195 [STOP]
196 [RUN]
197 [ATTACK WITH BOW]
198 PNJ
199 [TYPE OF PNJ]
200 [ATTACK]
201 [STOP]
202 [RUN]
203 [ATTACK WITH BOW]
204 STATIC
205 list of pictures
206 TILES
207 list of tiles */
208
209 struct al_ffblk fi;
210 char cmd[ 512 ];
211 int it = 0;
212
213
214 /* searching recursively some sprites */
215 it = al_findfirst( cmd , &fi , FA_ARCH | FA_RDONLY );
216
217 /* adding extension to directory */
218 sprintf( cmd , "%s/*.dat" , name );
219
220 it = al_findfirst( cmd , &fi , FA_ARCH | FA_RDONLY );
221
222
223 if ( ! ( *lib ) ) {
224
225 return FALSE;
226 }
227
228
229 /* we loop until we got no result */
230 while ( it == 0 ) {
231
232
233
234 it = al_findnext( &fi );
235
236 }
237
238
239 if ( name )
240 return 4;
241
242 if ( ( *lib ) )
243 return 2;
244
245 return 1;
246
247
248 } /* make_sprite_lib( ... ) */