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.
14 * $Source: /cvs/cvsroot/d2x/main/editor/objpage.c,v $
17 * $Date: 2004-12-19 13:54:27 $
19 * object selection stuff.
21 * $Log: not supported by cvs2svn $
22 * Revision 1.1.1.1 1999/06/14 22:04:10 donut
23 * Import of d1x 1.37 source.
25 * Revision 2.0 1995/02/27 11:34:43 john
26 * Version 2.0! No anonymous unions, Watcom 10.0, with no need
29 * Revision 1.37 1995/01/14 19:17:55 john
30 * First version of object paging.
32 * Revision 1.36 1995/01/05 16:20:13 mike
33 * bah, remove the int3.
35 * Revision 1.35 1995/01/05 12:47:13 mike
36 * Move code about to prevent compiler warning.
38 * Revision 1.34 1994/11/18 15:23:55 john
39 * Made so the int3 for drawing an invalib object just returns.
41 * Revision 1.33 1994/11/02 16:19:18 matt
42 * Moved draw_model_picture() out of editor, and cleaned up code
44 * Revision 1.32 1994/10/23 02:11:18 matt
45 * Got rid of obsolete hostage_info stuff
47 * Revision 1.31 1994/09/09 14:41:35 matt
48 * New parms for draw_polygon_model()
50 * Revision 1.30 1994/08/29 19:26:53 matt
51 * Fixed botches change from yesterday
53 * Revision 1.29 1994/08/28 23:40:35 matt
56 * Revision 1.28 1994/08/14 23:15:32 matt
57 * Added animating bitmap hostages, and cleaned up vclips a bit
59 * Revision 1.27 1994/08/13 14:59:02 matt
60 * Finished adding support for miscellaneous objects
62 * Revision 1.26 1994/08/09 16:06:15 john
63 * Added the ability to place players. Made old
64 * Player variable be ConsoleObject.
66 * Revision 1.25 1994/07/28 16:59:23 mike
67 * objects containing objects.
69 * Revision 1.24 1994/06/08 18:17:25 john
70 * Changed the way object types and id's work for hostages
73 * Revision 1.23 1994/06/07 16:52:30 matt
74 * Made object lighting work correctly; changed name of Ambient_light to
75 * Dynamic_light; cleaned up polygobj object rendering a little.
77 * Revision 1.22 1994/05/31 18:42:07 matt
78 * Made robot photos unlighted
80 * Revision 1.21 1994/05/26 21:09:34 matt
81 * Moved robot stuff out of polygon model and into robot_info struct
82 * Made new file, robot.c, to deal with robots
84 * Revision 1.20 1994/05/19 12:10:11 matt
85 * Use new vecmat macros and globals
87 * Revision 1.19 1994/05/17 14:45:27 mike
88 * Get object type and id from ObjType and ObjId.
90 * Revision 1.18 1994/05/17 12:03:36 mike
91 * Deal with little known fact that polygon object != robot.
93 * Revision 1.17 1994/04/29 09:16:56 matt
94 * Added support for multiple-piece explosions
96 * Revision 1.16 1994/04/18 14:15:00 john
97 * Initial version of robot dialog box.
99 * Revision 1.15 1994/04/11 12:01:36 yuan
100 * Fixed resetting to first object on page annoyance.
102 * Revision 1.14 1994/04/01 14:35:50 yuan
103 * Removed debug "id %d\n" for placing objects
105 * Revision 1.13 1994/04/01 11:17:04 yuan
106 * Added objects to objpage. Added buttons for easier tmap scrolling.
107 * Objects are selected fully from objpage and add object menu or pad.
109 * Revision 1.12 1994/03/25 18:42:26 matt
110 * Adjusted constant to make robot pictures more correct size
112 * Revision 1.11 1994/03/25 16:57:17 matt
113 * New parm to draw_polygon_object(), and draw object "snapshots" in
114 * correct size (although this probably doesn't work yet).
116 * Revision 1.10 1994/03/25 14:23:01 matt
117 * Disabled lighting when taking "snapshots" of robots
119 * Revision 1.9 1994/03/17 10:47:24 john
120 * Corrected all kinds of problems associated with N_polygon_objects.
122 * Revision 1.8 1994/03/16 11:07:31 john
123 * Made zoom work a bit better.
125 * Revision 1.7 1994/03/16 10:50:32 john
126 * fixed warning with constant length.
128 * Revision 1.6 1994/03/16 10:43:18 john
129 * Added controls to rotate/zoom object.
131 * Revision 1.5 1994/03/15 22:23:24 matt
132 * Render little bitmap pictures of robots for display on editor page
134 * Revision 1.4 1994/02/01 11:27:14 john
135 * Hacked in 8 object types for demo.
137 * Revision 1.3 1994/01/26 16:42:19 john
138 * Display numbers instead of bitmaps... made
139 * Num_robot_types or whatever be set to 4
140 * in init_object_page... this is a hack!!!
142 * Revision 1.2 1993/12/16 17:26:24 john
143 * Moved texture and object selection to texpage and objpage
145 * Revision 1.1 1993/12/16 16:12:57 john
154 static char rcsid[] = "$Id: objpage.c,v 1.1 2004-12-19 13:54:27 btb Exp $";
157 // Num_robot_types --> N_polygon_models
158 // Cur_robot_type --> Cur_robot_type
159 // Texture[Cur_robot_type]->bitmap ---> robot_bms[robot_bm_nums[ Cur_robot_type ] ]
166 #include "screens.h" // For GAME_SCREEN?????
167 #include "editor.h" // For TMAP_CURBOX??????
168 #include "gr.h" // For canves, font stuff
169 #include "ui.h" // For UI_GADGET stuff
170 #include "object.h" // For robot_bms
171 #include "mono.h" // For debugging
180 #define OBJS_PER_PAGE 8
182 static UI_GADGET_USERBOX * ObjBox[OBJS_PER_PAGE];
183 static UI_GADGET_USERBOX * ObjCurrent;
185 static int ObjectPage = 0;
187 //static char Description[8][20] = { "Pig", "Star", "Little\nJosh", "Big\nJosh", "Flying\nPig", "Flying\nStar",
188 //"Little\nFlying\nJosh", "Big\nFlying\nJosh" };
190 //static grs_canvas * ObjnameCanvas;
191 //static char object_filename[13];
193 //static void objpage_print_name( char name[13] ) {
196 // gr_set_current_canvas( ObjnameCanvas );
197 // gr_get_string_size( name, &w, &h, &aw );
198 // gr_string( 0, 0, name );
199 // //gr_set_fontcolor( CBLACK, CWHITE );
202 //static void objpage_display_name( char *format, ... ) {
205 // va_start(ap, format);
206 // vsprintf(object_filename, format, ap);
209 // objpage_print_name(object_filename);
221 vms_angvec objpage_view_orient;
222 fix objpage_view_dist;
224 //this is bad to have the extern, but this snapshot stuff is special
225 extern int polyobj_lighting;
229 // Type is optional. If you pass -1, type is determined, else type is used, and id is not xlated through ObjId.
230 void draw_robot_picture(int id, vms_angvec *orient_angles, int type)
233 if (id >= Num_total_object_types)
237 type = ObjType[id]; // Find the object type, given an object id.
238 id = ObjId[id]; // Translate to sub-id.
244 PIGGY_PAGE_IN(Vclip[Hostage_vclip_num[id]].frames[0]);
245 gr_bitmap(0,0,&GameBitmaps[Vclip[Hostage_vclip_num[id]].frames[0].index]);
249 if ( Powerup_info[id].vclip_num > -1 ) {
250 PIGGY_PAGE_IN(Vclip[Powerup_info[id].vclip_num].frames[0]);
251 gr_bitmap(0,0,&GameBitmaps[Vclip[Powerup_info[id].vclip_num].frames[0].index]);
256 draw_model_picture(Player_ship->model_num,orient_angles); // Draw a poly model below
260 draw_model_picture(Robot_info[id].model_num,orient_angles); // Draw a poly model below
263 case OL_CONTROL_CENTER:
265 draw_model_picture(id,orient_angles);
268 //Int3(); // Invalid type!!!
274 void redraw_current_object()
279 gr_set_current_canvas(ObjCurrent->canvas);
280 draw_robot_picture(Cur_robot_type,&objpage_view_orient, -1);
281 gr_set_current_canvas(cc);
284 void gr_label_box( int i)
287 gr_clear_canvas(BM_XRGB(0,0,0));
288 draw_robot_picture(i,&objpage_view_orient, -1);
291 // sprintf( s, " %d ", i );
292 // gr_clear_canvas( BM_XRGB(0,15,0) );
293 // gr_set_fontcolor( CWHITE, BM_XRGB(0,15,0) );
294 // ui_string_centered( grd_curcanv->cv_bitmap.bm_w/2, grd_curcanv->cv_bitmap.bm_h/2, Description[i] );
297 int objpage_goto_first()
302 for (i=0; i<OBJS_PER_PAGE; i++ ) {
303 gr_set_current_canvas(ObjBox[i]->canvas);
304 if (i+ObjectPage*OBJS_PER_PAGE < Num_total_object_types ) {
305 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ i+ObjectPage*OBJS_PER_PAGE ] ] );
306 gr_label_box(i+ObjectPage*OBJS_PER_PAGE );
308 gr_clear_canvas( CGREY );
314 int objpage_goto_last()
318 ObjectPage=(Num_total_object_types)/OBJS_PER_PAGE;
319 for (i=0; i<OBJS_PER_PAGE; i++ )
321 gr_set_current_canvas(ObjBox[i]->canvas);
322 if (i+ObjectPage*OBJS_PER_PAGE < Num_total_object_types )
324 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ i+ObjectPage*OBJS_PER_PAGE ] ] );
325 gr_label_box(i+ObjectPage*OBJS_PER_PAGE );
327 gr_clear_canvas( CGREY );
333 static int objpage_goto_prev()
336 if (ObjectPage > 0) {
338 for (i=0; i<OBJS_PER_PAGE; i++ )
340 gr_set_current_canvas(ObjBox[i]->canvas);
341 if (i+ObjectPage*OBJS_PER_PAGE < Num_total_object_types)
343 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ i+ObjectPage*OBJS_PER_PAGE ] ] );
344 gr_label_box(i+ObjectPage*OBJS_PER_PAGE );
346 gr_clear_canvas( CGREY );
353 static int objpage_goto_next()
356 if ((ObjectPage+1)*OBJS_PER_PAGE < Num_total_object_types) {
358 for (i=0; i<OBJS_PER_PAGE; i++ )
360 gr_set_current_canvas(ObjBox[i]->canvas);
361 if (i+ObjectPage*OBJS_PER_PAGE < Num_total_object_types)
363 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ i+ObjectPage*OBJS_PER_PAGE ] ] );
364 gr_label_box(i+ObjectPage*OBJS_PER_PAGE );
366 gr_clear_canvas( CGREY );
373 int objpage_grab_current(int n)
377 if ( (n<0) || ( n>= Num_total_object_types) ) return 0;
379 ObjectPage = n / OBJS_PER_PAGE;
381 if (ObjectPage*OBJS_PER_PAGE < Num_total_object_types) {
382 for (i=0; i<OBJS_PER_PAGE; i++ )
384 gr_set_current_canvas(ObjBox[i]->canvas);
385 if (i+ObjectPage*OBJS_PER_PAGE < Num_total_object_types)
387 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ i+ObjectPage*OBJS_PER_PAGE ] ] );
388 gr_label_box(i+ObjectPage*OBJS_PER_PAGE );
390 gr_clear_canvas( CGREY );
396 gr_set_current_canvas(ObjCurrent->canvas);
397 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ Cur_robot_type ] ] );
398 gr_label_box(Cur_robot_type);
400 //objpage_display_name( Texture[Cur_robot_type]->filename );
405 int objpage_goto_next_object()
409 n = Cur_robot_type++;
410 if (n >= Num_total_object_types) n = 0;
412 objpage_grab_current(n);
418 #define OBJBOX_X (TMAPBOX_X) //location of first one
419 #define OBJBOX_Y (OBJCURBOX_Y - 24 )
423 #define DELTA_ANG 0x800
425 int objpage_increase_pitch()
427 objpage_view_orient.p += DELTA_ANG;
428 redraw_current_object();
432 int objpage_decrease_pitch()
434 objpage_view_orient.p -= DELTA_ANG;
435 redraw_current_object();
439 int objpage_increase_heading()
441 objpage_view_orient.h += DELTA_ANG;
442 redraw_current_object();
446 int objpage_decrease_heading()
448 objpage_view_orient.h -= DELTA_ANG;
449 redraw_current_object();
453 int objpage_increase_bank()
455 objpage_view_orient.b += DELTA_ANG;
456 redraw_current_object();
460 int objpage_decrease_bank()
462 objpage_view_orient.b -= DELTA_ANG;
463 redraw_current_object();
467 int objpage_increase_z()
469 objpage_view_dist -= 0x8000;
470 redraw_current_object();
474 int objpage_decrease_z()
476 objpage_view_dist += 0x8000;
477 redraw_current_object();
481 int objpage_reset_orient()
483 objpage_view_orient.p = 0;
484 objpage_view_orient.b = 0;
485 objpage_view_orient.h = -0x8000;
486 //objpage_view_dist = DEFAULT_VIEW_DIST;
487 redraw_current_object();
492 // INIT TEXTURE STUFF
494 void objpage_init( UI_WINDOW *win )
498 //Num_total_object_types = N_polygon_models + N_hostage_types + N_powerup_types;
499 //Assert (N_polygon_models < MAX_POLYGON_MODELS);
500 //Assert (Num_total_object_types < MAX_OBJTYPE );
501 //Assert (N_hostage_types < MAX_HOSTAGE_TYPES );
502 //Assert (N_powerup_types < MAX_POWERUP_TYPES );
503 // Assert (N_robot_types < MAX_ROBOTS);
505 ui_add_gadget_button( win, OBJCURBOX_X + 00, OBJCURBOX_Y - 27, 30, 20, "<<", objpage_goto_prev );
506 ui_add_gadget_button( win, OBJCURBOX_X + 32, OBJCURBOX_Y - 27, 30, 20, ">>", objpage_goto_next );
508 ui_add_gadget_button( win, OBJCURBOX_X + 00, OBJCURBOX_Y - 54, 30, 20, "B", objpage_goto_first );
509 ui_add_gadget_button( win, OBJCURBOX_X + 32, OBJCURBOX_Y - 54, 30, 20, "E", objpage_goto_last );
511 ui_add_gadget_button( win, OBJCURBOX_X + 25, OBJCURBOX_Y + 62, 22, 13, "P-", objpage_decrease_pitch );
512 ui_add_gadget_button( win, OBJCURBOX_X + 25, OBJCURBOX_Y + 90, 22, 13, "P+", objpage_increase_pitch );
513 ui_add_gadget_button( win, OBJCURBOX_X + 00, OBJCURBOX_Y + 90, 22, 13, "B-", objpage_decrease_bank );
514 ui_add_gadget_button( win, OBJCURBOX_X + 50, OBJCURBOX_Y + 90, 22, 13, "B+", objpage_increase_bank );
515 ui_add_gadget_button( win, OBJCURBOX_X + 00, OBJCURBOX_Y + 76, 22, 13, "H-", objpage_decrease_heading );
516 ui_add_gadget_button( win, OBJCURBOX_X + 50, OBJCURBOX_Y + 76, 22, 13, "H+", objpage_increase_heading );
517 ui_add_gadget_button( win, OBJCURBOX_X + 00, OBJCURBOX_Y + 62, 22, 13, "Z+", objpage_increase_z );
518 ui_add_gadget_button( win, OBJCURBOX_X + 50, OBJCURBOX_Y + 62, 22, 13, "Z-", objpage_decrease_z );
519 ui_add_gadget_button( win, OBJCURBOX_X + 25, OBJCURBOX_Y + 76, 22, 13, "R", objpage_reset_orient );
521 for (i=0;i<OBJS_PER_PAGE;i++)
522 ObjBox[i] = ui_add_gadget_userbox( win, OBJBOX_X + (i/2)*(2+OBJBOX_W), OBJBOX_Y + (i%2)*(2+OBJBOX_H), OBJBOX_W, OBJBOX_H);
524 ObjCurrent = ui_add_gadget_userbox( win, OBJCURBOX_X, OBJCURBOX_Y-5, 64, 64 );
526 objpage_reset_orient();
528 for (i=0; i<OBJS_PER_PAGE; i++ )
530 gr_set_current_canvas(ObjBox[i]->canvas);
531 if (i+ObjectPage*OBJS_PER_PAGE < Num_total_object_types)
533 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ i+ObjectPage*OBJS_PER_PAGE ] ] );
534 gr_label_box(i+ObjectPage*OBJS_PER_PAGE );
536 gr_clear_canvas( CGREY );
540 // Don't reset robot_type when we return to editor.
541 // Cur_robot_type = ObjectPage*OBJS_PER_PAGE;
542 gr_set_current_canvas(ObjCurrent->canvas);
543 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ Cur_robot_type ] ] );
544 gr_label_box(Cur_robot_type);
546 //ObjnameCanvas = gr_create_sub_canvas(&grd_curscreen->sc_canvas, OBJCURBOX_X , OBJCURBOX_Y + OBJBOX_H + 10, 100, 20);
547 //gr_set_current_canvas( ObjnameCanvas );
548 //gr_set_curfont( ui_small_font );
549 //gr_set_fontcolor( CBLACK, CWHITE );
550 //objpage_display_name( Texture[Cur_robot_type]->filename );
556 //gr_free_sub_canvas(ObjnameCanvas);
566 for (i=0; i<OBJS_PER_PAGE; i++ )
568 if (ObjBox[i]->b1_clicked && (i+ObjectPage*OBJS_PER_PAGE < Num_total_object_types))
570 Cur_robot_type = i+ObjectPage*OBJS_PER_PAGE;
571 gr_set_current_canvas(ObjCurrent->canvas);
572 //gr_ubitmap(0,0, robot_bms[robot_bm_nums[ Cur_robot_type ] ] );
573 gr_label_box(Cur_robot_type);
574 //objpage_display_name( Texture[Cur_robot_type]->filename );