]> icculus.org git repositories - btb/d2x.git/blob - main/editor/info.c
3d7c3c23b8c9d6bca4217a4adab0e21b7c43c062
[btb/d2x.git] / main / editor / info.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13 /*
14  * $Source: /cvs/cvsroot/d2x/main/editor/info.c,v $
15  * $Revision: 1.1 $
16  * $Author: btb $
17  * $Date: 2004-12-19 13:54:27 $
18  * 
19  * Print debugging info in ui.
20  * 
21  * $Log: not supported by cvs2svn $
22  * Revision 1.1.1.1  1999/06/14 22:03:18  donut
23  * Import of d1x 1.37 source.
24  *
25  * Revision 2.0  1995/02/27  11:35:34  john
26  * Version 2.0! No anonymous unions, Watcom 10.0, with no need
27  * for bitmaps.tbl.
28  * 
29  * Revision 1.42  1995/02/22  15:12:50  allender
30  * remove anonymous unions from object structure
31  * 
32  * Revision 1.41  1994/12/08  13:59:39  matt
33  * *** empty log message ***
34  * 
35  * Revision 1.40  1994/09/30  00:38:30  mike
36  * Fix some diagnostic messages
37  * 
38  * Revision 1.39  1994/09/29  20:13:12  mike
39  * Clean up some text, prevent it from writing outside canvas.
40  * 
41  * Revision 1.38  1994/09/29  09:32:17  mike
42  * Fix text clipping problem in UI keypad info text.
43  * 
44  * Revision 1.37  1994/09/25  23:42:20  matt
45  * Took out references to obsolete constants
46  * 
47  * Revision 1.36  1994/08/25  21:57:05  mike
48  * IS_CHILD stuff.
49  * 
50  * Revision 1.35  1994/08/23  16:39:50  mike
51  * mode replaced by behavior in ai_info.
52  * 
53  * Revision 1.34  1994/07/18  10:45:23  mike
54  * Fix erase window in texture pads after adding more click-boxes.
55  * 
56  * Revision 1.33  1994/07/15  12:34:10  mike
57  * Remove use of AIM_FOLLOW_PATH_CIRCULAR.
58  * 
59  * Revision 1.32  1994/06/17  17:13:46  yuan
60  * Fixed text so it doesn't overflow screen
61  * 
62  * Revision 1.31  1994/06/01  17:22:31  matt
63  * Set font color before drawing info; got rid of superfluous %d
64  * 
65  * Revision 1.30  1994/05/29  23:40:29  matt
66  * Killed reference to now-unused movement type
67  * 
68  * Revision 1.29  1994/05/29  22:52:32  matt
69  * Deleted unused stuff
70  * 
71  * Revision 1.28  1994/05/27  10:34:16  yuan
72  * Added new Dialog boxes for Walls and Triggers.
73  * 
74  * Revision 1.27  1994/05/17  10:34:35  matt
75  * Changed Num_objects to num_objects, since it's not really global anymore
76  * 
77  * Revision 1.26  1994/05/14  17:17:59  matt
78  * Got rid of externs in source (non-header) files
79  * 
80  * Revision 1.25  1994/05/12  14:47:07  mike
81  * Adjust for Ai_states killed, replaced by field in object structure.
82  * 
83  * Revision 1.24  1994/05/06  12:52:11  yuan
84  * Adding some gamesave checks...
85  * 
86  * Revision 1.23  1994/05/03  19:21:28  matt
87  * Removed reference to robot flythrough mode, which doesn't exist anymore
88  * 
89  * Revision 1.22  1994/05/03  11:03:06  mike
90  * Customize text for segment sizing keypad.
91  * 
92  * Revision 1.21  1994/04/29  15:05:40  yuan
93  * More info added...
94  * 
95  * Revision 1.20  1994/04/22  17:45:58  john
96  * MAde top 2 bits of paste-ons pick the 
97  * orientation of the bitmap.
98  * 
99  * Revision 1.19  1994/04/20  17:29:30  yuan
100  * Added tmap_num info.
101  * 
102  * Revision 1.18  1994/04/13  19:12:55  mike
103  * Fix font color problems in keypads.
104  * 
105  * Revision 1.17  1994/04/13  13:26:37  mike
106  * Kill a mprintf.
107  * 
108  * Revision 1.16  1994/04/13  13:24:44  mike
109  * Separate info display, customize for each keypad.
110  * 
111  * Revision 1.15  1994/03/19  17:21:31  yuan
112  * Wall system implemented until specific features need to be added...
113  * (Needs to be hammered on though.)
114  * 
115  * Revision 1.14  1994/02/22  18:13:13  yuan
116  * Added tmap number field.
117  * 
118  * Revision 1.13  1994/02/17  09:46:27  matt
119  * Removed include of slew.h
120  * 
121  * Revision 1.12  1994/02/16  19:58:56  yuan
122  * Added type to info
123  * 
124  * Revision 1.11  1994/02/16  16:48:08  yuan
125  * Added Curside.
126  * 
127  * Revision 1.10  1994/02/03  17:26:43  yuan
128  * Fixed formatting of vertex numbering.
129  * 
130  * Revision 1.9  1994/01/31  12:17:06  yuan
131  * Make sure Num_segments, etc. are drawn.
132  * 
133  * Revision 1.8  1994/01/22  13:43:12  yuan
134  * Cosmetic fixes.
135  * 
136  * Revision 1.7  1994/01/21  12:14:59  yuan
137  * Fixed cosmetic problem
138  * 
139  * Revision 1.6  1994/01/21  12:01:03  yuan
140  * Added segment and vertex info
141  * 
142  * Revision 1.5  1994/01/20  11:28:11  john
143  * *** empty log message ***
144  * 
145  * Revision 1.4  1994/01/19  10:44:42  john
146  * *** empty log message ***
147  * 
148  * Revision 1.3  1994/01/19  10:32:36  john
149  * *** empty log message ***
150  * 
151  * Revision 1.2  1994/01/19  09:34:31  john
152  * First version.
153  * 
154  * Revision 1.1  1994/01/19  09:30:43  john
155  * Initial revision
156  * 
157  * 
158  */
159
160
161 #ifdef RCS
162 static char rcsid[] = "$Id: info.c,v 1.1 2004-12-19 13:54:27 btb Exp $";
163 #endif
164
165 #include <i86.h>
166 #include <stdio.h>
167 #include <stdlib.h>
168 #include <string.h>                                                                                               
169 #include <malloc.h>
170
171 #include "inferno.h"
172 #include "segment.h"
173 #include "gr.h"
174 #include "ui.h"
175 #include "editor.h"
176
177 #include "mono.h"
178 #include "error.h"
179 #include "textures.h"
180 #include "object.h"
181 #include "ai.h"
182
183 #include "texpage.h"            // Textue selection paging stuff
184 #include "objpage.h"            // Object selection paging stuff
185
186 #include "wall.h"
187 #include "switch.h"
188
189 int init_info;
190
191 #ifdef DO_MEMINFO
192 struct meminfo {
193     int LargestBlockAvail;
194     int MaxUnlockedPage;
195     int LargestLockablePage;
196     int LinAddrSpace;
197     int NumFreePagesAvail;
198     int NumPhysicalPagesFree;
199     int TotalPhysicalPages;
200     int FreeLinAddrSpace;
201     int SizeOfPageFile;
202     int Reserved[3];
203 } MemInfo;
204
205 #define DPMI_INT        0x31
206
207 void read_mem_info()
208 {
209     union REGS regs;
210     struct SREGS sregs;
211
212     regs.x.eax = 0x00000500;
213     memset( &sregs, 0, sizeof(sregs) );
214     sregs.es = FP_SEG( &MemInfo );
215     regs.x.edi = FP_OFF( &MemInfo );
216
217     int386x( DPMI_INT, &regs, &regs, &sregs );
218 }
219 #endif
220
221 char * get_object_type(int num, char *name)
222 {
223         switch (num) {
224                 case OBJ_NONE:                  strcpy(name, "OBJ_NONE    ");   break;
225                 case OBJ_WALL:          strcpy(name, "OBJ_WALL    ");   break;
226                 case OBJ_FIREBALL:      strcpy(name, "OBJ_FIREBALL");   break;
227                 case OBJ_ROBOT:                 strcpy(name, "OBJ_ROBOT   ");   break;
228                 case OBJ_HOSTAGE:       strcpy(name, "OBJ_HOSTAGE ");   break;
229                 case OBJ_PLAYER:                strcpy(name, "OBJ_PLAYER  ");   break;
230                 case OBJ_WEAPON:                strcpy(name, "OBJ_WEAPON  ");   break;
231                 case OBJ_CAMERA:                strcpy(name, "OBJ_CAMERA  ");   break;
232                 case OBJ_POWERUP:       strcpy(name, "OBJ_POWERUP ");   break;
233                 default:                                        strcpy(name, " (unknown)  ");   break;
234         }
235
236         return name;
237 }
238
239 char * get_control_type(int num, char *name)
240 {
241         switch (num) {
242                 case CT_NONE:                                   strcpy(name, "CT_NONE       "); break;
243                 case CT_AI:                                             strcpy(name, "CT_AI         "); break;
244                 case CT_EXPLOSION:                      strcpy(name, "CT_EXPLOSION  "); break;
245                 //case CT_MULTIPLAYER:                  strcpy(name, "CT_MULTIPLAYER"); break;
246                 case CT_FLYING:                         strcpy(name, "CT_FLYING     "); break;
247                 case CT_SLEW:                                   strcpy(name, "CT_SLEW       "); break;
248                 case CT_FLYTHROUGH:                     strcpy(name, "CT_FLYTHROUGH "); break;
249                 //case CT_DEMO:                                 strcpy(name, "CT_DEMO       "); break;
250                 //case CT_ROBOT_FLYTHROUGH:     strcpy(name, "CT_FLYTHROUGH "); break;
251                 case CT_WEAPON:                         strcpy(name, "CT_WEAPON     "); break;
252                 default:                                                        strcpy(name, " (unknown)    "); break;
253         }
254         return name;
255 }
256
257 char * get_movement_type(int num, char *name)
258 {
259         switch (num) {
260                 case MT_NONE:                   strcpy(name, "MT_NONE       "); break;
261                 case MT_PHYSICS:                strcpy(name, "MT_PHYSICS    "); break;
262                 //case MT_MULTIPLAYER:  strcpy(name, "MT_MULTIPLAYER"); break;
263                 default:                                        strcpy(name, " (unknown)    "); break;
264         }
265         return name;
266 }
267
268 char * get_ai_behavior(int num, char *name)
269 {
270 #define AIB_STILL                                               0x80
271 #define AIB_NORMAL                                              0x81
272 #define AIB_HIDE                                                        0x82
273 #define AIB_RUN_FROM                                    0x83
274 #define AIB_FOLLOW_PATH                         0x84
275
276         switch (num) {
277                 case AIB_STILL:                         strcpy(name, "STILL       ");   break;
278                 case AIB_NORMAL:                                strcpy(name, "NORMAL      ");   break;
279                 case AIB_HIDE:                                  strcpy(name, "HIDE        ");   break;
280                 case AIB_RUN_FROM:                      strcpy(name, "RUN_FROM    ");   break;
281                 case AIB_FOLLOW_PATH:           strcpy(name, "FOLLOW_PATH ");   break;
282                 default:                                                        strcpy(name, " (unknown)  ");   break;
283         }
284         return name;
285 }
286
287 //      ---------------------------------------------------------------------------------------------------
288 void info_display_object_placement(int show_all)
289 {
290         static  int     old_Cur_object_index;
291         static  int     old_type;
292         static  int     old_movement_type;
293         static  int     old_control_type;
294         static  int     old_mode;
295
296         char            name[30];
297
298         if (init_info | show_all) {
299                 old_Cur_object_index = -2;
300                 old_type = -2;
301                 old_movement_type = -2;
302                 old_control_type = -2;
303                 old_mode = -2;
304         }
305
306         if ( ( Cur_object_index != old_Cur_object_index) || 
307                         ( Objects[Cur_object_index].type != old_type) || 
308                         ( Objects[Cur_object_index].movement_type != old_movement_type) || 
309                         ( Objects[Cur_object_index].control_type != old_control_type) || 
310                         ( Objects[Cur_object_index].ctype.ai_info.behavior != old_mode) ) {
311
312                 gr_uprintf( 0, 0, "Object id: %4d\n", Cur_object_index);
313                 gr_uprintf( 0, 16, "Type: %s\n", get_object_type(Objects[Cur_object_index].type , name));
314                 gr_uprintf( 0, 32, "Movmnt: %s\n", get_movement_type(Objects[Cur_object_index].movement_type, name));
315                 gr_uprintf( 0, 48, "Cntrl: %s\n", get_control_type(Objects[Cur_object_index].control_type, name));
316                 gr_uprintf( 0, 64, "Mode: %s\n", get_ai_behavior(Objects[Cur_object_index].ctype.ai_info.behavior, name));
317
318                 old_Cur_object_index = Cur_object_index;
319                 old_type = Objects[Cur_object_index].type;
320                 old_movement_type = Objects[Cur_object_index].movement_type;
321                 old_mode = Objects[Cur_object_index].control_type;
322                 old_mode = Objects[Cur_object_index].ctype.ai_info.behavior;
323         }
324
325 }
326
327 //      ---------------------------------------------------------------------------------------------------
328 void info_display_segsize(int show_all)
329 {
330         static  int     old_SegSizeMode;
331
332         char            name[30];
333
334         if (init_info | show_all) {
335                 old_SegSizeMode = -2;
336         }
337
338         if (old_SegSizeMode != SegSizeMode  ) {
339                 switch (SegSizeMode) {
340                         case SEGSIZEMODE_FREE:          strcpy(name, "free   ");        break;
341                         case SEGSIZEMODE_ALL:           strcpy(name, "all    ");        break;
342                         case SEGSIZEMODE_CURSIDE:       strcpy(name, "curside");        break;
343                         case SEGSIZEMODE_EDGE:          strcpy(name, "edge   ");        break;
344                         case SEGSIZEMODE_VERTEX:        strcpy(name, "vertex ");        break;
345                         default:
346                                 Error("Illegal value for SegSizeMode in info.c/info_display_segsize\n");
347                 }
348
349                 gr_uprintf( 0, 0, "Mode: %s\n", name);
350
351                 old_SegSizeMode = SegSizeMode;
352         }
353
354 }
355
356 extern int num_objects;
357
358 //      ---------------------------------------------------------------------------------------------------
359 void info_display_default(int show_all)
360 {
361         static int old_Num_segments = -1;
362         static int old_Num_vertices = -1;
363         static int old_Num_objects = -1;
364         static int old_Cursegp_num = -1;
365         static int old_Curside = -1;
366         static int old_Cursegp_num_for_verts = -1;
367         static int old_CurrentTexture = -1;
368         static int old_Num_walls = -1;
369         static int old_Num_triggers = -1;
370
371         if (init_info | show_all) {
372                 init_info = 0;
373                 old_Num_segments = -1;
374                 old_Num_vertices = -1;
375                 old_Num_objects = -1;
376                 old_Cursegp_num = -1;
377                 old_Cursegp_num_for_verts = -1;
378                 old_Curside = -1;
379                 old_CurrentTexture = -1;
380                 old_Num_walls = -1;
381                 old_Num_triggers = -1;
382         }
383
384         gr_set_fontcolor(CBLACK,CWHITE);
385
386         //--------------- Number of segments ----------------
387
388         if ( old_Num_segments != Num_segments ) {
389                 gr_uprintf( 0, 0, "Segments: %4d/%4d", Num_segments, MAX_SEGMENTS );
390                 old_Num_segments = Num_segments;
391         }
392
393         //---------------- Number of vertics -----------------
394         
395         if ( old_Num_vertices != Num_vertices ) {
396                 gr_uprintf( 0, 16, "Vertices: %4d/%4d", Num_vertices, MAX_VERTICES );
397                 old_Num_vertices = Num_vertices;
398         }
399
400         //---------------- Number of objects -----------------
401         
402         if ( old_Num_objects != num_objects )   {
403                 gr_uprintf( 0, 32, "Objs: %3d/%3d", num_objects, MAX_OBJECTS );
404                 old_Num_objects = num_objects;
405         }
406
407         //--------------- Current_segment_number -------------
408         //--------------- Current_side_number -------------
409
410         if (( old_Cursegp_num != Cursegp-Segments ) || ( old_Curside != Curside ))      {
411                 gr_uprintf( 0, 48, "Cursegp/side: %3d/%1d", Cursegp-Segments, Curside);
412                 gr_uprintf( 0, 128, " tmap1,2,o: %3d/%3dx%1d", Cursegp->sides[Curside].tmap_num, Cursegp->sides[Curside].tmap_num2 & 0x3FFF, (Cursegp->sides[Curside].tmap_num2 >> 14) & 3);
413                 old_Cursegp_num = Cursegp-Segments;
414                 old_Curside = Curside;
415         }
416
417         //--------------- Current_vertex_numbers -------------
418
419         if ( old_Cursegp_num_for_verts != Cursegp-Segments )    {
420
421                 gr_uprintf( 0, 64, "{%3d,%3d,%3d,%3d,", Cursegp->verts[0],Cursegp->verts[1],
422                                                                                                                                                                                          Cursegp->verts[2],Cursegp->verts[3] );
423                 gr_uprintf( 0, 80," %3d,%3d,%3d,%3d}", Cursegp->verts[4],Cursegp->verts[5],
424                                                                                                                                                                                          Cursegp->verts[6],Cursegp->verts[7] );
425                 old_Cursegp_num_for_verts = Cursegp-Segments;
426         }
427
428         //--------------- Num walls/links/triggers -------------------------
429
430         if ( old_Num_walls != Num_walls ) {
431 //              gr_uprintf( 0, 96, "Walls/Links %d/%d", Num_walls, Num_links );
432                 gr_uprintf( 0, 96, "Walls %3d", Num_walls );
433                 old_Num_walls = Num_walls;
434         }
435
436         //--------------- Num triggers ----------------------
437
438         if ( old_Num_triggers != Num_triggers ) {
439                 gr_uprintf( 0, 112, "Num_triggers %2d", Num_triggers );
440                 old_Num_triggers = Num_triggers;
441         }
442
443         //--------------- Current texture number -------------
444
445         if ( old_CurrentTexture != CurrentTexture )     {
446                 gr_uprintf( 0, 144, "Tex/Light: %3d %5.2f", CurrentTexture, f2fl(TmapInfo[CurrentTexture].lighting));
447                 old_CurrentTexture = CurrentTexture;
448         }
449
450 }
451
452 //      ------------------------------------------------------------------------------------
453 void clear_pad_display(void)
454 {
455         gr_clear_canvas(CWHITE);
456    gr_set_fontcolor( CBLACK, CWHITE );
457 }
458
459 //      ------------------------------------------------------------------------------------
460 void info_display_all( UI_WINDOW * wnd )
461 {
462         static int old_padnum = -1;
463         int        padnum,show_all = 0;
464         grs_canvas *save_canvas = grd_curcanv;
465
466         wnd++;          //kill warning
467
468         grd_curcanv = Pad_text_canvas;
469
470         padnum = ui_pad_get_current();
471         Assert(padnum <= MAX_PAD_ID);
472
473         if (padnum != old_padnum) {
474                 clear_pad_display();
475                 old_padnum = padnum;
476                 show_all = 1;
477         }
478
479         switch (padnum) {
480                 case OBJECT_PAD_ID:                     // Object placement
481                         info_display_object_placement(show_all);
482                         break;
483                 case SEGSIZE_PAD_ID:                    // Segment sizing
484                         info_display_segsize(show_all);
485                         break;
486                 default:
487                         info_display_default(show_all);
488                         break;
489         }
490         grd_curcanv = save_canvas;
491 }
492