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.
56 //-------------------------------------------------------------------------
57 // Variables for this module...
58 //-------------------------------------------------------------------------
59 static UI_WINDOW *MainWindow = NULL;
60 static UI_GADGET_BUTTON *QuitButton;
61 static UI_GADGET_RADIO *CenterFlag[MAX_CENTER_TYPES];
62 static UI_GADGET_CHECKBOX *RobotMatFlag[64]; // 2 ints = 64 bits
64 static int old_seg_num;
66 char center_names[MAX_CENTER_TYPES][CENTER_STRING_LENGTH] = {
74 //-------------------------------------------------------------------------
75 // Called from the editor... does one instance of the centers dialog box
76 //-------------------------------------------------------------------------
77 int do_centers_dialog()
81 // Only open 1 instance of this window...
82 if ( MainWindow != NULL ) return 0;
84 // Close other windows.
85 close_trigger_window();
86 hostage_close_window();
90 // Open a window with a quit button
91 MainWindow = ui_open_window( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, WIN_DIALOG );
92 QuitButton = ui_add_gadget_button( MainWindow, 20, 252, 48, 40, "Done", NULL );
94 // These are the checkboxes for each door flag.
96 CenterFlag[0] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "NONE" ); i += 24;
97 CenterFlag[1] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "FuelCen" ); i += 24;
98 CenterFlag[2] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RepairCen" ); i += 24;
99 CenterFlag[3] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "ControlCen" ); i += 24;
100 CenterFlag[4] = ui_add_gadget_radio( MainWindow, 18, i, 16, 16, 0, "RobotCen" ); i += 24;
102 // These are the checkboxes for each robot flag.
103 for (i=0; i < 64; i++)
104 RobotMatFlag[i] = ui_add_gadget_checkbox( MainWindow, 128 + (i%2)*92, 20+(i/2)*24, 16, 16, 0, Robot_names[i]);
106 old_seg_num = -2; // Set to some dummy value so everything works ok on the first frame.
111 void close_centers_window()
113 if ( MainWindow!=NULL ) {
114 ui_close_window( MainWindow );
119 void do_centers_window()
126 if ( MainWindow == NULL ) return;
128 //------------------------------------------------------------
129 // Call the ui code..
130 //------------------------------------------------------------
131 ui_button_any_drawn = 0;
132 ui_window_do_gadgets(MainWindow);
134 //------------------------------------------------------------
135 // If we change walls, we need to reset the ui code for all
136 // of the checkboxes that control the wall flags.
137 //------------------------------------------------------------
138 if (old_seg_num != SEGMENT_NUMBER(Cursegp)) {
139 Assert(Curseg2p->special < MAX_CENTER_TYPES);
140 ui_radio_set_value(CenterFlag[Curseg2p->special], 1);
142 mprintf((0, "Curseg2p->matcen_num = %i\n", Curseg2p->matcen_num));
144 // Read materialization center robot bit flags
145 for (i = 0; i < 2; i++)
147 robot_index = i * 32;
148 robot_flags = RobotCenters[Curseg2p->matcen_num].robot_flags[i];
151 ui_checkbox_check(RobotMatFlag[i], robot_flags & 1);
159 //------------------------------------------------------------
160 // If any of the radio buttons that control the mode are set, then
161 // update the corresponding center.
162 //------------------------------------------------------------
165 for ( i=0; i < MAX_CENTER_TYPES; i++ ) {
166 if ( CenterFlag[i]->flag == 1 )
169 fuelcen_delete(Cursegp);
170 else if (Curseg2p->special != i)
172 fuelcen_delete(Cursegp);
174 fuelcen_activate( Cursegp, i );
179 for (i = 0; i < 2; i++)
181 robot_flags = RobotCenters[Curseg2p->matcen_num].robot_flags[i];
183 for (robot_index = 0; robot_index < 32; robot_index++)
185 if (RobotMatFlag[robot_index + i * 32]->flag == 1)
187 if (!(robot_flags & (1 << robot_index)))
189 robot_flags |= (1 << robot_index);
190 mprintf((0, "Segment %i, matcen = %i, robot_flags[%d] = %d\n", SEGMENT_NUMBER(Cursegp), Curseg2p->matcen_num, i, robot_flags));
193 else if (robot_flags & 1 << robot_index)
195 robot_flags &= ~(1 << robot_index);
196 mprintf((0, "Segment %i, matcen = %i, robot_flags[%d] = %d\n", SEGMENT_NUMBER(Cursegp), Curseg2p->matcen_num, i, robot_flags));
200 RobotCenters[Curseg2p->matcen_num].robot_flags[i] = robot_flags;
203 //------------------------------------------------------------
204 // If anything changes in the ui system, redraw all the text that
205 // identifies this wall.
206 //------------------------------------------------------------
207 if ( redraw_window || (old_seg_num != SEGMENT_NUMBER(Cursegp)) ) {
209 // char temp_text[CENTER_STRING_LENGTH];
211 ui_wprintf_at( MainWindow, 12, 6, "Seg: %3d", SEGMENT_NUMBER(Cursegp) );
213 // for (i=0; i<CENTER_STRING_LENGTH; i++)
214 // temp_text[i] = ' ';
217 // Assert(Curseg2p->special < MAX_CENTER_TYPES);
218 // strncpy(temp_text, Center_names[Curseg2p->special], strlen(Center_names[Curseg2p->special]));
219 // ui_wprintf_at( MainWindow, 12, 23, " Type: %s", temp_text );
220 Update_flags |= UF_WORLD_CHANGED;
223 if ( QuitButton->pressed || (last_keypress==KEY_ESC) ) {
224 close_centers_window();
228 old_seg_num = SEGMENT_NUMBER(Cursegp);