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.
16 * Dialog box stuff for control centers, material centers, etc.
38 //-------------------------------------------------------------------------
39 // Variables for this module...
40 //-------------------------------------------------------------------------
41 static UI_WINDOW *MainWindow = NULL;
42 static UI_GADGET_BUTTON *QuitButton;
43 static UI_GADGET_RADIO *CenterFlag[MAX_CENTER_TYPES];
44 static UI_GADGET_CHECKBOX *RobotMatFlag[64]; // 2 ints = 64 bits
46 static int old_seg_num;
48 char center_names[MAX_CENTER_TYPES][CENTER_STRING_LENGTH] = {
56 //-------------------------------------------------------------------------
57 // Called from the editor... does one instance of the centers dialog box
58 //-------------------------------------------------------------------------
59 int do_centers_dialog()
63 // Only open 1 instance of this window...
64 if ( MainWindow != NULL ) return 0;
66 // Close other windows.
67 close_trigger_window();
68 hostage_close_window();
72 // Open a window with a quit button
73 MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
74 QuitButton = ui_add_gadget_button( MainWindow, 20, 252, 48, 40, "Done", NULL );
76 // These are the checkboxes for each door flag.
78 CenterFlag[0] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "NONE" ); i += 24;
79 CenterFlag[1] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "FuelCen" ); i += 24;
80 CenterFlag[2] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RepairCen" ); i += 24;
81 CenterFlag[3] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "ControlCen" ); i += 24;
82 CenterFlag[4] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RobotCen" ); i += 24;
84 // These are the checkboxes for each robot flag.
85 for (i=0; i < 64; i++)
86 RobotMatFlag[i] = ui_add_gadget_checkbox( MainWindow, 128 + (i%2)*92, 20+(i/2)*24, 16, 16, 0, Robot_names[i]);
88 old_seg_num = -2; // Set to some dummy value so everything works ok on the first frame.
93 void close_centers_window()
95 if ( MainWindow!=NULL ) {
96 ui_close_window( MainWindow );
101 void do_centers_window()
108 if ( MainWindow == NULL ) return;
110 //------------------------------------------------------------
111 // Call the ui code..
112 //------------------------------------------------------------
113 ui_button_any_drawn = 0;
114 ui_window_do_gadgets(MainWindow);
116 //------------------------------------------------------------
117 // If we change walls, we need to reset the ui code for all
118 // of the checkboxes that control the wall flags.
119 //------------------------------------------------------------
120 if (old_seg_num != SEGMENT_NUMBER(Cursegp)) {
121 Assert(Curseg2p->special < MAX_CENTER_TYPES);
122 ui_radio_set_value(CenterFlag[Curseg2p->special], 1);
124 mprintf((0, "Curseg2p->matcen_num = %i\n", Curseg2p->matcen_num));
126 // Read materialization center robot bit flags
127 for (i = 0; i < 2; i++)
129 robot_index = i * 32;
130 robot_flags = RobotCenters[Curseg2p->matcen_num].robot_flags[i];
133 ui_checkbox_check(RobotMatFlag[i], robot_flags & 1);
141 //------------------------------------------------------------
142 // If any of the radio buttons that control the mode are set, then
143 // update the corresponding center.
144 //------------------------------------------------------------
147 for ( i=0; i < MAX_CENTER_TYPES; i++ ) {
148 if ( CenterFlag[i]->flag == 1 )
151 fuelcen_delete(Cursegp);
152 else if (Curseg2p->special != i)
154 fuelcen_delete(Cursegp);
156 fuelcen_activate( Cursegp, i );
161 for (i = 0; i < 2; i++)
163 robot_flags = RobotCenters[Curseg2p->matcen_num].robot_flags[i];
165 for (robot_index = 0; robot_index < 32; robot_index++)
167 if (RobotMatFlag[robot_index + i * 32]->flag == 1)
169 if (!(robot_flags & (1 << robot_index)))
171 robot_flags |= (1 << robot_index);
172 mprintf((0, "Segment %i, matcen = %i, robot_flags[%d] = %d\n", SEGMENT_NUMBER(Cursegp), Curseg2p->matcen_num, i, robot_flags));
175 else if (robot_flags & 1 << robot_index)
177 robot_flags &= ~(1 << robot_index);
178 mprintf((0, "Segment %i, matcen = %i, robot_flags[%d] = %d\n", SEGMENT_NUMBER(Cursegp), Curseg2p->matcen_num, i, robot_flags));
182 RobotCenters[Curseg2p->matcen_num].robot_flags[i] = robot_flags;
185 //------------------------------------------------------------
186 // If anything changes in the ui system, redraw all the text that
187 // identifies this wall.
188 //------------------------------------------------------------
189 if ( redraw_window || (old_seg_num != SEGMENT_NUMBER(Cursegp)) ) {
191 // char temp_text[CENTER_STRING_LENGTH];
193 ui_wprintf_at( MainWindow, 12, 6, "Seg: %3d", SEGMENT_NUMBER(Cursegp) );
195 // for (i=0; i<CENTER_STRING_LENGTH; i++)
196 // temp_text[i] = ' ';
199 // Assert(Curseg2p->special < MAX_CENTER_TYPES);
200 // strncpy(temp_text, Center_names[Curseg2p->special], strlen(Center_names[Curseg2p->special]));
201 // ui_wprintf_at( MainWindow, 12, 23, " Type: %s", temp_text );
202 Update_flags |= UF_WORLD_CHANGED;
205 if ( QuitButton->pressed || (last_keypress==KEY_ESC) ) {
206 close_centers_window();
210 old_seg_num = SEGMENT_NUMBER(Cursegp);