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/centers.c,v $
17 * $Date: 2004-12-19 13:54:27 $
19 * Dialog box stuff for control centers, material centers, etc.
21 * $Log: not supported by cvs2svn $
22 * Revision 1.1.1.1 1999/06/14 22:02:47 donut
23 * Import of d1x 1.37 source.
25 * Revision 2.0 1995/02/27 11:35:30 john
26 * Version 2.0! No anonymous unions, Watcom 10.0, with no need
29 * Revision 1.9 1994/11/27 23:17:28 matt
30 * Made changes for new mprintf calling convention
32 * Revision 1.8 1994/10/05 22:13:46 mike
33 * Clean up Centers dialog.
35 * Revision 1.7 1994/10/03 23:39:55 mike
36 * Call fuelcen_activate instead of fuelcen_create.
38 * Revision 1.6 1994/08/02 12:16:35 mike
39 * Change materialization center functionality.
41 * Revision 1.5 1994/08/01 11:04:42 yuan
42 * New materialization centers.
44 * Revision 1.4 1994/07/22 17:19:10 yuan
45 * Working on dialog box for refuel/repair/material/control centers.
47 * Revision 1.3 1994/07/21 19:35:09 yuan
48 * Fixed #include problem
50 * Revision 1.2 1994/07/21 19:02:41 yuan
51 * *** empty log message ***
53 * Revision 1.1 1994/07/18 16:00:54 yuan
61 static char rcsid[] = "$Id: centers.c,v 1.1 2004-12-19 13:54:27 btb Exp $";
96 //-------------------------------------------------------------------------
97 // Variables for this module...
98 //-------------------------------------------------------------------------
99 static UI_WINDOW *MainWindow = NULL;
100 static UI_GADGET_BUTTON *QuitButton;
101 static UI_GADGET_RADIO *CenterFlag[MAX_CENTER_TYPES];
102 static UI_GADGET_CHECKBOX *RobotMatFlag[MAX_ROBOT_TYPES];
104 static int old_seg_num;
106 char center_names[MAX_CENTER_TYPES][CENTER_STRING_LENGTH] = {
114 //-------------------------------------------------------------------------
115 // Called from the editor... does one instance of the centers dialog box
116 //-------------------------------------------------------------------------
117 int do_centers_dialog()
121 // Only open 1 instance of this window...
122 if ( MainWindow != NULL ) return 0;
124 // Close other windows.
125 close_trigger_window();
126 hostage_close_window();
128 robot_close_window();
130 // Open a window with a quit button
131 MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
132 QuitButton = ui_add_gadget_button( MainWindow, 20, 252, 48, 40, "Done", NULL );
134 // These are the checkboxes for each door flag.
136 CenterFlag[0] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "NONE" ); i += 24;
137 CenterFlag[1] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "FuelCen" ); i += 24;
138 CenterFlag[2] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RepairCen" ); i += 24;
139 CenterFlag[3] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "ControlCen" ); i += 24;
140 CenterFlag[4] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RobotCen" ); i += 24;
142 // These are the checkboxes for each door flag.
143 for (i=0; i<N_robot_types; i++)
144 RobotMatFlag[i] = ui_add_gadget_checkbox( MainWindow, 128 + (i%2)*92, 20+(i/2)*24, 16, 16, 0, Robot_names[i]);
146 old_seg_num = -2; // Set to some dummy value so everything works ok on the first frame.
151 void close_centers_window()
153 if ( MainWindow!=NULL ) {
154 ui_close_window( MainWindow );
159 void do_centers_window()
165 if ( MainWindow == NULL ) return;
167 //------------------------------------------------------------
168 // Call the ui code..
169 //------------------------------------------------------------
170 ui_button_any_drawn = 0;
171 ui_window_do_gadgets(MainWindow);
173 //------------------------------------------------------------
174 // If we change walls, we need to reset the ui code for all
175 // of the checkboxes that control the wall flags.
176 //------------------------------------------------------------
177 if (old_seg_num != Cursegp-Segments) {
178 for ( i=0; i < MAX_CENTER_TYPES; i++ ) {
179 CenterFlag[i]->flag = 0; // Tells ui that this button isn't checked
180 CenterFlag[i]->status = 1; // Tells ui to redraw button
183 Assert(Cursegp->special < MAX_CENTER_TYPES);
184 CenterFlag[Cursegp->special]->flag = 1;
186 mprintf((0, "Cursegp->matcen_num = %i\n", Cursegp->matcen_num));
188 // Read materialization center robot bit flags
189 for ( i=0; i < N_robot_types; i++ ) {
190 RobotMatFlag[i]->status = 1; // Tells ui to redraw button
191 if (RobotCenters[Cursegp->matcen_num].robot_flags & (1 << i))
192 RobotMatFlag[i]->flag = 1; // Tells ui that this button is checked
194 RobotMatFlag[i]->flag = 0; // Tells ui that this button is not checked
199 //------------------------------------------------------------
200 // If any of the radio buttons that control the mode are set, then
201 // update the corresponding center.
202 //------------------------------------------------------------
205 for ( i=0; i < MAX_CENTER_TYPES; i++ ) {
206 if ( CenterFlag[i]->flag == 1 )
209 fuelcen_delete(Cursegp);
210 else if ( Cursegp->special != i ) {
211 fuelcen_delete(Cursegp);
213 fuelcen_activate( Cursegp, i );
218 for ( i=0; i < N_robot_types; i++ ) {
219 if ( RobotMatFlag[i]->flag == 1 ) {
220 if (!(RobotCenters[Cursegp->matcen_num].robot_flags & (1<<i) )) {
221 RobotCenters[Cursegp->matcen_num].robot_flags |= (1<<i);
222 mprintf((0,"Segment %i, matcen = %i, Robot_flags %d\n", Cursegp-Segments, Cursegp->matcen_num, RobotCenters[Cursegp->matcen_num].robot_flags));
224 } else if (RobotCenters[Cursegp->matcen_num].robot_flags & 1<<i) {
225 RobotCenters[Cursegp->matcen_num].robot_flags &= ~(1<<i);
226 mprintf((0,"Segment %i, matcen = %i, Robot_flags %d\n", Cursegp-Segments, Cursegp->matcen_num, RobotCenters[Cursegp->matcen_num].robot_flags));
230 //------------------------------------------------------------
231 // If anything changes in the ui system, redraw all the text that
232 // identifies this wall.
233 //------------------------------------------------------------
234 if (redraw_window || (old_seg_num != Cursegp-Segments ) ) {
236 // char temp_text[CENTER_STRING_LENGTH];
238 ui_wprintf_at( MainWindow, 12, 6, "Seg: %3d", Cursegp-Segments );
240 // for (i=0; i<CENTER_STRING_LENGTH; i++)
241 // temp_text[i] = ' ';
244 // Assert(Cursegp->special < MAX_CENTER_TYPES);
245 // strncpy(temp_text, Center_names[Cursegp->special], strlen(Center_names[Cursegp->special]));
246 // ui_wprintf_at( MainWindow, 12, 23, " Type: %s", temp_text );
247 Update_flags |= UF_WORLD_CHANGED;
250 if ( QuitButton->pressed || (last_keypress==KEY_ESC) ) {
251 close_centers_window();
255 old_seg_num = Cursegp-Segments;