1 /* $Id: medrobot.c,v 1.5 2005-01-24 22:26:06 schaffner Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Dialog box to edit robot properties.
22 static char rcsid[] = "$Id: medrobot.c,v 1.5 2005-01-24 22:26:06 schaffner Exp $";
64 #define NUM_BOXES 6 // Number of boxes, AI modes
68 void robot_close_window();
69 //-------------------------------------------------------------------------
70 // Variables for this module...
71 //-------------------------------------------------------------------------
72 static UI_WINDOW *MainWindow = NULL;
73 static UI_GADGET_USERBOX *RobotViewBox;
74 static UI_GADGET_USERBOX *ContainsViewBox;
75 static UI_GADGET_BUTTON *QuitButton;
76 static UI_GADGET_RADIO *InitialMode[NUM_BOXES];
78 static int old_object;
80 static vms_angvec angles={0,0,0}, goody_angles={0,0,0};
82 //-------------------------------------------------------------------------
83 // Given a pointer to an object, returns a number that cooresponds to the
84 // object id as used in the objpage stuff.
85 //-------------------------------------------------------------------------
86 int get_object_id( object * obj )
92 case OBJ_PLAYER: goal_type=OL_PLAYER; break;
93 case OBJ_ROBOT: goal_type=OL_ROBOT; break;
94 case OBJ_POWERUP: goal_type=OL_POWERUP; break;
95 case OBJ_CNTRLCEN: goal_type=OL_CONTROL_CENTER; break;
96 case OBJ_HOSTAGE: goal_type=OL_HOSTAGE; break;
97 case OBJ_CLUTTER: goal_type=OL_CLUTTER; break;
99 Int3(); // Invalid object type
103 // Find first object with the same type as this
104 // one and then add the object id to that to find
105 // the offset into the list.
107 for (i=0; i< Num_total_object_types; i++ ) {
108 if ( ObjType[i]==goal_type)
114 void call_init_ai_object(object *objp, int behavior)
118 if (behavior == AIB_STATION)
119 hide_segment = Cursegp-Segments;
121 if (Markedsegp != NULL)
122 hide_segment = Markedsegp-Segments;
124 hide_segment = Cursegp-Segments;
127 mprintf((0, "Initializing AI object with hide segment = %i\n", hide_segment));
128 init_ai_object(objp-Objects, behavior, hide_segment);
130 if (behavior == AIB_STATION) {
137 cseg = Cursegp-Segments;
139 if (Markedsegp != NULL) {
140 mseg = Markedsegp-Segments;
143 //objp->ctype.ai_info.follow_path_start_seg = Cursegp-Segments;
144 //objp->ctype.ai_info.follow_path_end_seg = Markedsegp-Segments;
148 //-------------------------------------------------------------------------
149 // Called when user presses "Next Type" button. This only works for polygon
150 // objects and it just selects the next polygon model for the current object.
151 //-------------------------------------------------------------------------
154 if (Cur_object_index > -1 ) {
155 if ( Objects[Cur_object_index].type == OBJ_ROBOT ) {
156 object * obj = &Objects[Cur_object_index];
158 if (obj->id >= N_robot_types )
161 //Set polygon-object-specific data
162 obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
163 obj->rtype.pobj_info.subobj_flags = 0;
165 obj->mtype.phys_info.flags |= (PF_LEVELLING);
166 obj->shields = Robot_info[obj->id].strength;
167 call_init_ai_object(obj, AIB_NORMAL);
169 Cur_robot_type = obj->id;
172 Update_flags |= UF_WORLD_CHANGED;
176 //-------------------------------------------------------------------------
177 // Called when user presses "Prev Type" button. This only works for polygon
178 // objects and it just selects the prev polygon model for the current object.
179 //-------------------------------------------------------------------------
182 if (Cur_object_index > -1 ) {
183 if ( Objects[Cur_object_index].type == OBJ_ROBOT ) {
184 object * obj = &Objects[Cur_object_index];
186 obj->id = N_robot_types-1;
190 //Set polygon-object-specific data
191 obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
192 obj->rtype.pobj_info.subobj_flags = 0;
194 obj->mtype.phys_info.flags |= (PF_LEVELLING);
195 obj->shields = Robot_info[obj->id].strength;
196 call_init_ai_object(obj, AIB_NORMAL);
198 Cur_robot_type = obj->id;
201 Update_flags |= UF_WORLD_CHANGED;
205 //-------------------------------------------------------------------------
206 // Dummy function for Mike to write.
207 //-------------------------------------------------------------------------
208 int med_set_ai_path()
210 mprintf( (0, "med-set-ai-path called -- it does nothing, paths automatically set!\n" ));
215 // #define OBJ_NONE 255 //unused object
216 // #define OBJ_WALL 0 //A wall... not really an object, but used for collisions
217 // #define OBJ_FIREBALL 1 //a fireball, part of an explosion
218 // #define OBJ_ROBOT 2 //an evil enemy
219 // #define OBJ_HOSTAGE 3 //a hostage you need to rescue
220 // #define OBJ_PLAYER 4 //the player on the console
221 // #define OBJ_WEAPON 5 //a laser, missile, etc
222 // #define OBJ_CAMERA 6 //a camera to slew around with
223 // #define OBJ_POWERUP 7 //a powerup you can pick up
224 // #define OBJ_DEBRIS 8 //a piece of robot
225 // #define OBJ_CNTRLCEN 9 //the control center
226 // #define OBJ_FLARE 10 //the control center
227 // #define MAX_OBJECT_TYPES 11
230 #define GOODY_TYPE_MAX MAX_OBJECT_TYPES
234 //#define GOODY_ID_MAX_ROBOT 6
235 //#define GOODY_ID_MAX_POWERUP 9
236 #define GOODY_COUNT_MAX 4
238 int Cur_goody_type = OBJ_POWERUP;
239 int Cur_goody_id = 0;
240 int Cur_goody_count = 0;
242 void update_goody_info(void)
244 if (Cur_object_index > -1 ) {
245 if ( Objects[Cur_object_index].type == OBJ_ROBOT ) {
246 object * obj = &Objects[Cur_object_index];
248 obj->contains_type = Cur_goody_type;
249 obj->contains_id = Cur_goody_id;
250 obj->contains_count = Cur_goody_count;
255 // #define OBJ_WALL 0 //A wall... not really an object, but used for collisions
256 // #define OBJ_FIREBALL 1 //a fireball, part of an explosion
257 // #define OBJ_ROBOT 2 //an evil enemy
258 // #define OBJ_HOSTAGE 3 //a hostage you need to rescue
259 // #define OBJ_PLAYER 4 //the player on the console
260 // #define OBJ_WEAPON 5 //a laser, missile, etc
261 // #define OBJ_CAMERA 6 //a camera to slew around with
262 // #define OBJ_POWERUP 7 //a powerup you can pick up
263 // #define OBJ_DEBRIS 8 //a piece of robot
264 // #define OBJ_CNTRLCEN 9 //the control center
265 // #define OBJ_FLARE 10 //the control center
266 // #define MAX_OBJECT_TYPES 11
272 while (!((Cur_goody_type == OBJ_ROBOT) || (Cur_goody_type == OBJ_POWERUP))) {
273 if (Cur_goody_type > GOODY_TYPE_MAX)
289 while (!((Cur_goody_type == OBJ_ROBOT) || (Cur_goody_type == OBJ_POWERUP))) {
290 if (Cur_goody_type < 0)
291 Cur_goody_type = GOODY_TYPE_MAX;
306 if (Cur_goody_type == OBJ_ROBOT) {
307 if (Cur_goody_id >= N_robot_types)
310 if (Cur_goody_id >= N_powerup_types)
321 if (Cur_goody_type == OBJ_ROBOT) {
322 if (Cur_goody_id < 0)
323 Cur_goody_id = N_robot_types-1;
325 if (Cur_goody_id < 0)
326 Cur_goody_id = N_powerup_types-1;
336 if (Cur_goody_count > GOODY_COUNT_MAX)
346 if (Cur_goody_count < 0)
347 Cur_goody_count=GOODY_COUNT_MAX;
353 int is_legal_type(int the_type)
355 return (the_type == OBJ_ROBOT) || (the_type == OBJ_CLUTTER);
358 int is_legal_type_for_this_window(int objnum)
363 return is_legal_type(Objects[objnum].type);
366 int LocalObjectSelectNextinSegment(void)
370 rval = ObjectSelectNextinSegment();
371 first_obj = Cur_object_index;
373 if (Cur_object_index != -1) {
374 while (!is_legal_type_for_this_window(Cur_object_index)) {
375 //mprintf((0, "Skipping object #%i of type %i\n", Cur_object_index, Objects[Cur_object_index].type));
376 rval = ObjectSelectNextinSegment();
377 if (first_obj == Cur_object_index)
381 Cur_goody_type = Objects[Cur_object_index].contains_type;
382 Cur_goody_id = Objects[Cur_object_index].contains_id;
383 if (Objects[Cur_object_index].contains_count < 0)
384 Objects[Cur_object_index].contains_count = 0;
385 Cur_goody_count = Objects[Cur_object_index].contains_count;
388 if (Cur_object_index != first_obj)
389 set_view_target_from_segment(Cursegp);
394 int LocalObjectSelectNextinMine(void)
398 rval = ObjectSelectNextInMine();
400 first_obj = Cur_object_index;
402 if (Cur_object_index != -1) {
403 while (!is_legal_type_for_this_window(Cur_object_index)) {
404 //mprintf((0, "Skipping object #%i of type %i\n", Cur_object_index, Objects[Cur_object_index].type));
405 ObjectSelectNextInMine();
406 if (Cur_object_index == first_obj)
410 Cur_goody_type = Objects[Cur_object_index].contains_type;
411 Cur_goody_id = Objects[Cur_object_index].contains_id;
412 if (Objects[Cur_object_index].contains_count < 0)
413 Objects[Cur_object_index].contains_count = 0;
414 Cur_goody_count = Objects[Cur_object_index].contains_count;
417 if (Cur_object_index != first_obj)
418 set_view_target_from_segment(Cursegp);
423 int LocalObjectSelectPrevinMine(void)
427 rval = ObjectSelectPrevInMine();
429 first_obj = Cur_object_index;
431 if (Cur_object_index != -1) {
432 while (!is_legal_type_for_this_window(Cur_object_index)) {
433 //mprintf((0, "Skipping object #%i of type %i\n", Cur_object_index, Objects[Cur_object_index].type));
434 ObjectSelectPrevInMine();
435 if (first_obj == Cur_object_index)
439 Cur_goody_type = Objects[Cur_object_index].contains_type;
440 Cur_goody_id = Objects[Cur_object_index].contains_id;
441 if (Objects[Cur_object_index].contains_count < 0)
442 Objects[Cur_object_index].contains_count = 0;
443 Cur_goody_count = Objects[Cur_object_index].contains_count;
446 if (Cur_object_index != first_obj)
447 set_view_target_from_segment(Cursegp);
452 int LocalObjectDelete(void)
456 rval = ObjectDelete();
458 if (Cur_object_index != -1) {
459 Cur_goody_type = Objects[Cur_object_index].contains_type;
460 Cur_goody_id = Objects[Cur_object_index].contains_id;
461 Cur_goody_count = Objects[Cur_object_index].contains_count;
464 set_view_target_from_segment(Cursegp);
469 int LocalObjectPlaceObject(void)
475 while (ObjType[Cur_robot_type] != OL_ROBOT) { // && (ObjType[Cur_robot_type] != OL_POWERUP)) {
477 if (Cur_robot_type >= N_robot_types)
481 rval = ObjectPlaceObject();
485 Objects[Cur_object_index].contains_type = Cur_goody_type;
486 Objects[Cur_object_index].contains_id = Cur_goody_id;
487 Objects[Cur_object_index].contains_count = Cur_goody_count;
489 set_view_target_from_segment(Cursegp);
494 void close_all_windows(void)
496 close_trigger_window();
498 close_centers_window();
499 hostage_close_window();
500 robot_close_window();
504 //-------------------------------------------------------------------------
505 // Called from the editor... does one instance of the robot dialog box
506 //-------------------------------------------------------------------------
507 int do_robot_dialog()
511 // Only open 1 instance of this window...
512 if ( MainWindow != NULL ) return 0;
514 // Close other windows
518 // Open a window with a quit button
519 MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
520 QuitButton = ui_add_gadget_button( MainWindow, 20, 286, 40, 32, "Done", NULL );
522 ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y-3, 25, 22, "<<", GoodyPrevType );
523 ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y-3, 25, 22, ">>", GoodyNextType );
525 ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+21, 25, 22, "<<", GoodyPrevID );
526 ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+21, 25, 22, ">>", GoodyNextID );
528 ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+45, 25, 22, "<<", GoodyPrevCount );
529 ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+45, 25, 22, ">>", GoodyNextCount );
531 InitialMode[0] = ui_add_gadget_radio( MainWindow, 6, 58, 16, 16, 0, "Hover" );
532 InitialMode[1] = ui_add_gadget_radio( MainWindow, 76, 58, 16, 16, 0, "Normal" );
533 InitialMode[2] = ui_add_gadget_radio( MainWindow, 6, 78, 16, 16, 0, "(hide)" );
534 InitialMode[3] = ui_add_gadget_radio( MainWindow, 76, 78, 16, 16, 0, "Avoid" );
535 InitialMode[4] = ui_add_gadget_radio( MainWindow, 6, 98, 16, 16, 0, "Follow" );
536 InitialMode[5] = ui_add_gadget_radio( MainWindow, 76, 98, 16, 16, 0, "Station" );
538 // The little box the robots will spin in.
539 RobotViewBox = ui_add_gadget_userbox( MainWindow,155, 5, 150, 125 );
541 // The little box the robots will spin in.
542 ContainsViewBox = ui_add_gadget_userbox( MainWindow,10, 202, 100, 80 );
544 // A bunch of buttons...
546 ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Typ", RobotPrevType );
547 ui_add_gadget_button( MainWindow,247,i,53, 26, "Typ>>", RobotNextType ); i += 29;
548 ui_add_gadget_button( MainWindow,190,i,110, 26, "Next in Seg", LocalObjectSelectNextinSegment ); i += 29;
550 ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Obj", LocalObjectSelectPrevinMine );
551 ui_add_gadget_button( MainWindow,247,i,53, 26, ">>Obj", LocalObjectSelectNextinMine ); i += 29;
553 ui_add_gadget_button( MainWindow,190,i,110, 26, "Delete", LocalObjectDelete ); i += 29;
554 ui_add_gadget_button( MainWindow,190,i,110, 26, "Create New", LocalObjectPlaceObject ); i += 29;
555 ui_add_gadget_button( MainWindow,190,i,110, 26, "Set Path", med_set_ai_path );
557 Time = timer_get_fixed_seconds();
559 old_object = -2; // Set to some dummy value so everything works ok on the first frame.
561 if ( Cur_object_index == -1 )
562 LocalObjectSelectNextinMine();
568 void robot_close_window()
570 if ( MainWindow!=NULL ) {
571 ui_close_window( MainWindow );
577 #define STRING_LENGTH 8
579 void do_robot_window()
583 int first_object_index;
585 if ( MainWindow == NULL ) return;
587 first_object_index = Cur_object_index;
588 while (!is_legal_type_for_this_window(Cur_object_index)) {
589 LocalObjectSelectNextinMine();
590 if (first_object_index == Cur_object_index) {
595 //------------------------------------------------------------
596 // Call the ui code..
597 //------------------------------------------------------------
598 ui_button_any_drawn = 0;
599 ui_window_do_gadgets(MainWindow);
601 //------------------------------------------------------------
602 // If we change objects, we need to reset the ui code for all
603 // of the radio buttons that control the ai mode. Also makes
604 // the current AI mode button be flagged as pressed down.
605 //------------------------------------------------------------
606 if (old_object != Cur_object_index ) {
607 for ( i=0; i < NUM_BOXES; i++ ) {
608 InitialMode[i]->flag = 0; // Tells ui that this button isn't checked
609 InitialMode[i]->status = 1; // Tells ui to redraw button
611 if ( Cur_object_index > -1 ) {
612 int behavior = Objects[Cur_object_index].ctype.ai_info.behavior;
613 if ( !((behavior >= MIN_BEHAVIOR) && (behavior <= MAX_BEHAVIOR))) {
614 mprintf((0, "Object #%i behavior id (%i) out of bounds, setting to AIB_NORMAL.\n", Cur_object_index, behavior));
615 Objects[Cur_object_index].ctype.ai_info.behavior = AIB_NORMAL;
616 behavior = AIB_NORMAL;
618 InitialMode[behavior - MIN_BEHAVIOR]->flag = 1; // Mark this button as checked
622 //------------------------------------------------------------
623 // If any of the radio buttons that control the mode are set, then
624 // update the cooresponding AI state.
625 //------------------------------------------------------------
626 for ( i=0; i < NUM_BOXES; i++ ) {
627 if ( InitialMode[i]->flag == 1 )
628 if (Objects[Cur_object_index].ctype.ai_info.behavior != MIN_BEHAVIOR+i) {
629 Objects[Cur_object_index].ctype.ai_info.behavior = MIN_BEHAVIOR+i; // Set the ai_state to the cooresponding radio button
630 call_init_ai_object(&Objects[Cur_object_index], MIN_BEHAVIOR+i);
634 //------------------------------------------------------------
635 // A simple frame time counter for spinning the objects...
636 //------------------------------------------------------------
637 Temp = timer_get_fixed_seconds();
638 DeltaTime = Temp - Time;
641 //------------------------------------------------------------
642 // Redraw the object in the little 64x64 box
643 //------------------------------------------------------------
644 if (Cur_object_index > -1 ) {
646 gr_set_current_canvas( RobotViewBox->canvas );
647 id = get_object_id(&Objects[Cur_object_index]);
649 draw_robot_picture(id, &angles, -1 );
651 gr_clear_canvas( CGREY );
652 angles.h += fixmul(0x1000, DeltaTime );
654 // no object, so just blank out
655 gr_set_current_canvas( RobotViewBox->canvas );
656 gr_clear_canvas( CGREY );
658 // LocalObjectSelectNextInMine();
661 //------------------------------------------------------------
662 // Redraw the contained object in the other little box
663 //------------------------------------------------------------
664 if ((Cur_object_index > -1 ) && (Cur_goody_count > 0)) {
667 gr_set_current_canvas( ContainsViewBox->canvas );
671 if (Cur_goody_type == OBJ_ROBOT)
673 else if (Cur_goody_type == OBJ_POWERUP)
674 ol_type = OL_POWERUP;
676 Int3(); // Error? Unknown goody type!
678 draw_robot_picture(id, &goody_angles, ol_type );
680 gr_clear_canvas( CGREY );
681 goody_angles.h += fixmul(0x1000, DeltaTime );
683 // no object, so just blank out
684 gr_set_current_canvas( ContainsViewBox->canvas );
685 gr_clear_canvas( CGREY );
687 // LocalObjectSelectNextInMine();
690 //------------------------------------------------------------
691 // If anything changes in the ui system, redraw all the text that
692 // identifies this robot.
693 //------------------------------------------------------------
695 if (ui_button_any_drawn || (old_object != Cur_object_index) ) {
697 char type_text[STRING_LENGTH+1],id_text[STRING_LENGTH+1];
699 if (Cur_object_index != -1) {
700 Cur_goody_type = Objects[Cur_object_index].contains_type;
701 Cur_goody_id = Objects[Cur_object_index].contains_id;
702 if (Objects[Cur_object_index].contains_count < 0)
703 Objects[Cur_object_index].contains_count = 0;
704 Cur_goody_count = Objects[Cur_object_index].contains_count;
707 ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y, " Type:");
708 ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y+24, " ID:");
709 ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y+48, "Count:");
711 for (i=0; i<STRING_LENGTH; i++)
715 switch (Cur_goody_type) {
717 strcpy(type_text, "Robot ");
718 strncpy(id_text, Robot_names[Cur_goody_id], strlen(Robot_names[Cur_goody_id]));
721 strcpy(type_text, "Powerup");
722 strncpy(id_text, Powerup_names[Cur_goody_id], strlen(Powerup_names[Cur_goody_id]));
725 editor_status("Illegal contained object type (%i), changing to powerup.", Cur_goody_type);
726 Cur_goody_type = OBJ_POWERUP;
728 strcpy(type_text, "Powerup");
729 strncpy(id_text, Powerup_names[Cur_goody_id], strlen(Powerup_names[Cur_goody_id]));
733 ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y, type_text);
734 ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y+24, id_text);
735 ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y+48, "%i", Cur_goody_count);
737 if ( Cur_object_index > -1 ) {
738 int id = Objects[Cur_object_index].id;
742 for (i=0; i<STRING_LENGTH; i++)
746 strncpy(id_text, Robot_names[id], strlen(Robot_names[id]));
748 ui_wprintf_at( MainWindow, 12, 6, "Robot: %3d ", Cur_object_index );
749 ui_wprintf_at( MainWindow, 12, 22, " Id: %3d", id);
750 ui_wprintf_at( MainWindow, 12, 38, " Name: %8s", id_text);
753 ui_wprintf_at( MainWindow, 12, 6, "Robot: none" );
754 ui_wprintf_at( MainWindow, 12, 22, " Type: ? " );
755 ui_wprintf_at( MainWindow, 12, 38, " Name: ________" );
757 Update_flags |= UF_WORLD_CHANGED;
760 if ( QuitButton->pressed || (last_keypress==KEY_ESC)) {
761 robot_close_window();
765 old_object = Cur_object_index;
768 // --------------------------------------------------------------------------------------------------------------------------
769 #define NUM_MATT_THINGS 2
773 static UI_WINDOW *MattWindow = NULL;
775 void object_close_window()
777 if ( MattWindow!=NULL ) {
778 ui_close_window( MattWindow );
785 UI_GADGET_INPUTBOX *Xtext, *Ytext, *Ztext;
787 //-------------------------------------------------------------------------
788 // Called from the editor... does one instance of the object dialog box
789 //-------------------------------------------------------------------------
790 int do_object_dialog()
792 char Xmessage[MATT_LEN], Ymessage[MATT_LEN], Zmessage[MATT_LEN];
793 object *obj=&Objects[Cur_object_index];
795 if (obj->type == OBJ_ROBOT) //don't do this for robots
798 // Only open 1 instance of this window...
799 if ( MattWindow != NULL )
804 // Open a window with a quit button
805 MattWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
806 QuitButton = ui_add_gadget_button( MattWindow, 20, 286, 40, 32, "Done", NULL );
808 QuitButton->hotkey = KEY_ENTER;
810 // These are the radio buttons for each mode
811 InitialMode[0] = ui_add_gadget_radio( MattWindow, 10, 50, 16, 16, 0, "None" );
812 InitialMode[1] = ui_add_gadget_radio( MattWindow, 80, 50, 16, 16, 0, "Spinning" );
814 InitialMode[obj->movement_type == MT_SPINNING?1:0]->flag = 1;
816 sprintf(Xmessage,"%.2f",f2fl(obj->mtype.spin_rate.x));
817 sprintf(Ymessage,"%.2f",f2fl(obj->mtype.spin_rate.y));
818 sprintf(Zmessage,"%.2f",f2fl(obj->mtype.spin_rate.z));
820 ui_wprintf_at( MattWindow, 10, 132,"&X:" );
821 Xtext = ui_add_gadget_inputbox( MattWindow, 30, 132, MATT_LEN, MATT_LEN, Xmessage );
823 ui_wprintf_at( MattWindow, 10, 162,"&Y:" );
824 Ytext = ui_add_gadget_inputbox( MattWindow, 30, 162, MATT_LEN, MATT_LEN, Ymessage );
826 ui_wprintf_at( MattWindow, 10, 192,"&Z:" );
827 Ztext = ui_add_gadget_inputbox( MattWindow, 30, 192, MATT_LEN, MATT_LEN, Zmessage );
829 ui_gadget_calc_keys(MattWindow);
831 MattWindow->keyboard_focus_gadget = (UI_GADGET *) InitialMode[0];
833 mprintf((0, "X = %08x, Y = %08x, Z = %08x\n", atoi(Xmessage), atoi(Ymessage), atoi(Zmessage)));
839 void do_object_window()
841 object *obj=&Objects[Cur_object_index];
843 if ( MattWindow == NULL ) return;
845 //------------------------------------------------------------
846 // Call the ui code..
847 //------------------------------------------------------------
848 ui_button_any_drawn = 0;
849 ui_window_do_gadgets(MattWindow);
852 if ( QuitButton->pressed || (last_keypress==KEY_ESC)) {
854 if (InitialMode[0]->flag) obj->movement_type = MT_NONE;
855 if (InitialMode[1]->flag) obj->movement_type = MT_SPINNING;
857 obj->mtype.spin_rate.x = fl2f(atof(Xtext->text));
858 obj->mtype.spin_rate.y = fl2f(atof(Ytext->text));
859 obj->mtype.spin_rate.z = fl2f(atof(Ztext->text));
861 object_close_window();
865 old_object = Cur_object_index;
868 void set_all_modes_to_hover(void)
872 for (i=0; i<=Highest_object_index; i++)
873 if (Objects[i].control_type == CT_AI)
874 Objects[i].ctype.ai_info.behavior = AIB_STILL;