1 /* $Id: medrobot.c,v 1.2 2004-12-19 14:52:48 btb 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.
23 static char rcsid[] = "$Id: medrobot.c,v 1.2 2004-12-19 14:52:48 btb Exp $";
61 #define NUM_BOXES 6 // Number of boxes, AI modes
65 void robot_close_window();
66 //-------------------------------------------------------------------------
67 // Variables for this module...
68 //-------------------------------------------------------------------------
69 static UI_WINDOW *MainWindow = NULL;
70 static UI_GADGET_USERBOX *RobotViewBox;
71 static UI_GADGET_USERBOX *ContainsViewBox;
72 static UI_GADGET_BUTTON *QuitButton;
73 static UI_GADGET_RADIO *InitialMode[NUM_BOXES];
75 static int old_object;
77 static vms_angvec angles={0,0,0}, goody_angles={0,0,0};
79 //-------------------------------------------------------------------------
80 // Given a pointer to an object, returns a number that cooresponds to the
81 // object id as used in the objpage stuff.
82 //-------------------------------------------------------------------------
83 int get_object_id( object * obj )
89 case OBJ_PLAYER: goal_type=OL_PLAYER; break;
90 case OBJ_ROBOT: goal_type=OL_ROBOT; break;
91 case OBJ_POWERUP: goal_type=OL_POWERUP; break;
92 case OBJ_CNTRLCEN: goal_type=OL_CONTROL_CENTER; break;
93 case OBJ_HOSTAGE: goal_type=OL_HOSTAGE; break;
94 case OBJ_CLUTTER: goal_type=OL_CLUTTER; break;
96 Int3(); // Invalid object type
100 // Find first object with the same type as this
101 // one and then add the object id to that to find
102 // the offset into the list.
104 for (i=0; i< Num_total_object_types; i++ ) {
105 if ( ObjType[i]==goal_type)
111 void call_init_ai_object(object *objp, int behavior)
115 if (behavior == AIB_STATION)
116 hide_segment = Cursegp-Segments;
118 if (Markedsegp != NULL)
119 hide_segment = Markedsegp-Segments;
121 hide_segment = Cursegp-Segments;
124 mprintf((0, "Initializing AI object with hide segment = %i\n", hide_segment));
125 init_ai_object(objp-Objects, behavior, hide_segment);
127 if (behavior == AIB_STATION) {
134 cseg = Cursegp-Segments;
136 if (Markedsegp != NULL) {
137 mseg = Markedsegp-Segments;
140 objp->ctype.ai_info.follow_path_start_seg = Cursegp-Segments;
141 objp->ctype.ai_info.follow_path_end_seg = Markedsegp-Segments;
145 //-------------------------------------------------------------------------
146 // Called when user presses "Next Type" button. This only works for polygon
147 // objects and it just selects the next polygon model for the current object.
148 //-------------------------------------------------------------------------
151 if (Cur_object_index > -1 ) {
152 if ( Objects[Cur_object_index].type == OBJ_ROBOT ) {
153 object * obj = &Objects[Cur_object_index];
155 if (obj->id >= N_robot_types )
158 //Set polygon-object-specific data
159 obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
160 obj->rtype.pobj_info.subobj_flags = 0;
162 obj->mtype.phys_info.flags |= (PF_LEVELLING);
163 obj->shields = Robot_info[obj->id].strength;
164 call_init_ai_object(obj, AIB_NORMAL);
166 Cur_robot_type = obj->id;
169 Update_flags |= UF_WORLD_CHANGED;
173 //-------------------------------------------------------------------------
174 // Called when user presses "Prev Type" button. This only works for polygon
175 // objects and it just selects the prev polygon model for the current object.
176 //-------------------------------------------------------------------------
179 if (Cur_object_index > -1 ) {
180 if ( Objects[Cur_object_index].type == OBJ_ROBOT ) {
181 object * obj = &Objects[Cur_object_index];
183 obj->id = N_robot_types-1;
187 //Set polygon-object-specific data
188 obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
189 obj->rtype.pobj_info.subobj_flags = 0;
191 obj->mtype.phys_info.flags |= (PF_LEVELLING);
192 obj->shields = Robot_info[obj->id].strength;
193 call_init_ai_object(obj, AIB_NORMAL);
195 Cur_robot_type = obj->id;
198 Update_flags |= UF_WORLD_CHANGED;
202 //-------------------------------------------------------------------------
203 // Dummy function for Mike to write.
204 //-------------------------------------------------------------------------
205 int med_set_ai_path()
207 mprintf( (0, "med-set-ai-path called -- it does nothing, paths automatically set!\n" ));
212 // #define OBJ_NONE 255 //unused object
213 // #define OBJ_WALL 0 //A wall... not really an object, but used for collisions
214 // #define OBJ_FIREBALL 1 //a fireball, part of an explosion
215 // #define OBJ_ROBOT 2 //an evil enemy
216 // #define OBJ_HOSTAGE 3 //a hostage you need to rescue
217 // #define OBJ_PLAYER 4 //the player on the console
218 // #define OBJ_WEAPON 5 //a laser, missile, etc
219 // #define OBJ_CAMERA 6 //a camera to slew around with
220 // #define OBJ_POWERUP 7 //a powerup you can pick up
221 // #define OBJ_DEBRIS 8 //a piece of robot
222 // #define OBJ_CNTRLCEN 9 //the control center
223 // #define OBJ_FLARE 10 //the control center
224 // #define MAX_OBJECT_TYPES 11
227 #define GOODY_TYPE_MAX MAX_OBJECT_TYPES
231 //#define GOODY_ID_MAX_ROBOT 6
232 //#define GOODY_ID_MAX_POWERUP 9
233 #define GOODY_COUNT_MAX 4
235 int Cur_goody_type = OBJ_POWERUP;
236 int Cur_goody_id = 0;
237 int Cur_goody_count = 0;
239 void update_goody_info(void)
241 if (Cur_object_index > -1 ) {
242 if ( Objects[Cur_object_index].type == OBJ_ROBOT ) {
243 object * obj = &Objects[Cur_object_index];
245 obj->contains_type = Cur_goody_type;
246 obj->contains_id = Cur_goody_id;
247 obj->contains_count = Cur_goody_count;
252 // #define OBJ_WALL 0 //A wall... not really an object, but used for collisions
253 // #define OBJ_FIREBALL 1 //a fireball, part of an explosion
254 // #define OBJ_ROBOT 2 //an evil enemy
255 // #define OBJ_HOSTAGE 3 //a hostage you need to rescue
256 // #define OBJ_PLAYER 4 //the player on the console
257 // #define OBJ_WEAPON 5 //a laser, missile, etc
258 // #define OBJ_CAMERA 6 //a camera to slew around with
259 // #define OBJ_POWERUP 7 //a powerup you can pick up
260 // #define OBJ_DEBRIS 8 //a piece of robot
261 // #define OBJ_CNTRLCEN 9 //the control center
262 // #define OBJ_FLARE 10 //the control center
263 // #define MAX_OBJECT_TYPES 11
269 while (!((Cur_goody_type == OBJ_ROBOT) || (Cur_goody_type == OBJ_POWERUP))) {
270 if (Cur_goody_type > GOODY_TYPE_MAX)
286 while (!((Cur_goody_type == OBJ_ROBOT) || (Cur_goody_type == OBJ_POWERUP))) {
287 if (Cur_goody_type < 0)
288 Cur_goody_type = GOODY_TYPE_MAX;
303 if (Cur_goody_type == OBJ_ROBOT) {
304 if (Cur_goody_id >= N_robot_types)
307 if (Cur_goody_id >= N_powerup_types)
318 if (Cur_goody_type == OBJ_ROBOT) {
319 if (Cur_goody_id < 0)
320 Cur_goody_id = N_robot_types-1;
322 if (Cur_goody_id < 0)
323 Cur_goody_id = N_powerup_types-1;
333 if (Cur_goody_count > GOODY_COUNT_MAX)
343 if (Cur_goody_count < 0)
344 Cur_goody_count=GOODY_COUNT_MAX;
350 int is_legal_type(int the_type)
352 return (the_type == OBJ_ROBOT) || (the_type == OBJ_CLUTTER);
355 int is_legal_type_for_this_window(int objnum)
360 return is_legal_type(Objects[objnum].type);
363 int LocalObjectSelectNextinSegment(void)
367 rval = ObjectSelectNextinSegment();
368 first_obj = Cur_object_index;
370 if (Cur_object_index != -1) {
371 while (!is_legal_type_for_this_window(Cur_object_index)) {
372 //mprintf((0, "Skipping object #%i of type %i\n", Cur_object_index, Objects[Cur_object_index].type));
373 rval = ObjectSelectNextinSegment();
374 if (first_obj == Cur_object_index)
378 Cur_goody_type = Objects[Cur_object_index].contains_type;
379 Cur_goody_id = Objects[Cur_object_index].contains_id;
380 if (Objects[Cur_object_index].contains_count < 0)
381 Objects[Cur_object_index].contains_count = 0;
382 Cur_goody_count = Objects[Cur_object_index].contains_count;
385 if (Cur_object_index != first_obj)
386 set_view_target_from_segment(Cursegp);
391 int LocalObjectSelectNextinMine(void)
395 rval = ObjectSelectNextInMine();
397 first_obj = Cur_object_index;
399 if (Cur_object_index != -1) {
400 while (!is_legal_type_for_this_window(Cur_object_index)) {
401 //mprintf((0, "Skipping object #%i of type %i\n", Cur_object_index, Objects[Cur_object_index].type));
402 ObjectSelectNextInMine();
403 if (Cur_object_index == first_obj)
407 Cur_goody_type = Objects[Cur_object_index].contains_type;
408 Cur_goody_id = Objects[Cur_object_index].contains_id;
409 if (Objects[Cur_object_index].contains_count < 0)
410 Objects[Cur_object_index].contains_count = 0;
411 Cur_goody_count = Objects[Cur_object_index].contains_count;
414 if (Cur_object_index != first_obj)
415 set_view_target_from_segment(Cursegp);
420 int LocalObjectSelectPrevinMine(void)
424 rval = ObjectSelectPrevInMine();
426 first_obj = Cur_object_index;
428 if (Cur_object_index != -1) {
429 while (!is_legal_type_for_this_window(Cur_object_index)) {
430 //mprintf((0, "Skipping object #%i of type %i\n", Cur_object_index, Objects[Cur_object_index].type));
431 ObjectSelectPrevInMine();
432 if (first_obj == Cur_object_index)
436 Cur_goody_type = Objects[Cur_object_index].contains_type;
437 Cur_goody_id = Objects[Cur_object_index].contains_id;
438 if (Objects[Cur_object_index].contains_count < 0)
439 Objects[Cur_object_index].contains_count = 0;
440 Cur_goody_count = Objects[Cur_object_index].contains_count;
443 if (Cur_object_index != first_obj)
444 set_view_target_from_segment(Cursegp);
449 int LocalObjectDelete(void)
453 rval = ObjectDelete();
455 if (Cur_object_index != -1) {
456 Cur_goody_type = Objects[Cur_object_index].contains_type;
457 Cur_goody_id = Objects[Cur_object_index].contains_id;
458 Cur_goody_count = Objects[Cur_object_index].contains_count;
461 set_view_target_from_segment(Cursegp);
466 int LocalObjectPlaceObject(void)
472 while (ObjType[Cur_robot_type] != OL_ROBOT) { // && (ObjType[Cur_robot_type] != OL_POWERUP)) {
474 if (Cur_robot_type >= N_robot_types)
478 rval = ObjectPlaceObject();
482 Objects[Cur_object_index].contains_type = Cur_goody_type;
483 Objects[Cur_object_index].contains_id = Cur_goody_id;
484 Objects[Cur_object_index].contains_count = Cur_goody_count;
486 set_view_target_from_segment(Cursegp);
491 void close_all_windows(void)
493 close_trigger_window();
495 close_centers_window();
496 hostage_close_window();
497 robot_close_window();
501 //-------------------------------------------------------------------------
502 // Called from the editor... does one instance of the robot dialog box
503 //-------------------------------------------------------------------------
504 int do_robot_dialog()
508 // Only open 1 instance of this window...
509 if ( MainWindow != NULL ) return 0;
511 // Close other windows
515 // Open a window with a quit button
516 MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
517 QuitButton = ui_add_gadget_button( MainWindow, 20, 286, 40, 32, "Done", NULL );
519 ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y-3, 25, 22, "<<", GoodyPrevType );
520 ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y-3, 25, 22, ">>", GoodyNextType );
522 ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+21, 25, 22, "<<", GoodyPrevID );
523 ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+21, 25, 22, ">>", GoodyNextID );
525 ui_add_gadget_button( MainWindow, GOODY_X+50, GOODY_Y+45, 25, 22, "<<", GoodyPrevCount );
526 ui_add_gadget_button( MainWindow, GOODY_X+80, GOODY_Y+45, 25, 22, ">>", GoodyNextCount );
528 InitialMode[0] = ui_add_gadget_radio( MainWindow, 6, 58, 16, 16, 0, "Hover" );
529 InitialMode[1] = ui_add_gadget_radio( MainWindow, 76, 58, 16, 16, 0, "Normal" );
530 InitialMode[2] = ui_add_gadget_radio( MainWindow, 6, 78, 16, 16, 0, "(hide)" );
531 InitialMode[3] = ui_add_gadget_radio( MainWindow, 76, 78, 16, 16, 0, "Avoid" );
532 InitialMode[4] = ui_add_gadget_radio( MainWindow, 6, 98, 16, 16, 0, "Follow" );
533 InitialMode[5] = ui_add_gadget_radio( MainWindow, 76, 98, 16, 16, 0, "Station" );
535 // The little box the robots will spin in.
536 RobotViewBox = ui_add_gadget_userbox( MainWindow,155, 5, 150, 125 );
538 // The little box the robots will spin in.
539 ContainsViewBox = ui_add_gadget_userbox( MainWindow,10, 202, 100, 80 );
541 // A bunch of buttons...
543 ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Typ", RobotPrevType );
544 ui_add_gadget_button( MainWindow,247,i,53, 26, "Typ>>", RobotNextType ); i += 29;
545 ui_add_gadget_button( MainWindow,190,i,110, 26, "Next in Seg", LocalObjectSelectNextinSegment ); i += 29;
547 ui_add_gadget_button( MainWindow,190,i,53, 26, "<<Obj", LocalObjectSelectPrevinMine );
548 ui_add_gadget_button( MainWindow,247,i,53, 26, ">>Obj", LocalObjectSelectNextinMine ); i += 29;
550 ui_add_gadget_button( MainWindow,190,i,110, 26, "Delete", LocalObjectDelete ); i += 29;
551 ui_add_gadget_button( MainWindow,190,i,110, 26, "Create New", LocalObjectPlaceObject ); i += 29;
552 ui_add_gadget_button( MainWindow,190,i,110, 26, "Set Path", med_set_ai_path );
554 Time = timer_get_fixed_seconds();
556 old_object = -2; // Set to some dummy value so everything works ok on the first frame.
558 if ( Cur_object_index == -1 )
559 LocalObjectSelectNextinMine();
565 void robot_close_window()
567 if ( MainWindow!=NULL ) {
568 ui_close_window( MainWindow );
574 #define STRING_LENGTH 8
576 void do_robot_window()
580 int first_object_index;
582 if ( MainWindow == NULL ) return;
584 first_object_index = Cur_object_index;
585 while (!is_legal_type_for_this_window(Cur_object_index)) {
586 LocalObjectSelectNextinMine();
587 if (first_object_index == Cur_object_index) {
592 //------------------------------------------------------------
593 // Call the ui code..
594 //------------------------------------------------------------
595 ui_button_any_drawn = 0;
596 ui_window_do_gadgets(MainWindow);
598 //------------------------------------------------------------
599 // If we change objects, we need to reset the ui code for all
600 // of the radio buttons that control the ai mode. Also makes
601 // the current AI mode button be flagged as pressed down.
602 //------------------------------------------------------------
603 if (old_object != Cur_object_index ) {
604 for ( i=0; i < NUM_BOXES; i++ ) {
605 InitialMode[i]->flag = 0; // Tells ui that this button isn't checked
606 InitialMode[i]->status = 1; // Tells ui to redraw button
608 if ( Cur_object_index > -1 ) {
609 int behavior = Objects[Cur_object_index].ctype.ai_info.behavior;
610 if ( !((behavior >= MIN_BEHAVIOR) && (behavior <= MAX_BEHAVIOR))) {
611 mprintf((0, "Object #%i behavior id (%i) out of bounds, setting to AIB_NORMAL.\n", Cur_object_index, behavior));
612 Objects[Cur_object_index].ctype.ai_info.behavior = AIB_NORMAL;
613 behavior = AIB_NORMAL;
615 InitialMode[behavior - MIN_BEHAVIOR]->flag = 1; // Mark this button as checked
619 //------------------------------------------------------------
620 // If any of the radio buttons that control the mode are set, then
621 // update the cooresponding AI state.
622 //------------------------------------------------------------
623 for ( i=0; i < NUM_BOXES; i++ ) {
624 if ( InitialMode[i]->flag == 1 )
625 if (Objects[Cur_object_index].ctype.ai_info.behavior != MIN_BEHAVIOR+i) {
626 Objects[Cur_object_index].ctype.ai_info.behavior = MIN_BEHAVIOR+i; // Set the ai_state to the cooresponding radio button
627 call_init_ai_object(&Objects[Cur_object_index], MIN_BEHAVIOR+i);
631 //------------------------------------------------------------
632 // A simple frame time counter for spinning the objects...
633 //------------------------------------------------------------
634 Temp = timer_get_fixed_seconds();
635 DeltaTime = Temp - Time;
638 //------------------------------------------------------------
639 // Redraw the object in the little 64x64 box
640 //------------------------------------------------------------
641 if (Cur_object_index > -1 ) {
643 gr_set_current_canvas( RobotViewBox->canvas );
644 id = get_object_id(&Objects[Cur_object_index]);
646 draw_robot_picture(id, &angles, -1 );
648 gr_clear_canvas( CGREY );
649 angles.h += fixmul(0x1000, DeltaTime );
651 // no object, so just blank out
652 gr_set_current_canvas( RobotViewBox->canvas );
653 gr_clear_canvas( CGREY );
655 // LocalObjectSelectNextInMine();
658 //------------------------------------------------------------
659 // Redraw the contained object in the other little box
660 //------------------------------------------------------------
661 if ((Cur_object_index > -1 ) && (Cur_goody_count > 0)) {
664 gr_set_current_canvas( ContainsViewBox->canvas );
668 if (Cur_goody_type == OBJ_ROBOT)
670 else if (Cur_goody_type == OBJ_POWERUP)
671 ol_type = OL_POWERUP;
673 Int3(); // Error? Unknown goody type!
675 draw_robot_picture(id, &goody_angles, ol_type );
677 gr_clear_canvas( CGREY );
678 goody_angles.h += fixmul(0x1000, DeltaTime );
680 // no object, so just blank out
681 gr_set_current_canvas( ContainsViewBox->canvas );
682 gr_clear_canvas( CGREY );
684 // LocalObjectSelectNextInMine();
687 //------------------------------------------------------------
688 // If anything changes in the ui system, redraw all the text that
689 // identifies this robot.
690 //------------------------------------------------------------
692 if (ui_button_any_drawn || (old_object != Cur_object_index) ) {
694 char type_text[STRING_LENGTH+1],id_text[STRING_LENGTH+1];
696 if (Cur_object_index != -1) {
697 Cur_goody_type = Objects[Cur_object_index].contains_type;
698 Cur_goody_id = Objects[Cur_object_index].contains_id;
699 if (Objects[Cur_object_index].contains_count < 0)
700 Objects[Cur_object_index].contains_count = 0;
701 Cur_goody_count = Objects[Cur_object_index].contains_count;
704 ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y, " Type:");
705 ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y+24, " ID:");
706 ui_wprintf_at( MainWindow, GOODY_X, GOODY_Y+48, "Count:");
708 for (i=0; i<STRING_LENGTH; i++)
712 switch (Cur_goody_type) {
714 strcpy(type_text, "Robot ");
715 strncpy(id_text, Robot_names[Cur_goody_id], strlen(Robot_names[Cur_goody_id]));
718 strcpy(type_text, "Powerup");
719 strncpy(id_text, Powerup_names[Cur_goody_id], strlen(Powerup_names[Cur_goody_id]));
722 editor_status("Illegal contained object type (%i), changing to powerup.", Cur_goody_type);
723 Cur_goody_type = OBJ_POWERUP;
725 strcpy(type_text, "Powerup");
726 strncpy(id_text, Powerup_names[Cur_goody_id], strlen(Powerup_names[Cur_goody_id]));
730 ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y, type_text);
731 ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y+24, id_text);
732 ui_wprintf_at( MainWindow, GOODY_X+108, GOODY_Y+48, "%i", Cur_goody_count);
734 if ( Cur_object_index > -1 ) {
735 int id = Objects[Cur_object_index].id;
739 for (i=0; i<STRING_LENGTH; i++)
743 strncpy(id_text, Robot_names[id], strlen(Robot_names[id]));
745 ui_wprintf_at( MainWindow, 12, 6, "Robot: %3d ", Cur_object_index );
746 ui_wprintf_at( MainWindow, 12, 22, " Id: %3d", id);
747 ui_wprintf_at( MainWindow, 12, 38, " Name: %8s", id_text);
750 ui_wprintf_at( MainWindow, 12, 6, "Robot: none" );
751 ui_wprintf_at( MainWindow, 12, 22, " Type: ? " );
752 ui_wprintf_at( MainWindow, 12, 38, " Name: ________" );
754 Update_flags |= UF_WORLD_CHANGED;
757 if ( QuitButton->pressed || (last_keypress==KEY_ESC)) {
758 robot_close_window();
762 old_object = Cur_object_index;
765 // --------------------------------------------------------------------------------------------------------------------------
766 #define NUM_MATT_THINGS 2
770 static UI_WINDOW *MattWindow = NULL;
772 void object_close_window()
774 if ( MattWindow!=NULL ) {
775 ui_close_window( MattWindow );
782 UI_GADGET_INPUTBOX *Xtext, *Ytext, *Ztext;
784 //-------------------------------------------------------------------------
785 // Called from the editor... does one instance of the object dialog box
786 //-------------------------------------------------------------------------
787 int do_object_dialog()
789 char Xmessage[MATT_LEN], Ymessage[MATT_LEN], Zmessage[MATT_LEN];
790 object *obj=&Objects[Cur_object_index];
792 if (obj->type == OBJ_ROBOT) //don't do this for robots
795 // Only open 1 instance of this window...
796 if ( MattWindow != NULL )
801 // Open a window with a quit button
802 MattWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
803 QuitButton = ui_add_gadget_button( MattWindow, 20, 286, 40, 32, "Done", NULL );
805 QuitButton->hotkey = KEY_ENTER;
807 // These are the radio buttons for each mode
808 InitialMode[0] = ui_add_gadget_radio( MattWindow, 10, 50, 16, 16, 0, "None" );
809 InitialMode[1] = ui_add_gadget_radio( MattWindow, 80, 50, 16, 16, 0, "Spinning" );
811 InitialMode[obj->movement_type == MT_SPINNING?1:0]->flag = 1;
813 sprintf(Xmessage,"%.2f",f2fl(obj->mtype.spin_rate.x));
814 sprintf(Ymessage,"%.2f",f2fl(obj->mtype.spin_rate.y));
815 sprintf(Zmessage,"%.2f",f2fl(obj->mtype.spin_rate.z));
817 ui_wprintf_at( MattWindow, 10, 132,"&X:" );
818 Xtext = ui_add_gadget_inputbox( MattWindow, 30, 132, MATT_LEN, MATT_LEN, Xmessage );
820 ui_wprintf_at( MattWindow, 10, 162,"&Y:" );
821 Ytext = ui_add_gadget_inputbox( MattWindow, 30, 162, MATT_LEN, MATT_LEN, Ymessage );
823 ui_wprintf_at( MattWindow, 10, 192,"&Z:" );
824 Ztext = ui_add_gadget_inputbox( MattWindow, 30, 192, MATT_LEN, MATT_LEN, Zmessage );
826 ui_gadget_calc_keys(MattWindow);
828 MattWindow->keyboard_focus_gadget = (UI_GADGET *) InitialMode[0];
830 mprintf((0, "X = %08x, Y = %08x, Z = %08x\n", atoi(Xmessage), atoi(Ymessage), atoi(Zmessage)));
836 void do_object_window()
838 object *obj=&Objects[Cur_object_index];
840 if ( MattWindow == NULL ) return;
842 //------------------------------------------------------------
843 // Call the ui code..
844 //------------------------------------------------------------
845 ui_button_any_drawn = 0;
846 ui_window_do_gadgets(MattWindow);
849 if ( QuitButton->pressed || (last_keypress==KEY_ESC)) {
851 if (InitialMode[0]->flag) obj->movement_type = MT_NONE;
852 if (InitialMode[1]->flag) obj->movement_type = MT_SPINNING;
854 obj->mtype.spin_rate.x = fl2f(atof(Xtext->text));
855 obj->mtype.spin_rate.y = fl2f(atof(Ytext->text));
856 obj->mtype.spin_rate.z = fl2f(atof(Ztext->text));
858 object_close_window();
862 old_object = Cur_object_index;
865 void set_all_modes_to_hover(void)
869 for (i=0; i<=Highest_object_index; i++)
870 if (Objects[i].control_type == CT_AI)
871 Objects[i].ctype.ai_info.behavior = AIB_STILL;