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