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