]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/surface_quake2/surfaceflagsdialog_quake2.cpp
uncrustify! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / plugins / surface_quake2 / surfaceflagsdialog_quake2.cpp
1 /*
2    Copyright (C) 1999-2007 id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #include <gtk/gtk.h>
23 #include <gdk/gdkkeysyms.h>
24 #include <glib/gi18n.h>
25
26 #include "surfdlg_plugin.h"
27
28 #include "surfaceflagsdialog_quake2.h"
29
30 GtkWidget *notebook1;
31
32 GtkWidget *surface_lightbutton;
33 GtkWidget *surface_slickbutton;
34 GtkWidget *surface_skybutton;
35 GtkWidget *surface_warpbutton;
36 GtkWidget *surface_trans33button;
37 GtkWidget *surface_trans66button;
38 GtkWidget *surface_flowingbutton;
39 GtkWidget *surface_nodrawbutton;
40 GtkWidget *surface_hintbutton;
41 GtkWidget *surface_skipbutton;
42
43 GtkWidget *content_solidbutton;
44 GtkWidget *content_windowbutton;
45 GtkWidget *content_auxbutton;
46 GtkWidget *content_lavabutton;
47 GtkWidget *content_slimebutton;
48 GtkWidget *content_waterbutton;
49 GtkWidget *content_mistbutton;
50 GtkWidget *content_areaportalbutton;
51 GtkWidget *content_playerclipbutton;
52 GtkWidget *content_monsterclipbutton;
53 GtkWidget *content_current0button;
54 GtkWidget *content_current90button;
55 GtkWidget *content_current180button;
56 GtkWidget *content_current270button;
57 GtkWidget *content_currentUPbutton;
58 GtkWidget *content_currentDOWNbutton;
59 GtkWidget *content_originbutton;
60 GtkWidget *content_detailbutton;
61 GtkWidget *content_translucentbutton;
62 GtkWidget *content_ladderbutton;
63
64 GtkWidget *surfacebutton;
65 GtkWidget *contentbutton;
66
67 GtkWidget *value_entry;
68 gboolean setup_buttons = TRUE;
69
70 int working_surface_flags;
71 int surface_mask;
72 int working_content_flags;
73 int content_mask;
74 int working_value;
75
76 inline void set_inconsistent( GtkWidget *toggle_button ){
77         gtk_toggle_button_set_inconsistent( GTK_TOGGLE_BUTTON( toggle_button ), TRUE );
78 }
79
80 inline void clear_inconsistent( GtkWidget *toggle_button ){
81         if ( gtk_toggle_button_get_inconsistent( GTK_TOGGLE_BUTTON( toggle_button ) ) ) {
82                 gtk_toggle_button_set_inconsistent( GTK_TOGGLE_BUTTON( toggle_button ), FALSE );
83         }
84 }
85
86 void clear_all_inconsistent( void ){
87         clear_inconsistent( surface_lightbutton );
88         clear_inconsistent( surface_slickbutton );
89         clear_inconsistent( surface_skybutton );
90         clear_inconsistent( surface_warpbutton );
91         clear_inconsistent( surface_trans33button );
92         clear_inconsistent( surface_trans66button );
93         clear_inconsistent( surface_flowingbutton );
94         clear_inconsistent( surface_nodrawbutton );
95         clear_inconsistent( surface_hintbutton );
96         clear_inconsistent( surface_skipbutton );
97
98         clear_inconsistent( content_solidbutton );
99         clear_inconsistent( content_windowbutton );
100         clear_inconsistent( content_auxbutton );
101         clear_inconsistent( content_lavabutton );
102         clear_inconsistent( content_slimebutton );
103         clear_inconsistent( content_waterbutton );
104         clear_inconsistent( content_mistbutton );
105         clear_inconsistent( content_areaportalbutton );
106         clear_inconsistent( content_playerclipbutton );
107         clear_inconsistent( content_monsterclipbutton );
108         clear_inconsistent( content_current0button );
109         clear_inconsistent( content_current90button );
110         clear_inconsistent( content_current180button );
111         clear_inconsistent( content_current270button );
112         clear_inconsistent( content_currentUPbutton );
113         clear_inconsistent( content_currentDOWNbutton );
114         clear_inconsistent( content_originbutton );
115         clear_inconsistent( content_detailbutton );
116         clear_inconsistent( content_translucentbutton );
117         clear_inconsistent( content_ladderbutton );
118 }
119
120 void clear_all_buttons_and_values(){
121         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_lightbutton ), FALSE );
122         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_slickbutton ), FALSE );
123         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skybutton ), FALSE );
124         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_warpbutton ), FALSE );
125         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans33button ), FALSE );
126         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans66button ), FALSE );
127         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_flowingbutton ), FALSE );
128         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_nodrawbutton ), FALSE );
129         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_hintbutton ), FALSE );
130         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skipbutton ), FALSE );
131
132         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_solidbutton ), FALSE );
133         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_windowbutton ), FALSE );
134         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_auxbutton ), FALSE );
135         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_lavabutton ), FALSE );
136         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_slimebutton ), FALSE );
137         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_waterbutton ), FALSE );
138         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_mistbutton ), FALSE );
139         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_areaportalbutton ), FALSE );
140         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_playerclipbutton ), FALSE );
141         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_monsterclipbutton ), FALSE );
142         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current0button ), FALSE );
143         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current90button ), FALSE );
144         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current180button ), FALSE );
145         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current270button ), FALSE );
146         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentUPbutton ), FALSE );
147         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentDOWNbutton ), FALSE );
148         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_originbutton ), FALSE );
149         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_detailbutton ), FALSE );
150         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_translucentbutton ), FALSE );
151         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_ladderbutton ), FALSE );
152
153         gtk_entry_set_text( (GtkEntry *)value_entry, "" );
154 }
155
156 void SetFlagButtons_Quake2( texdef_to_face_t *texdef_face_list, bool b_isListEmpty ){
157         int contents = 0;
158         int flags = 0;
159         int value = 0;
160         int diff_contents = 0;
161         int diff_flags = 0;
162         gboolean diff_value = FALSE;
163         char tex_buff[11];
164         texdef_t* tmp_texdef;
165         texdef_to_face_t* temp_texdef_face_list;
166
167
168         setup_buttons = TRUE;
169         working_surface_flags = 0;
170         surface_mask = 0;
171         working_content_flags = 0;
172         content_mask = 0;
173         working_value = 0;
174
175         if ( !b_isListEmpty ) {
176                 tmp_texdef = &texdef_face_list->texdef;
177                 contents = tmp_texdef->contents;
178                 flags = tmp_texdef->flags;
179                 value = tmp_texdef->value;
180
181                 Sys_Printf( "Surface: %d\tContents: %d\tValue: %d\ttmp_texdef\n",tmp_texdef->flags,tmp_texdef->contents,tmp_texdef->value );
182                 Sys_Printf( "Surface: %d\tContents: %d\tValue: %d\n",flags,contents,value );
183
184                 for ( temp_texdef_face_list = texdef_face_list->next; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
185                 {
186                         tmp_texdef = &temp_texdef_face_list->texdef;
187                         diff_contents |= contents ^ tmp_texdef->contents; // Figure out which buttons are inconsistent
188                         diff_flags |= flags ^ tmp_texdef->flags;
189                         if ( tmp_texdef->value != value ) {
190                                 diff_value = TRUE;
191                         }
192
193                         Sys_Printf( "Surface: %d\tContents: %d\tValue: %d\ttmp_texdef\n",tmp_texdef->flags,tmp_texdef->contents,tmp_texdef->value );
194                         Sys_Printf( "Surface: %d\tContents: %d\tValue: %d\n",flags,contents,value );
195
196                 }
197         }
198
199
200
201         clear_all_inconsistent();
202
203         // If no faces/brushes are selected, clear everything and bail
204         if ( b_isListEmpty ) {
205                 clear_all_buttons_and_values();
206                 setup_buttons = FALSE;
207                 return;
208         }
209
210         // Set surface buttons to reflect brush/face flags, contents, and values
211         if ( diff_flags & QUAKE2_SURF_LIGHT ) {
212                 set_inconsistent( surface_lightbutton );
213         }
214         else if ( flags & QUAKE2_SURF_LIGHT ) {
215                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_lightbutton ), TRUE );
216         }
217         else{
218                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_lightbutton ), FALSE );
219         }
220
221         if ( diff_flags & QUAKE2_SURF_SLICK ) {
222                 set_inconsistent( surface_slickbutton );
223         }
224         else if ( flags & QUAKE2_SURF_SLICK ) {
225                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_slickbutton ), TRUE );
226         }
227         else{
228                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_slickbutton ), FALSE );
229         }
230
231         if ( diff_flags & QUAKE2_SURF_SKY ) {
232                 set_inconsistent( surface_skybutton );
233         }
234         else if ( flags & QUAKE2_SURF_SKY ) {
235                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skybutton ), TRUE );
236         }
237         else{
238                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skybutton ), FALSE );
239         }
240
241         if ( diff_flags & QUAKE2_SURF_WARP ) {
242                 set_inconsistent( surface_warpbutton );
243         }
244         else if ( flags & QUAKE2_SURF_WARP ) {
245                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_warpbutton ), TRUE );
246         }
247         else{
248                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_warpbutton ), FALSE );
249         }
250
251         if ( diff_flags & QUAKE2_SURF_TRANS33 ) {
252                 set_inconsistent( surface_trans33button );
253         }
254         else if ( flags & QUAKE2_SURF_TRANS33 ) {
255                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans33button ), TRUE );
256         }
257         else{
258                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans33button ), FALSE );
259         }
260
261         if ( diff_flags & QUAKE2_SURF_TRANS66 ) {
262                 set_inconsistent( surface_trans66button );
263         }
264         else if ( flags & QUAKE2_SURF_TRANS66 ) {
265                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans66button ), TRUE );
266         }
267         else{
268                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans66button ), FALSE );
269         }
270
271         if ( diff_flags & QUAKE2_SURF_FLOWING ) {
272                 set_inconsistent( surface_flowingbutton );
273         }
274         else if ( flags & QUAKE2_SURF_FLOWING ) {
275                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_flowingbutton ), TRUE );
276         }
277         else{
278                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_flowingbutton ), FALSE );
279         }
280
281         if ( diff_flags & QUAKE2_SURF_NODRAW ) {
282                 set_inconsistent( surface_nodrawbutton );
283         }
284         else if ( flags & QUAKE2_SURF_NODRAW ) {
285                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_nodrawbutton ), TRUE );
286         }
287         else{
288                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_nodrawbutton ), FALSE );
289         }
290
291         if ( diff_flags & QUAKE2_SURF_HINT ) {
292                 set_inconsistent( surface_hintbutton );
293         }
294         else if ( flags & QUAKE2_SURF_HINT ) {
295                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_hintbutton ), TRUE );
296         }
297         else{
298                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_hintbutton ), FALSE );
299         }
300
301         if ( diff_flags & QUAKE2_SURF_SKIP ) {
302                 set_inconsistent( surface_skipbutton );
303         }
304         else if ( flags & QUAKE2_SURF_SKIP ) {
305                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skipbutton ), TRUE );
306         }
307         else{
308                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skipbutton ), FALSE );
309         }
310
311         // Set content buttons to reflect brush values
312         if ( diff_contents & QUAKE2_CONTENTS_SOLID ) {
313                 set_inconsistent( content_solidbutton );
314         }
315         else if ( contents & QUAKE2_CONTENTS_SOLID ) {
316                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_solidbutton ), TRUE );
317         }
318         else{
319                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_solidbutton ), FALSE );
320         }
321
322         if ( diff_contents & QUAKE2_CONTENTS_WINDOW ) {
323                 set_inconsistent( content_windowbutton );
324         }
325         else if ( contents & QUAKE2_CONTENTS_WINDOW ) {
326                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_windowbutton ), TRUE );
327         }
328         else{
329                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_windowbutton ), FALSE );
330         }
331
332         if ( diff_contents & QUAKE2_CONTENTS_AUX ) {
333                 set_inconsistent( content_auxbutton );
334         }
335         else if ( contents & QUAKE2_CONTENTS_AUX ) {
336                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_auxbutton ), TRUE );
337         }
338         else{
339                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_auxbutton ), FALSE );
340         }
341
342         if ( diff_contents & QUAKE2_CONTENTS_LAVA ) {
343                 set_inconsistent( content_lavabutton );
344         }
345         else if ( contents & QUAKE2_CONTENTS_LAVA ) {
346                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_lavabutton ), TRUE );
347         }
348         else{
349                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_lavabutton ), FALSE );
350         }
351
352         if ( diff_contents & QUAKE2_CONTENTS_SLIME ) {
353                 set_inconsistent( content_slimebutton );
354         }
355         else if ( contents & QUAKE2_CONTENTS_SLIME ) {
356                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_slimebutton ), TRUE );
357         }
358         else{
359                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_slimebutton ), FALSE );
360         }
361
362         if ( diff_contents & QUAKE2_CONTENTS_WATER ) {
363                 set_inconsistent( content_waterbutton );
364         }
365         else if ( contents & QUAKE2_CONTENTS_WATER ) {
366                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_waterbutton ), TRUE );
367         }
368         else{
369                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_waterbutton ), FALSE );
370         }
371
372         if ( diff_contents & QUAKE2_CONTENTS_MIST ) {
373                 set_inconsistent( content_mistbutton );
374         }
375         else if ( contents & QUAKE2_CONTENTS_MIST ) {
376                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_mistbutton ), TRUE );
377         }
378         else{
379                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_mistbutton ), FALSE );
380         }
381
382         if ( diff_contents & QUAKE2_CONTENTS_AREAPORTAL ) {
383                 set_inconsistent( content_areaportalbutton );
384         }
385         else if ( contents & QUAKE2_CONTENTS_AREAPORTAL ) {
386                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_areaportalbutton ), TRUE );
387         }
388         else{
389                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_areaportalbutton ), FALSE );
390         }
391
392         if ( diff_contents & QUAKE2_CONTENTS_PLAYERCLIP ) {
393                 set_inconsistent( content_playerclipbutton );
394         }
395         else if ( contents & QUAKE2_CONTENTS_PLAYERCLIP ) {
396                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_playerclipbutton ), TRUE );
397         }
398         else{
399                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_playerclipbutton ), FALSE );
400         }
401
402         if ( diff_contents & QUAKE2_CONTENTS_MONSTERCLIP ) {
403                 set_inconsistent( content_monsterclipbutton );
404         }
405         else if ( contents & QUAKE2_CONTENTS_MONSTERCLIP ) {
406                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_monsterclipbutton ), TRUE );
407         }
408         else{
409                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_monsterclipbutton ), FALSE );
410         }
411
412         if ( diff_contents & QUAKE2_CONTENTS_CURRENT_0 ) {
413                 set_inconsistent( content_current0button );
414         }
415         else if ( contents & QUAKE2_CONTENTS_CURRENT_0 ) {
416                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current0button ), TRUE );
417         }
418         else{
419                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current0button ), FALSE );
420         }
421
422         if ( diff_contents & QUAKE2_CONTENTS_CURRENT_90 ) {
423                 set_inconsistent( content_current90button );
424         }
425         else if ( contents & QUAKE2_CONTENTS_CURRENT_90 ) {
426                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current90button ), TRUE );
427         }
428         else{
429                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current90button ), FALSE );
430         }
431
432         if ( diff_contents & QUAKE2_CONTENTS_CURRENT_180 ) {
433                 set_inconsistent( content_current180button );
434         }
435         else if ( contents & QUAKE2_CONTENTS_CURRENT_180 ) {
436                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current180button ), TRUE );
437         }
438         else{
439                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current180button ), FALSE );
440         }
441
442         if ( diff_contents & QUAKE2_CONTENTS_CURRENT_270 ) {
443                 set_inconsistent( content_current270button );
444         }
445         else if ( contents & QUAKE2_CONTENTS_CURRENT_270 ) {
446                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current270button ), TRUE );
447         }
448         else{
449                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current270button ), FALSE );
450         }
451
452         if ( diff_contents & QUAKE2_CONTENTS_CURRENT_UP ) {
453                 set_inconsistent( content_currentUPbutton );
454         }
455         else if ( contents & QUAKE2_CONTENTS_CURRENT_UP ) {
456                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentUPbutton ), TRUE );
457         }
458         else{
459                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentUPbutton ), FALSE );
460         }
461
462         if ( diff_contents & QUAKE2_CONTENTS_CURRENT_DOWN ) {
463                 set_inconsistent( content_currentDOWNbutton );
464         }
465         else if ( contents & QUAKE2_CONTENTS_CURRENT_DOWN ) {
466                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentDOWNbutton ), TRUE );
467         }
468         else{
469                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentDOWNbutton ), FALSE );
470         }
471
472         if ( diff_contents & QUAKE2_CONTENTS_ORIGIN ) {
473                 set_inconsistent( content_originbutton );
474         }
475         else if ( contents & QUAKE2_CONTENTS_ORIGIN ) {
476                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_originbutton ), TRUE );
477         }
478         else{
479                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_originbutton ), FALSE );
480         }
481
482         if ( diff_contents & QUAKE2_CONTENTS_DETAIL ) {
483                 set_inconsistent( content_detailbutton );
484         }
485         else if ( contents & QUAKE2_CONTENTS_DETAIL ) {
486                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_detailbutton ), TRUE );
487         }
488         else{
489                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_detailbutton ), FALSE );
490         }
491
492         if ( diff_contents & QUAKE2_CONTENTS_TRANSLUCENT ) {
493                 set_inconsistent( content_translucentbutton );
494         }
495         else if ( contents & QUAKE2_CONTENTS_TRANSLUCENT ) {
496                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_translucentbutton ), TRUE );
497         }
498         else{
499                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_translucentbutton ), FALSE );
500         }
501
502         if ( diff_contents & QUAKE2_CONTENTS_LADDER ) {
503                 set_inconsistent( content_ladderbutton );
504         }
505         else if ( contents & QUAKE2_CONTENTS_LADDER ) {
506                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_ladderbutton ), TRUE );
507         }
508         else{
509                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_ladderbutton ), FALSE );
510         }
511
512         // Set Value
513         if ( diff_value ) {
514                 gtk_entry_set_text( (GtkEntry *)value_entry, "" );
515         }
516         else
517         {
518                 working_value = value;
519                 sprintf( tex_buff, "%d", value );
520                 gtk_entry_set_text( (GtkEntry *)value_entry, tex_buff );
521         }
522
523         setup_buttons = FALSE;
524 }
525
526 void SetChangeInFlags_Face_Quake2( texdef_to_face_t *texdef_face_list ){
527         texdef_to_face_t *temp_texdef_face_list;
528         texdef_t *tmp_texdef;
529
530         for ( temp_texdef_face_list = texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
531         {
532                 tmp_texdef = &temp_texdef_face_list->texdef;
533                 tmp_texdef->flags = ( tmp_texdef->flags & ~surface_mask ) | working_surface_flags;
534                 tmp_texdef->contents = ( tmp_texdef->contents & ~content_mask ) | working_content_flags;
535                 tmp_texdef->value = working_value;
536                 Sys_Printf( "content_flag: %d     content_mask: %d\n",working_content_flags,content_mask );
537                 Sys_Printf( "content: %d\n",tmp_texdef->contents );
538         }
539 }
540
541 inline void change_surfaceflag( GtkWidget *togglebutton, int sur_flag, gboolean change_flag_to ){
542
543         if ( !setup_buttons ) { // If we're setting up the buttons, we really don't need to
544                                    // set flags that are already set
545
546                 if ( gtk_toggle_button_get_inconsistent( GTK_TOGGLE_BUTTON( togglebutton ) ) ) { // Clear out inconsistent, if set
547                         clear_inconsistent( GTK_WIDGET( togglebutton ) );
548                 }
549
550                 surface_mask |= sur_flag;
551
552                 if ( change_flag_to ) {
553                         working_surface_flags |= sur_flag;
554                 }
555                 else{
556                         working_surface_flags &= ~sur_flag;
557                 }
558         }
559 }
560
561 inline void change_contentflag( GtkWidget *togglebutton, int content_flag, gboolean change_flag_to ){
562
563         if ( ( !setup_buttons ) ) { // If we're setting up the buttons, we really don't need to
564                                        // set flags that are already set
565
566                 if ( gtk_toggle_button_get_inconsistent( GTK_TOGGLE_BUTTON( togglebutton ) ) ) {
567                         clear_inconsistent( togglebutton );
568                 }
569                 //if (g_ptrSelectedFaces.GetSize() == 0)  // Only changing content flags on whole brushes, not faces.
570                 //{
571                 content_mask |= content_flag;
572
573                 if ( change_flag_to ) {
574                         working_content_flags |= content_flag;
575                 }
576                 else{
577                         working_content_flags &= ~content_flag;
578                 }
579                 //}
580                 Sys_Printf( "content_flag: %d     content_mask: %d\n",content_flag,content_mask );
581         }
582 }
583
584 // Surface Flags Callbacks
585 void
586 on_surface_lightbutton_toggled( GtkToggleButton *togglebutton,
587                                                                 gpointer user_data ){
588         change_surfaceflag( surface_lightbutton, QUAKE2_SURF_LIGHT, ( GTK_TOGGLE_BUTTON( surface_lightbutton )->active ) );
589
590 }
591
592 void
593 on_surface_slickbutton_toggled( GtkToggleButton *togglebutton,
594                                                                 gpointer user_data ){
595         change_surfaceflag( surface_slickbutton, QUAKE2_SURF_SLICK, ( GTK_TOGGLE_BUTTON( surface_slickbutton )->active ) );
596
597 }
598
599 void
600 on_surface_skybutton_toggled( GtkToggleButton *togglebutton,
601                                                           gpointer user_data ){
602         change_surfaceflag( surface_skybutton, QUAKE2_SURF_SKY, ( GTK_TOGGLE_BUTTON( surface_skybutton )->active ) );
603 }
604
605 void
606 on_surface_warpbutton_toggled( GtkToggleButton *togglebutton,
607                                                            gpointer user_data ){
608         change_surfaceflag( surface_warpbutton, QUAKE2_SURF_WARP, ( GTK_TOGGLE_BUTTON( surface_warpbutton )->active ) );
609 }
610
611 void
612 on_surface_trans33button_toggled( GtkToggleButton *togglebutton,
613                                                                   gpointer user_data ){
614         change_surfaceflag( surface_trans33button, QUAKE2_SURF_TRANS33, ( GTK_TOGGLE_BUTTON( surface_trans33button )->active ) );
615 }
616
617 void
618 on_surface_trans66button_toggled( GtkToggleButton *togglebutton,
619                                                                   gpointer user_data ){
620         change_surfaceflag( surface_trans66button, QUAKE2_SURF_TRANS66, ( GTK_TOGGLE_BUTTON( surface_trans66button )->active ) );
621 }
622
623 void
624 on_surface_flowingbutton_toggled( GtkToggleButton *togglebutton,
625                                                                   gpointer user_data ){
626         change_surfaceflag( surface_flowingbutton, QUAKE2_SURF_FLOWING, ( GTK_TOGGLE_BUTTON( surface_flowingbutton )->active ) );
627 }
628
629 void
630 on_surface_nodrawbutton_toggled( GtkToggleButton *togglebutton,
631                                                                  gpointer user_data ){
632         change_surfaceflag( surface_nodrawbutton, QUAKE2_SURF_NODRAW, ( GTK_TOGGLE_BUTTON( surface_nodrawbutton )->active ) );
633 }
634
635 void
636 on_surface_hintbutton_toggled( GtkToggleButton *togglebutton,
637                                                            gpointer user_data ){
638         change_surfaceflag( surface_hintbutton, QUAKE2_SURF_HINT, ( GTK_TOGGLE_BUTTON( surface_hintbutton )->active ) );
639 }
640
641 void
642 on_surface_skipbutton_toggled( GtkToggleButton *togglebutton,
643                                                            gpointer user_data ){
644         change_surfaceflag( surface_skipbutton, QUAKE2_SURF_SKIP, ( GTK_TOGGLE_BUTTON( surface_skipbutton )->active ) );
645 }
646
647 // Content Flags Callbacks
648 void
649 on_content_solidbutton_toggled( GtkToggleButton *togglebutton,
650                                                                 gpointer user_data ){
651         change_contentflag( content_solidbutton, QUAKE2_CONTENTS_SOLID, ( GTK_TOGGLE_BUTTON( content_solidbutton )->active ) );
652 }
653
654 void
655 on_content_windowbutton_toggled( GtkToggleButton *togglebutton,
656                                                                  gpointer user_data ){
657         change_contentflag( content_windowbutton, QUAKE2_CONTENTS_WINDOW, ( GTK_TOGGLE_BUTTON( content_windowbutton )->active ) );
658 }
659
660 void
661 on_content_auxbutton_toggled( GtkToggleButton *togglebutton,
662                                                           gpointer user_data ){
663         change_contentflag( content_auxbutton, QUAKE2_CONTENTS_AUX, ( GTK_TOGGLE_BUTTON( content_auxbutton )->active ) );
664 }
665
666 void
667 on_content_lavabutton_toggled( GtkToggleButton *togglebutton,
668                                                            gpointer user_data ){
669         change_contentflag( content_lavabutton, QUAKE2_CONTENTS_LAVA, ( GTK_TOGGLE_BUTTON( content_lavabutton )->active ) );
670 }
671
672 void
673 on_content_slimebutton_toggled( GtkToggleButton *togglebutton,
674                                                                 gpointer user_data ){
675         change_contentflag( content_slimebutton, QUAKE2_CONTENTS_SLIME, ( GTK_TOGGLE_BUTTON( content_slimebutton )->active ) );
676 }
677
678 void
679 on_content_waterbutton_toggled( GtkToggleButton *togglebutton,
680                                                                 gpointer user_data ){
681         change_contentflag( content_waterbutton, QUAKE2_CONTENTS_WATER, ( GTK_TOGGLE_BUTTON( content_waterbutton )->active ) );
682 }
683
684 void
685 on_content_mistbutton_toggled( GtkToggleButton *togglebutton,
686                                                            gpointer user_data ){
687         change_contentflag( content_mistbutton, QUAKE2_CONTENTS_MIST, ( GTK_TOGGLE_BUTTON( content_mistbutton )->active ) );
688 }
689
690 void
691 on_content_areaportalbutton_toggled( GtkToggleButton *togglebutton,
692                                                                          gpointer user_data ){
693         change_contentflag( content_areaportalbutton, QUAKE2_CONTENTS_AREAPORTAL, ( GTK_TOGGLE_BUTTON( content_areaportalbutton )->active ) );
694 }
695
696 void
697 on_content_playerclipbutton_toggled( GtkToggleButton *togglebutton,
698                                                                          gpointer user_data ){
699         change_contentflag( content_playerclipbutton, QUAKE2_CONTENTS_PLAYERCLIP, ( GTK_TOGGLE_BUTTON( content_playerclipbutton )->active ) );
700 }
701
702 void
703 on_content_monsterclipbutton_toggled( GtkToggleButton *togglebutton,
704                                                                           gpointer user_data ){
705         change_contentflag( content_monsterclipbutton, QUAKE2_CONTENTS_MONSTERCLIP, ( GTK_TOGGLE_BUTTON( content_monsterclipbutton )->active ) );
706 }
707
708 void
709 on_content_current0button_toggled( GtkToggleButton *togglebutton,
710                                                                    gpointer user_data ){
711         change_contentflag( content_current0button, QUAKE2_CONTENTS_CURRENT_0, ( GTK_TOGGLE_BUTTON( content_current0button )->active ) );
712 }
713
714 void
715 on_content_current90button_toggled( GtkToggleButton *togglebutton,
716                                                                         gpointer user_data ){
717         change_contentflag( content_current90button, QUAKE2_CONTENTS_CURRENT_90, ( GTK_TOGGLE_BUTTON( content_current90button )->active ) );
718 }
719
720 void
721 on_content_current180button_toggled( GtkToggleButton *togglebutton,
722                                                                          gpointer user_data ){
723         change_contentflag( content_current180button, QUAKE2_CONTENTS_CURRENT_180, ( GTK_TOGGLE_BUTTON( content_current180button )->active ) );
724 }
725
726 void
727 on_content_current270button_toggled( GtkToggleButton *togglebutton,
728                                                                          gpointer user_data ){
729         change_contentflag( content_current270button, QUAKE2_CONTENTS_CURRENT_270, ( GTK_TOGGLE_BUTTON( content_current270button )->active ) );
730 }
731
732 void
733 on_content_currentUPbutton_toggled( GtkToggleButton *togglebutton,
734                                                                         gpointer user_data ){
735         change_contentflag( content_currentUPbutton, QUAKE2_CONTENTS_CURRENT_UP, ( GTK_TOGGLE_BUTTON( content_currentUPbutton )->active ) );
736 }
737
738 void
739 on_content_currentDOWNbutton_toggled( GtkToggleButton *togglebutton,
740                                                                           gpointer user_data ){
741         change_contentflag( content_currentDOWNbutton, QUAKE2_CONTENTS_CURRENT_DOWN, ( GTK_TOGGLE_BUTTON( content_currentDOWNbutton )->active ) );
742 }
743
744 void
745 on_content_originbutton_toggled( GtkToggleButton *togglebutton,
746                                                                  gpointer user_data ){
747         change_contentflag( content_originbutton, QUAKE2_CONTENTS_ORIGIN, ( GTK_TOGGLE_BUTTON( content_originbutton )->active ) );
748 }
749
750 void
751 on_content_detailbutton_toggled( GtkToggleButton *togglebutton,
752                                                                  gpointer user_data ){
753         change_contentflag( content_detailbutton, QUAKE2_CONTENTS_DETAIL, ( GTK_TOGGLE_BUTTON( content_detailbutton )->active ) );
754 }
755
756 void
757 on_content_translucentbutton_toggled( GtkToggleButton *togglebutton,
758                                                                           gpointer user_data ){
759         change_contentflag( content_translucentbutton, QUAKE2_CONTENTS_TRANSLUCENT, ( GTK_TOGGLE_BUTTON( content_translucentbutton )->active ) );
760 }
761
762 void
763 on_content_ladderbutton_toggled( GtkToggleButton *togglebutton,
764                                                                  gpointer user_data ){
765         change_contentflag( content_ladderbutton, QUAKE2_CONTENTS_LADDER, ( GTK_TOGGLE_BUTTON( content_ladderbutton )->active ) );
766 }
767
768 // Value Entry Callback
769 void
770 on_value_entry_changed( GtkEditable     *editable,
771                                                 gpointer user_data ){
772         if ( ( !setup_buttons ) ) { // If we're setting up the buttons, don't change value
773                 working_value = atoi( gtk_entry_get_text( (GtkEntry*)editable ) );
774         }
775 }
776
777 void
778 on_value_entry_insert_text( GtkEditable     *editable,
779                                                         gchar           *new_text,
780                                                         gint new_text_length,
781                                                         gint            *position,
782                                                         gpointer user_data ){
783         int i, count = 0;
784         gchar *result;
785
786         // Limit input to digits, throwing out anything else
787         // Modified from Gtk FAQ for text filtering of GtkEntry
788         result = g_new( gchar, new_text_length );
789
790         for ( i = 0; i < new_text_length; i++ ) {
791                 if ( !isdigit( new_text[i] ) ) {
792                         continue;
793                 }
794                 result[count++] = new_text[i];
795         }
796
797         if ( count > 0 ) {
798                 gtk_signal_handler_block_by_func( GTK_OBJECT( editable ),
799                                                                                   GTK_SIGNAL_FUNC( on_value_entry_insert_text ),
800                                                                                   user_data );
801                 gtk_editable_insert_text( editable, result, count, position );
802                 gtk_signal_handler_unblock_by_func( GTK_OBJECT( editable ),
803                                                                                         GTK_SIGNAL_FUNC( on_value_entry_insert_text ),
804                                                                                         user_data );
805         }
806         gtk_signal_emit_stop_by_name( GTK_OBJECT( editable ), "insert_text" );
807
808         g_free( result );
809 }
810
811 void
812 on_surfacebutton_clicked( GtkButton       *button,
813                                                   gpointer user_data ){
814         gtk_notebook_set_page( GTK_NOTEBOOK( notebook1 ), 0 );
815 }
816
817 void
818 on_contentbutton_clicked( GtkButton       *button,
819                                                   gpointer user_data ){
820         gtk_notebook_set_page( GTK_NOTEBOOK( notebook1 ), 1 );
821 }
822
823
824 #define QUAKE2_FLAG_BUTTON_BORDER 3
825
826 GtkWidget* Create_Quake2FlagsDialog( GtkWidget* surfacedialog_widget ){
827         GtkWidget *frame1;
828         GtkWidget *vbox1;
829         GtkWidget *vbox2;
830         GtkWidget *vbox3;
831         GtkWidget *vbox4;
832         GtkWidget *table4;
833         GtkWidget *hbox2;
834         GtkWidget *hbox3;
835         GtkWidget *hseparator1;
836         GtkWidget *value_label;
837         GtkWidget *label5;
838         GtkWidget *table3;
839         GtkWidget *label6;
840
841         frame1 = gtk_frame_new( _( "Flags" ) );
842         gtk_widget_show( frame1 );
843         gtk_container_add( GTK_CONTAINER( surfacedialog_widget ), frame1 );
844
845         vbox1 = gtk_vbox_new( FALSE, 0 );
846         gtk_widget_show( vbox1 );
847         gtk_container_add( GTK_CONTAINER( frame1 ), vbox1 );
848
849         notebook1 = gtk_notebook_new();
850         gtk_widget_show( notebook1 );
851         gtk_box_pack_start( GTK_BOX( vbox1 ), notebook1, TRUE, TRUE, 0 );
852         gtk_notebook_set_show_tabs( GTK_NOTEBOOK( notebook1 ), TRUE );
853         gtk_container_set_border_width( GTK_CONTAINER( notebook1 ), 5 );
854
855         vbox2 = gtk_vbox_new( FALSE, 0 );
856         gtk_widget_show( vbox2 );
857         gtk_container_add( GTK_CONTAINER( notebook1 ), vbox2 );
858
859         table4 = gtk_table_new( 3, 4, FALSE );
860         gtk_widget_show( table4 );
861         gtk_box_pack_start( GTK_BOX( vbox2 ), table4, TRUE, TRUE, 0 );
862
863         surface_lightbutton = gtk_toggle_button_new_with_label( _( "Light" ) );
864         gtk_signal_connect( GTK_OBJECT( surface_lightbutton ), "toggled",
865                                                 GTK_SIGNAL_FUNC( on_surface_lightbutton_toggled ),
866                                                 NULL );
867         gtk_widget_show( surface_lightbutton );
868         gtk_table_attach( GTK_TABLE( table4 ), surface_lightbutton, 0, 1, 0, 1,
869                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
870                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
871         gtk_container_set_border_width( GTK_CONTAINER( surface_lightbutton ), QUAKE2_FLAG_BUTTON_BORDER );
872
873         surface_slickbutton = gtk_toggle_button_new_with_label( _( "Slick" ) );
874         gtk_signal_connect( GTK_OBJECT( surface_slickbutton ), "toggled",
875                                                 GTK_SIGNAL_FUNC( on_surface_slickbutton_toggled ),
876                                                 NULL );
877         gtk_widget_show( surface_slickbutton );
878         gtk_table_attach( GTK_TABLE( table4 ), surface_slickbutton, 1, 2, 0, 1,
879                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
880                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
881         gtk_container_set_border_width( GTK_CONTAINER( surface_slickbutton ), QUAKE2_FLAG_BUTTON_BORDER );
882
883         surface_skybutton = gtk_toggle_button_new_with_label( _( "Sky" ) );
884         gtk_signal_connect( GTK_OBJECT( surface_skybutton ), "toggled",
885                                                 GTK_SIGNAL_FUNC( on_surface_skybutton_toggled ),
886                                                 NULL );
887         gtk_widget_show( surface_skybutton );
888         gtk_table_attach( GTK_TABLE( table4 ), surface_skybutton, 2, 3, 0, 1,
889                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
890                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
891         gtk_container_set_border_width( GTK_CONTAINER( surface_skybutton ), QUAKE2_FLAG_BUTTON_BORDER );
892
893         surface_warpbutton = gtk_toggle_button_new_with_label( _( "Warp" ) );
894         gtk_signal_connect( GTK_OBJECT( surface_warpbutton ), "toggled",
895                                                 GTK_SIGNAL_FUNC( on_surface_warpbutton_toggled ),
896                                                 NULL );
897         gtk_widget_show( surface_warpbutton );
898         gtk_table_attach( GTK_TABLE( table4 ), surface_warpbutton, 3, 4, 0, 1,
899                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
900                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
901         gtk_container_set_border_width( GTK_CONTAINER( surface_warpbutton ), QUAKE2_FLAG_BUTTON_BORDER );
902
903         surface_trans33button = gtk_toggle_button_new_with_label( _( "Trans 33" ) );
904         gtk_signal_connect( GTK_OBJECT( surface_trans33button ), "toggled",
905                                                 GTK_SIGNAL_FUNC( on_surface_trans33button_toggled ),
906                                                 NULL );
907         gtk_widget_show( surface_trans33button );
908         gtk_table_attach( GTK_TABLE( table4 ), surface_trans33button, 0, 1, 1, 2,
909                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
910                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
911         gtk_container_set_border_width( GTK_CONTAINER( surface_trans33button ), QUAKE2_FLAG_BUTTON_BORDER );
912
913         surface_trans66button = gtk_toggle_button_new_with_label( _( "Trans 66" ) );
914         gtk_signal_connect( GTK_OBJECT( surface_trans66button ), "toggled",
915                                                 GTK_SIGNAL_FUNC( on_surface_trans66button_toggled ),
916                                                 NULL );
917         gtk_widget_show( surface_trans66button );
918         gtk_table_attach( GTK_TABLE( table4 ), surface_trans66button, 1, 2, 1, 2,
919                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
920                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
921         gtk_container_set_border_width( GTK_CONTAINER( surface_trans66button ), QUAKE2_FLAG_BUTTON_BORDER );
922
923         surface_flowingbutton = gtk_toggle_button_new_with_label( _( "Flowing" ) );
924         gtk_signal_connect( GTK_OBJECT( surface_flowingbutton ), "toggled",
925                                                 GTK_SIGNAL_FUNC( on_surface_flowingbutton_toggled ),
926                                                 NULL );
927         gtk_widget_show( surface_flowingbutton );
928         gtk_table_attach( GTK_TABLE( table4 ), surface_flowingbutton, 2, 3, 1, 2,
929                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
930                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
931         gtk_container_set_border_width( GTK_CONTAINER( surface_flowingbutton ), QUAKE2_FLAG_BUTTON_BORDER );
932
933         surface_nodrawbutton = gtk_toggle_button_new_with_label( _( "NoDraw" ) );
934         gtk_signal_connect( GTK_OBJECT( surface_nodrawbutton ), "toggled",
935                                                 GTK_SIGNAL_FUNC( on_surface_nodrawbutton_toggled ),
936                                                 NULL );
937         gtk_widget_show( surface_nodrawbutton );
938         gtk_table_attach( GTK_TABLE( table4 ), surface_nodrawbutton, 3, 4, 1, 2,
939                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
940                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
941         gtk_container_set_border_width( GTK_CONTAINER( surface_nodrawbutton ), QUAKE2_FLAG_BUTTON_BORDER );
942
943         surface_hintbutton = gtk_toggle_button_new_with_label( _( "Hint" ) );
944         gtk_signal_connect( GTK_OBJECT( surface_hintbutton ), "toggled",
945                                                 GTK_SIGNAL_FUNC( on_surface_hintbutton_toggled ),
946                                                 NULL );
947         gtk_widget_show( surface_hintbutton );
948         gtk_table_attach( GTK_TABLE( table4 ), surface_hintbutton, 0, 1, 2, 3,
949                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
950                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
951         gtk_container_set_border_width( GTK_CONTAINER( surface_hintbutton ), QUAKE2_FLAG_BUTTON_BORDER );
952
953         surface_skipbutton = gtk_toggle_button_new_with_label( _( "Skip" ) );
954         gtk_signal_connect( GTK_OBJECT( surface_skipbutton ), "toggled",
955                                                 GTK_SIGNAL_FUNC( on_surface_skipbutton_toggled ),
956                                                 NULL );
957         gtk_widget_show( surface_skipbutton );
958         gtk_table_attach( GTK_TABLE( table4 ), surface_skipbutton, 3, 4, 2, 3,
959                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
960                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
961         gtk_container_set_border_width( GTK_CONTAINER( surface_skipbutton ), QUAKE2_FLAG_BUTTON_BORDER );
962
963         hseparator1 = gtk_hseparator_new();
964         gtk_widget_show( hseparator1 );
965         gtk_box_pack_start( GTK_BOX( vbox2 ), hseparator1, FALSE, FALSE, 0 );
966         gtk_widget_set_usize( hseparator1, -2, 5 );
967
968         hbox2 = gtk_hbox_new( FALSE, 0 );
969         gtk_widget_show( hbox2 );
970         gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 0 );
971
972         hbox3 = gtk_hbox_new( FALSE, 0 );
973         gtk_widget_show( hbox3 );
974         gtk_box_pack_start( GTK_BOX( hbox2 ), hbox3, TRUE, TRUE, 0 );
975
976         vbox4 = gtk_vbox_new( FALSE, 0 );
977         gtk_widget_show( vbox4 );
978         gtk_box_pack_start( GTK_BOX( hbox3 ), vbox4, TRUE, TRUE, 0 );
979
980         value_label = gtk_label_new( _( "Value: " ) );
981         gtk_widget_show( value_label );
982         gtk_box_pack_start( GTK_BOX( hbox3 ), value_label, FALSE, FALSE, 0 );
983
984         value_entry = gtk_entry_new();
985         gtk_signal_connect( GTK_OBJECT( value_entry ), "changed",
986                                                 GTK_SIGNAL_FUNC( on_value_entry_changed ),
987                                                 NULL );
988         gtk_signal_connect( GTK_OBJECT( value_entry ), "insert_text",
989                                                 GTK_SIGNAL_FUNC( on_value_entry_insert_text ),
990                                                 NULL );
991         gtk_entry_set_max_length( (GtkEntry *)value_entry, 11 );
992         gtk_widget_show( value_entry );
993         gtk_box_pack_start( GTK_BOX( hbox3 ), value_entry, TRUE, TRUE, 0 );
994
995         vbox3 = gtk_vbox_new( FALSE, 0 );
996         gtk_widget_show( vbox3 );
997         gtk_box_pack_start( GTK_BOX( hbox3 ), vbox3, TRUE, TRUE, 0 );
998
999         label5 = gtk_label_new( _( "Surface Flags" ) );
1000         gtk_widget_show( label5 );
1001         gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ), gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ), 0 ), label5 );
1002
1003         table3 = gtk_table_new( 5, 4, FALSE );
1004         gtk_widget_show( table3 );
1005         gtk_container_add( GTK_CONTAINER( notebook1 ), table3 );
1006
1007         content_solidbutton = gtk_toggle_button_new_with_label( _( "Solid" ) );
1008         gtk_signal_connect( GTK_OBJECT( content_solidbutton ), "toggled",
1009                                                 GTK_SIGNAL_FUNC( on_content_solidbutton_toggled ),
1010                                                 NULL );
1011         gtk_widget_show( content_solidbutton );
1012         gtk_table_attach( GTK_TABLE( table3 ), content_solidbutton, 0, 1, 0, 1,
1013                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1014                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1015         gtk_container_set_border_width( GTK_CONTAINER( content_solidbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1016
1017         content_windowbutton = gtk_toggle_button_new_with_label( _( "Window" ) );
1018         gtk_signal_connect( GTK_OBJECT( content_windowbutton ), "toggled",
1019                                                 GTK_SIGNAL_FUNC( on_content_windowbutton_toggled ),
1020                                                 NULL );
1021         gtk_widget_show( content_windowbutton );
1022         gtk_table_attach( GTK_TABLE( table3 ), content_windowbutton, 1, 2, 0, 1,
1023                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1024                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1025         gtk_container_set_border_width( GTK_CONTAINER( content_windowbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1026
1027         content_auxbutton = gtk_toggle_button_new_with_label( _( "Aux" ) );
1028         gtk_signal_connect( GTK_OBJECT( content_auxbutton ), "toggled",
1029                                                 GTK_SIGNAL_FUNC( on_content_auxbutton_toggled ),
1030                                                 NULL );
1031         gtk_widget_show( content_auxbutton );
1032         gtk_table_attach( GTK_TABLE( table3 ), content_auxbutton, 2, 3, 0, 1,
1033                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1034                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1035         gtk_container_set_border_width( GTK_CONTAINER( content_auxbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1036
1037         content_lavabutton = gtk_toggle_button_new_with_label( _( "Lava" ) );
1038         gtk_signal_connect( GTK_OBJECT( content_lavabutton ), "toggled",
1039                                                 GTK_SIGNAL_FUNC( on_content_lavabutton_toggled ),
1040                                                 NULL );
1041         gtk_widget_show( content_lavabutton );
1042         gtk_table_attach( GTK_TABLE( table3 ), content_lavabutton, 3, 4, 0, 1,
1043                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1044                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1045         gtk_container_set_border_width( GTK_CONTAINER( content_lavabutton ), QUAKE2_FLAG_BUTTON_BORDER );
1046
1047         content_slimebutton = gtk_toggle_button_new_with_label( _( "Slime" ) );
1048         gtk_signal_connect( GTK_OBJECT( content_slimebutton ), "toggled",
1049                                                 GTK_SIGNAL_FUNC( on_content_slimebutton_toggled ),
1050                                                 NULL );
1051         gtk_widget_show( content_slimebutton );
1052         gtk_table_attach( GTK_TABLE( table3 ), content_slimebutton, 0, 1, 1, 2,
1053                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1054                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1055         gtk_container_set_border_width( GTK_CONTAINER( content_slimebutton ), QUAKE2_FLAG_BUTTON_BORDER );
1056
1057         content_waterbutton = gtk_toggle_button_new_with_label( _( "Water" ) );
1058         gtk_signal_connect( GTK_OBJECT( content_waterbutton ), "toggled",
1059                                                 GTK_SIGNAL_FUNC( on_content_waterbutton_toggled ),
1060                                                 NULL );
1061         gtk_widget_show( content_waterbutton );
1062         gtk_table_attach( GTK_TABLE( table3 ), content_waterbutton, 1, 2, 1, 2,
1063                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1064                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1065         gtk_container_set_border_width( GTK_CONTAINER( content_waterbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1066
1067         content_mistbutton = gtk_toggle_button_new_with_label( _( "Mist" ) );
1068         gtk_signal_connect( GTK_OBJECT( content_mistbutton ), "toggled",
1069                                                 GTK_SIGNAL_FUNC( on_content_mistbutton_toggled ),
1070                                                 NULL );
1071         gtk_widget_show( content_mistbutton );
1072         gtk_table_attach( GTK_TABLE( table3 ), content_mistbutton, 2, 3, 1, 2,
1073                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1074                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1075         gtk_container_set_border_width( GTK_CONTAINER( content_mistbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1076
1077         content_areaportalbutton = gtk_toggle_button_new_with_label( _( "AreaPortal" ) );
1078         gtk_signal_connect( GTK_OBJECT( content_areaportalbutton ), "toggled",
1079                                                 GTK_SIGNAL_FUNC( on_content_areaportalbutton_toggled ),
1080                                                 NULL );
1081         gtk_widget_show( content_areaportalbutton );
1082         gtk_table_attach( GTK_TABLE( table3 ), content_areaportalbutton, 3, 4, 1, 2,
1083                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1084                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1085         gtk_container_set_border_width( GTK_CONTAINER( content_areaportalbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1086
1087         content_playerclipbutton = gtk_toggle_button_new_with_label( _( "PlayerClip" ) );
1088         gtk_signal_connect( GTK_OBJECT( content_playerclipbutton ), "toggled",
1089                                                 GTK_SIGNAL_FUNC( on_content_playerclipbutton_toggled ),
1090                                                 NULL );
1091         gtk_widget_show( content_playerclipbutton );
1092         gtk_table_attach( GTK_TABLE( table3 ), content_playerclipbutton, 0, 1, 2, 3,
1093                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1094                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1095         gtk_container_set_border_width( GTK_CONTAINER( content_playerclipbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1096
1097         content_monsterclipbutton = gtk_toggle_button_new_with_label( _( "MonsterClip" ) );
1098         gtk_signal_connect( GTK_OBJECT( content_monsterclipbutton ), "toggled",
1099                                                 GTK_SIGNAL_FUNC( on_content_monsterclipbutton_toggled ),
1100                                                 NULL );
1101         gtk_widget_show( content_monsterclipbutton );
1102         gtk_table_attach( GTK_TABLE( table3 ), content_monsterclipbutton, 1, 2, 2, 3,
1103                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1104                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1105         gtk_container_set_border_width( GTK_CONTAINER( content_monsterclipbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1106
1107         content_current0button = gtk_toggle_button_new_with_label( _( "Current 0" ) );
1108         gtk_signal_connect( GTK_OBJECT( content_current0button ), "toggled",
1109                                                 GTK_SIGNAL_FUNC( on_content_current0button_toggled ),
1110                                                 NULL );
1111         gtk_widget_show( content_current0button );
1112         gtk_table_attach( GTK_TABLE( table3 ), content_current0button, 2, 3, 2, 3,
1113                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1114                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1115         gtk_container_set_border_width( GTK_CONTAINER( content_current0button ), QUAKE2_FLAG_BUTTON_BORDER );
1116
1117         content_current90button = gtk_toggle_button_new_with_label( _( "Current 90" ) );
1118         gtk_signal_connect( GTK_OBJECT( content_current90button ), "toggled",
1119                                                 GTK_SIGNAL_FUNC( on_content_current90button_toggled ),
1120                                                 NULL );
1121         gtk_widget_show( content_current90button );
1122         gtk_table_attach( GTK_TABLE( table3 ), content_current90button, 3, 4, 2, 3,
1123                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1124                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1125         gtk_container_set_border_width( GTK_CONTAINER( content_current90button ), QUAKE2_FLAG_BUTTON_BORDER );
1126
1127         content_current180button = gtk_toggle_button_new_with_label( _( "Current 180" ) );
1128         gtk_signal_connect( GTK_OBJECT( content_current180button ), "toggled",
1129                                                 GTK_SIGNAL_FUNC( on_content_current180button_toggled ),
1130                                                 NULL );
1131         gtk_widget_show( content_current180button );
1132         gtk_table_attach( GTK_TABLE( table3 ), content_current180button, 0, 1, 3, 4,
1133                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1134                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1135         gtk_container_set_border_width( GTK_CONTAINER( content_current180button ), QUAKE2_FLAG_BUTTON_BORDER );
1136
1137         content_current270button = gtk_toggle_button_new_with_label( _( "Current 270" ) );
1138         gtk_signal_connect( GTK_OBJECT( content_current270button ), "toggled",
1139                                                 GTK_SIGNAL_FUNC( on_content_current270button_toggled ),
1140                                                 NULL );
1141         gtk_widget_show( content_current270button );
1142         gtk_table_attach( GTK_TABLE( table3 ), content_current270button, 1, 2, 3, 4,
1143                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1144                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1145         gtk_container_set_border_width( GTK_CONTAINER( content_current270button ), QUAKE2_FLAG_BUTTON_BORDER );
1146
1147         content_currentUPbutton = gtk_toggle_button_new_with_label( _( "Current UP" ) );
1148         gtk_signal_connect( GTK_OBJECT( content_currentUPbutton ), "toggled",
1149                                                 GTK_SIGNAL_FUNC( on_content_currentUPbutton_toggled ),
1150                                                 NULL );
1151         gtk_widget_show( content_currentUPbutton );
1152         gtk_table_attach( GTK_TABLE( table3 ), content_currentUPbutton, 2, 3, 3, 4,
1153                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1154                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1155         gtk_container_set_border_width( GTK_CONTAINER( content_currentUPbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1156
1157         content_currentDOWNbutton = gtk_toggle_button_new_with_label( _( "Current DOWN" ) );
1158         gtk_signal_connect( GTK_OBJECT( content_currentDOWNbutton ), "toggled",
1159                                                 GTK_SIGNAL_FUNC( on_content_currentDOWNbutton_toggled ),
1160                                                 NULL );
1161         gtk_widget_show( content_currentDOWNbutton );
1162         gtk_table_attach( GTK_TABLE( table3 ), content_currentDOWNbutton, 3, 4, 3, 4,
1163                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1164                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1165         gtk_container_set_border_width( GTK_CONTAINER( content_currentDOWNbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1166
1167         content_originbutton = gtk_toggle_button_new_with_label( _( "Origin" ) );
1168         gtk_signal_connect( GTK_OBJECT( content_originbutton ), "toggled",
1169                                                 GTK_SIGNAL_FUNC( on_content_originbutton_toggled ),
1170                                                 NULL );
1171         gtk_widget_show( content_originbutton );
1172         gtk_table_attach( GTK_TABLE( table3 ), content_originbutton, 0, 1, 4, 5,
1173                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1174                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1175         gtk_container_set_border_width( GTK_CONTAINER( content_originbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1176
1177         content_detailbutton = gtk_toggle_button_new_with_label( _( "Detail" ) );
1178         gtk_signal_connect( GTK_OBJECT( content_detailbutton ), "toggled",
1179                                                 GTK_SIGNAL_FUNC( on_content_detailbutton_toggled ),
1180                                                 NULL );
1181         gtk_widget_show( content_detailbutton );
1182         gtk_table_attach( GTK_TABLE( table3 ), content_detailbutton, 1, 2, 4, 5,
1183                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1184                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1185         gtk_container_set_border_width( GTK_CONTAINER( content_detailbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1186
1187         content_translucentbutton = gtk_toggle_button_new_with_label( _( "Translucent" ) );
1188         gtk_signal_connect( GTK_OBJECT( content_translucentbutton ), "toggled",
1189                                                 GTK_SIGNAL_FUNC( on_content_translucentbutton_toggled ),
1190                                                 NULL );
1191         gtk_widget_show( content_translucentbutton );
1192         gtk_table_attach( GTK_TABLE( table3 ), content_translucentbutton, 2, 3, 4, 5,
1193                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1194                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1195         gtk_container_set_border_width( GTK_CONTAINER( content_translucentbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1196
1197         content_ladderbutton = gtk_toggle_button_new_with_label( _( "Ladder" ) );
1198         gtk_signal_connect( GTK_OBJECT( content_ladderbutton ), "toggled",
1199                                                 GTK_SIGNAL_FUNC( on_content_ladderbutton_toggled ),
1200                                                 NULL );
1201         gtk_widget_show( content_ladderbutton );
1202         gtk_table_attach( GTK_TABLE( table3 ), content_ladderbutton, 3, 4, 4, 5,
1203                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1204                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1205         gtk_container_set_border_width( GTK_CONTAINER( content_ladderbutton ), QUAKE2_FLAG_BUTTON_BORDER );
1206
1207         label6 = gtk_label_new( _( "Content Flags" ) );
1208         gtk_widget_show( label6 );
1209         gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ), gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ), 1 ), label6 );
1210
1211         return frame1;
1212 }