]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/surface_heretic2/surfaceflagsdialog_heretic2.cpp
q3map2: fix dangling pointer dereference
[xonotic/netradiant.git] / plugins / surface_heretic2 / surfaceflagsdialog_heretic2.cpp
1 /*
2    Copyright (C) 1999-2007 id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #include <gtk/gtk.h>
23 #include <gdk/gdkkeysyms.h>
24 #include <glib/gi18n.h>
25
26 #include "surfdlg_plugin.h"
27
28 #include "surfaceflagsdialog_heretic2.h"
29
30 GtkWidget *surface_lightbutton;
31 GtkWidget *surface_slickbutton;
32 GtkWidget *surface_skybutton;
33 GtkWidget *surface_warpbutton;
34 GtkWidget *surface_trans33button;
35 GtkWidget *surface_trans66button;
36 GtkWidget *surface_flowingbutton;
37 GtkWidget *surface_nodrawbutton;
38 GtkWidget *surface_tallwallbutton;
39 GtkWidget *surface_alphatexbutton;
40 GtkWidget *surface_animspeedbutton;
41 GtkWidget *surface_undulatebutton;
42
43 GtkWidget *surf_gravel_radiobutton;
44 GSList *surf_gravel_radiobutton_group = NULL;
45 GtkWidget *surf_metal_radiobutton;
46 GtkWidget *surf_stone_radiobutton;
47 GtkWidget *surf_wood_radiobutton;
48
49 GtkWidget *surf_value_entry;
50
51 GtkWidget *notebook1;
52
53 GtkWidget *content_solidbutton;
54 GtkWidget *content_windowbutton;
55 GtkWidget *content_illusbutton;
56 GtkWidget *content_lavabutton;
57 GtkWidget *content_slimebutton;
58 GtkWidget *content_waterbutton;
59 GtkWidget *content_mistbutton;
60 GtkWidget *content_areaportalbutton;
61 GtkWidget *content_playerclipbutton;
62 GtkWidget *content_monsterclipbutton;
63 GtkWidget *content_current0button;
64 GtkWidget *content_current90button;
65 GtkWidget *content_current180button;
66 GtkWidget *content_current270button;
67 GtkWidget *content_currentUPbutton;
68 GtkWidget *content_currentDOWNbutton;
69 GtkWidget *content_originbutton;
70 GtkWidget *content_detailbutton;
71 GtkWidget *content_ladderbutton;
72 GtkWidget *content_camnoblockbutton;
73
74
75 gboolean setup_buttons = TRUE;
76
77 int working_surface_flags;
78 int surface_mask;
79 int working_content_flags;
80 int content_mask;
81 int working_value;
82 gboolean surface_material_inconsistant = FALSE;
83
84 inline void set_inconsistent( GtkWidget *toggle_button ){
85         gtk_toggle_button_set_inconsistent( GTK_TOGGLE_BUTTON( toggle_button ), TRUE );
86 }
87
88 inline void clear_inconsistent( GtkWidget *toggle_button ){
89         if ( gtk_toggle_button_get_inconsistent( GTK_TOGGLE_BUTTON( toggle_button ) ) ) {
90                 gtk_toggle_button_set_inconsistent( GTK_TOGGLE_BUTTON( toggle_button ), FALSE );
91         }
92
93 }
94
95 void clear_all_inconsistent( void ){
96         clear_inconsistent( surface_lightbutton );
97         clear_inconsistent( surface_slickbutton );
98         clear_inconsistent( surface_skybutton );
99         clear_inconsistent( surface_warpbutton );
100         clear_inconsistent( surface_trans33button );
101         clear_inconsistent( surface_trans66button );
102         clear_inconsistent( surface_flowingbutton );
103         clear_inconsistent( surface_nodrawbutton );
104         clear_inconsistent( surface_tallwallbutton );
105         clear_inconsistent( surface_alphatexbutton );
106         clear_inconsistent( surface_animspeedbutton );
107         clear_inconsistent( surface_undulatebutton );
108
109         clear_inconsistent( surf_gravel_radiobutton );
110         clear_inconsistent( surf_metal_radiobutton );
111         clear_inconsistent( surf_stone_radiobutton );
112         clear_inconsistent( surf_wood_radiobutton );
113
114         clear_inconsistent( content_solidbutton );
115         clear_inconsistent( content_windowbutton );
116         clear_inconsistent( content_illusbutton );
117         clear_inconsistent( content_lavabutton );
118         clear_inconsistent( content_slimebutton );
119         clear_inconsistent( content_waterbutton );
120         clear_inconsistent( content_mistbutton );
121         clear_inconsistent( content_areaportalbutton );
122         clear_inconsistent( content_playerclipbutton );
123         clear_inconsistent( content_monsterclipbutton );
124         clear_inconsistent( content_current0button );
125         clear_inconsistent( content_current90button );
126         clear_inconsistent( content_current180button );
127         clear_inconsistent( content_current270button );
128         clear_inconsistent( content_currentUPbutton );
129         clear_inconsistent( content_currentDOWNbutton );
130         clear_inconsistent( content_originbutton );
131         clear_inconsistent( content_detailbutton );
132         clear_inconsistent( content_ladderbutton );
133         clear_inconsistent( content_camnoblockbutton );
134 }
135
136 void clear_all_buttons_and_values(){
137         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_lightbutton ), FALSE );
138         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_slickbutton ), FALSE );
139         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skybutton ), FALSE );
140         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_warpbutton ), FALSE );
141         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans33button ), FALSE );
142         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans66button ), FALSE );
143         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_flowingbutton ), FALSE );
144         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_nodrawbutton ), FALSE );
145         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_tallwallbutton ), FALSE );
146         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_alphatexbutton ), FALSE );
147         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_animspeedbutton ), FALSE );
148         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_undulatebutton ), FALSE );
149
150 //  surface_material_inconsistant = TRUE;
151
152         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_gravel_radiobutton ), FALSE );
153         set_inconsistent( surf_gravel_radiobutton );
154
155         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_metal_radiobutton ), FALSE );
156         set_inconsistent( surf_metal_radiobutton );
157
158         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_stone_radiobutton ), FALSE );
159         set_inconsistent( surf_stone_radiobutton );
160
161         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_wood_radiobutton ), FALSE );
162         set_inconsistent( surf_wood_radiobutton );
163
164         gtk_entry_set_text( (GtkEntry *)surf_value_entry, "" );
165
166         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_solidbutton ), FALSE );
167         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_windowbutton ), FALSE );
168         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_illusbutton ), FALSE );
169         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_lavabutton ), FALSE );
170         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_slimebutton ), FALSE );
171         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_waterbutton ), FALSE );
172         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_mistbutton ), FALSE );
173         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_areaportalbutton ), FALSE );
174         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_playerclipbutton ), FALSE );
175         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_monsterclipbutton ), FALSE );
176         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current0button ), FALSE );
177         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current90button ), FALSE );
178         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current180button ), FALSE );
179         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current270button ), FALSE );
180         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentUPbutton ), FALSE );
181         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentDOWNbutton ), FALSE );
182         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_originbutton ), FALSE );
183         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_detailbutton ), FALSE );
184         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_ladderbutton ), FALSE );
185         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_camnoblockbutton ), FALSE );
186
187 }
188
189 void SetFlagButtons_Heretic2( texdef_to_face_t *texdef_face_list, bool b_isListEmpty ){
190         int contents = 0;
191         int flags = 0;
192         int value = 0;
193         int diff_contents = 0;
194         int diff_flags = 0;
195         gboolean diff_value = FALSE;
196         char tex_buff[11];
197         texdef_t* tmp_texdef;
198         texdef_to_face_t* temp_texdef_face_list;
199         gboolean surface_which_material_inconsistant[4];
200         int surface_iterator;
201
202         setup_buttons = TRUE;
203         working_surface_flags = 0;
204         surface_mask = 0;
205         working_content_flags = 0;
206         content_mask = 0;
207         working_value = 0;
208         surface_material_inconsistant = FALSE;
209         surface_which_material_inconsistant[0] = FALSE;
210         surface_which_material_inconsistant[1] = FALSE;
211         surface_which_material_inconsistant[2] = FALSE;
212         surface_which_material_inconsistant[3] = FALSE;
213
214         if ( !b_isListEmpty ) {
215                 tmp_texdef = &texdef_face_list->texdef;
216                 contents = tmp_texdef->contents;
217                 flags = tmp_texdef->flags;
218                 value = tmp_texdef->value;
219
220                 surface_iterator = ( tmp_texdef->flags & ~HERETIC2_SURF_MATERIAL_MASK ) >> 24; // Inconsistant Material?
221                 surface_which_material_inconsistant[surface_iterator] = TRUE;
222
223                 for ( temp_texdef_face_list = texdef_face_list->next; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
224                 {
225                         tmp_texdef = &temp_texdef_face_list->texdef;
226                         diff_contents |= contents ^ tmp_texdef->contents; // Figure out which buttons are inconsistent
227                         diff_flags |= flags ^ tmp_texdef->flags;
228                         if ( tmp_texdef->value != value ) {
229                                 diff_value = TRUE;
230                         }
231
232                         surface_iterator = ( tmp_texdef->flags & ~HERETIC2_SURF_MATERIAL_MASK ) >> 24; // Inconsistant Material?
233                         surface_which_material_inconsistant[surface_iterator] = TRUE;
234
235                         Sys_Printf( "Diff_Flags: %d\t Surf_Iter: %d\n",diff_flags, surface_iterator );
236
237                 }
238         }
239
240
241         clear_all_inconsistent();
242
243         // If no faces/brushes are selected, clear everything and bail
244         if ( b_isListEmpty ) {
245                 clear_all_buttons_and_values();
246                 setup_buttons = FALSE;
247                 return;
248         }
249
250         // Set surface buttons to reflect brush/face flags, contents, and values
251         if ( diff_flags & HERETIC2_SURF_LIGHT ) {
252                 set_inconsistent( surface_lightbutton );
253         }
254         else{
255                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_lightbutton ), ( flags & HERETIC2_SURF_LIGHT ) );
256         }
257
258         if ( diff_flags & HERETIC2_SURF_SLICK ) {
259                 set_inconsistent( surface_slickbutton );
260         }
261         else if ( flags & HERETIC2_SURF_SLICK ) {
262                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_slickbutton ), TRUE );
263         }
264         else{
265                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_slickbutton ), FALSE );
266         }
267
268         if ( diff_flags & HERETIC2_SURF_SKY ) {
269                 set_inconsistent( surface_skybutton );
270         }
271         else if ( flags & HERETIC2_SURF_SKY ) {
272                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skybutton ), TRUE );
273         }
274         else{
275                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_skybutton ), FALSE );
276         }
277
278         if ( diff_flags & HERETIC2_SURF_WARP ) {
279                 set_inconsistent( surface_warpbutton );
280         }
281         else if ( flags & HERETIC2_SURF_WARP ) {
282                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_warpbutton ), TRUE );
283         }
284         else{
285                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_warpbutton ), FALSE );
286         }
287
288         if ( diff_flags & HERETIC2_SURF_TRANS33 ) {
289                 set_inconsistent( surface_trans33button );
290         }
291         else if ( flags & HERETIC2_SURF_TRANS33 ) {
292                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans33button ), TRUE );
293         }
294         else{
295                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans33button ), FALSE );
296         }
297
298         if ( diff_flags & HERETIC2_SURF_TRANS66 ) {
299                 set_inconsistent( surface_trans66button );
300         }
301         else if ( flags & HERETIC2_SURF_TRANS66 ) {
302                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans66button ), TRUE );
303         }
304         else{
305                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_trans66button ), FALSE );
306         }
307
308         if ( diff_flags & HERETIC2_SURF_FLOWING ) {
309                 set_inconsistent( surface_flowingbutton );
310         }
311         else if ( flags & HERETIC2_SURF_FLOWING ) {
312                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_flowingbutton ), TRUE );
313         }
314         else{
315                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_flowingbutton ), FALSE );
316         }
317
318         if ( diff_flags & HERETIC2_SURF_NODRAW ) {
319                 set_inconsistent( surface_nodrawbutton );
320         }
321         else if ( flags & HERETIC2_SURF_NODRAW ) {
322                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_nodrawbutton ), TRUE );
323         }
324         else{
325                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_nodrawbutton ), FALSE );
326         }
327
328         if ( diff_flags & HERETIC2_SURF_TALL_WALL ) {
329                 set_inconsistent( surface_tallwallbutton );
330         }
331         else if ( flags & HERETIC2_SURF_TALL_WALL ) {
332                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_tallwallbutton ), TRUE );
333         }
334         else{
335                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_tallwallbutton ), FALSE );
336         }
337
338         if ( diff_flags & HERETIC2_SURF_ALPHA_TEXTURE ) {
339                 set_inconsistent( surface_alphatexbutton );
340         }
341         else if ( flags & HERETIC2_SURF_ALPHA_TEXTURE ) {
342                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_alphatexbutton ), TRUE );
343         }
344         else{
345                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_alphatexbutton ), FALSE );
346         }
347
348         if ( diff_flags & HERETIC2_SURF_ANIMSPEED ) {
349                 set_inconsistent( surface_animspeedbutton );
350         }
351         else if ( flags & HERETIC2_SURF_ANIMSPEED ) {
352                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_animspeedbutton ), TRUE );
353         }
354         else{
355                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_animspeedbutton ), FALSE );
356         }
357
358         if ( diff_flags & HERETIC2_SURF_UNDULATE ) {
359                 set_inconsistent( surface_undulatebutton );
360         }
361         else if ( flags & HERETIC2_SURF_UNDULATE ) {
362                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_undulatebutton ), TRUE );
363         }
364         else{
365                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surface_undulatebutton ), FALSE );
366         }
367
368         if ( diff_flags & ~HERETIC2_SURF_MATERIAL_MASK ) {
369                 Sys_Printf( "--> %d\n", ( diff_flags & ~HERETIC2_SURF_MATERIAL_MASK ) );
370                 Sys_Printf( "%d\t%d\t%d\t%d\n", surface_which_material_inconsistant[0], surface_which_material_inconsistant[1], surface_which_material_inconsistant[2], surface_which_material_inconsistant[3] );
371
372                 if ( surface_which_material_inconsistant[0] ) {
373                         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_gravel_radiobutton ), FALSE );
374                         surface_material_inconsistant = TRUE;
375                         set_inconsistent( surf_gravel_radiobutton );
376                 }
377                 if ( surface_which_material_inconsistant[1] ) {
378                         //if (!surface_material_inconsistant)
379                         //{
380                         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_metal_radiobutton ), FALSE );
381                         surface_material_inconsistant = TRUE;
382                         //}
383                         set_inconsistent( surf_metal_radiobutton );
384                 }
385                 if ( surface_which_material_inconsistant[2] ) {
386                         //if (!surface_material_inconsistant)
387                         //{
388                         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_stone_radiobutton ), FALSE );
389                         surface_material_inconsistant = TRUE;
390                         //}
391                         set_inconsistent( surf_stone_radiobutton );
392                 }
393                 if ( surface_which_material_inconsistant[3] ) {
394                         //if (!surface_material_inconsistant)
395                         //{
396                         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_wood_radiobutton ), FALSE );
397                         surface_material_inconsistant = TRUE;
398                         //}
399                         set_inconsistent( surf_wood_radiobutton );
400                 }
401         }
402         else
403         {
404                 if ( flags & ~HERETIC2_SURF_MATERIAL_MASK ) {
405                         surface_iterator = ( flags & ~HERETIC2_SURF_MATERIAL_MASK ) >> 24;
406                         if ( surface_iterator == 1 ) {
407                                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_metal_radiobutton ), TRUE );
408                         }
409                         else if ( surface_iterator == 2 ) {
410                                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_stone_radiobutton ), TRUE );
411                         }
412                         else if ( surface_iterator == 3 ) {
413                                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_wood_radiobutton ), TRUE );
414                         }
415                 }
416                 else
417                 {
418                         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( surf_gravel_radiobutton ), TRUE );
419                 }
420         }
421
422         // Set content buttons to reflect brush values
423         if ( diff_contents & HERETIC2_CONTENTS_SOLID ) {
424                 set_inconsistent( content_solidbutton );
425         }
426         else if ( contents & HERETIC2_CONTENTS_SOLID ) {
427                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_solidbutton ), TRUE );
428         }
429         else{
430                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_solidbutton ), FALSE );
431         }
432
433         if ( diff_contents & HERETIC2_CONTENTS_WINDOW ) {
434                 set_inconsistent( content_windowbutton );
435         }
436         else if ( contents & HERETIC2_CONTENTS_WINDOW ) {
437                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_windowbutton ), TRUE );
438         }
439         else{
440                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_windowbutton ), FALSE );
441         }
442
443         if ( diff_contents & HERETIC2_CONTENTS_ILLUSIONARY ) {
444                 set_inconsistent( content_illusbutton );
445         }
446         else if ( contents & HERETIC2_CONTENTS_ILLUSIONARY ) {
447                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_illusbutton ), TRUE );
448         }
449         else{
450                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_illusbutton ), FALSE );
451         }
452
453         if ( diff_contents & HERETIC2_CONTENTS_LAVA ) {
454                 set_inconsistent( content_lavabutton );
455         }
456         else if ( contents & HERETIC2_CONTENTS_LAVA ) {
457                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_lavabutton ), TRUE );
458         }
459         else{
460                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_lavabutton ), FALSE );
461         }
462
463         if ( diff_contents & HERETIC2_CONTENTS_SLIME ) {
464                 set_inconsistent( content_slimebutton );
465         }
466         else if ( contents & HERETIC2_CONTENTS_SLIME ) {
467                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_slimebutton ), TRUE );
468         }
469         else{
470                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_slimebutton ), FALSE );
471         }
472
473         if ( diff_contents & HERETIC2_CONTENTS_WATER ) {
474                 set_inconsistent( content_waterbutton );
475         }
476         else if ( contents & HERETIC2_CONTENTS_WATER ) {
477                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_waterbutton ), TRUE );
478         }
479         else{
480                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_waterbutton ), FALSE );
481         }
482
483         if ( diff_contents & HERETIC2_CONTENTS_MIST ) {
484                 set_inconsistent( content_mistbutton );
485         }
486         else if ( contents & HERETIC2_CONTENTS_MIST ) {
487                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_mistbutton ), TRUE );
488         }
489         else{
490                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_mistbutton ), FALSE );
491         }
492
493         if ( diff_contents & HERETIC2_CONTENTS_AREAPORTAL ) {
494                 set_inconsistent( content_areaportalbutton );
495         }
496         else if ( contents & HERETIC2_CONTENTS_AREAPORTAL ) {
497                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_areaportalbutton ), TRUE );
498         }
499         else{
500                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_areaportalbutton ), FALSE );
501         }
502
503         if ( diff_contents & HERETIC2_CONTENTS_PLAYERCLIP ) {
504                 set_inconsistent( content_playerclipbutton );
505         }
506         else if ( contents & HERETIC2_CONTENTS_PLAYERCLIP ) {
507                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_playerclipbutton ), TRUE );
508         }
509         else{
510                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_playerclipbutton ), FALSE );
511         }
512
513         if ( diff_contents & HERETIC2_CONTENTS_MONSTERCLIP ) {
514                 set_inconsistent( content_monsterclipbutton );
515         }
516         else if ( contents & HERETIC2_CONTENTS_MONSTERCLIP ) {
517                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_monsterclipbutton ), TRUE );
518         }
519         else{
520                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_monsterclipbutton ), FALSE );
521         }
522
523         if ( diff_contents & HERETIC2_CONTENTS_CURRENT_0 ) {
524                 set_inconsistent( content_current0button );
525         }
526         else if ( contents & HERETIC2_CONTENTS_CURRENT_0 ) {
527                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current0button ), TRUE );
528         }
529         else{
530                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current0button ), FALSE );
531         }
532
533         if ( diff_contents & HERETIC2_CONTENTS_CURRENT_90 ) {
534                 set_inconsistent( content_current90button );
535         }
536         else if ( contents & HERETIC2_CONTENTS_CURRENT_90 ) {
537                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current90button ), TRUE );
538         }
539         else{
540                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current90button ), FALSE );
541         }
542
543         if ( diff_contents & HERETIC2_CONTENTS_CURRENT_180 ) {
544                 set_inconsistent( content_current180button );
545         }
546         else if ( contents & HERETIC2_CONTENTS_CURRENT_180 ) {
547                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current180button ), TRUE );
548         }
549         else{
550                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current180button ), FALSE );
551         }
552
553         if ( diff_contents & HERETIC2_CONTENTS_CURRENT_270 ) {
554                 set_inconsistent( content_current270button );
555         }
556         else if ( contents & HERETIC2_CONTENTS_CURRENT_270 ) {
557                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current270button ), TRUE );
558         }
559         else{
560                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_current270button ), FALSE );
561         }
562
563         if ( diff_contents & HERETIC2_CONTENTS_CURRENT_UP ) {
564                 set_inconsistent( content_currentUPbutton );
565         }
566         else if ( contents & HERETIC2_CONTENTS_CURRENT_UP ) {
567                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentUPbutton ), TRUE );
568         }
569         else{
570                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentUPbutton ), FALSE );
571         }
572
573         if ( diff_contents & HERETIC2_CONTENTS_CURRENT_DOWN ) {
574                 set_inconsistent( content_currentDOWNbutton );
575         }
576         else if ( contents & HERETIC2_CONTENTS_CURRENT_DOWN ) {
577                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentDOWNbutton ), TRUE );
578         }
579         else{
580                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_currentDOWNbutton ), FALSE );
581         }
582
583         if ( diff_contents & HERETIC2_CONTENTS_ORIGIN ) {
584                 set_inconsistent( content_originbutton );
585         }
586         else if ( contents & HERETIC2_CONTENTS_ORIGIN ) {
587                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_originbutton ), TRUE );
588         }
589         else{
590                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_originbutton ), FALSE );
591         }
592
593         if ( diff_contents & HERETIC2_CONTENTS_DETAIL ) {
594                 set_inconsistent( content_detailbutton );
595         }
596         else if ( contents & HERETIC2_CONTENTS_DETAIL ) {
597                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_detailbutton ), TRUE );
598         }
599         else{
600                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_detailbutton ), FALSE );
601         }
602
603         if ( diff_contents & HERETIC2_CONTENTS_LADDER ) {
604                 set_inconsistent( content_ladderbutton );
605         }
606         else if ( contents & HERETIC2_CONTENTS_LADDER ) {
607                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_ladderbutton ), TRUE );
608         }
609         else{
610                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_ladderbutton ), FALSE );
611         }
612
613         if ( diff_contents & HERETIC2_CONTENTS_CAMERANOBLOCK ) {
614                 set_inconsistent( content_camnoblockbutton );
615         }
616         else if ( contents & HERETIC2_CONTENTS_CAMERANOBLOCK ) {
617                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_camnoblockbutton ), TRUE );
618         }
619         else{
620                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( content_camnoblockbutton ), FALSE );
621         }
622
623         // Set Value
624         if ( diff_value ) {
625                 gtk_entry_set_text( (GtkEntry *)surf_value_entry, "" );
626         }
627         else
628         {
629                 working_value = value;
630                 sprintf( tex_buff, "%d", value );
631                 gtk_entry_set_text( (GtkEntry *)surf_value_entry, tex_buff );
632         }
633
634         setup_buttons = FALSE;
635 }
636
637 void SetChangeInFlags_Face_Heretic2( texdef_to_face_t *texdef_face_list ){
638         texdef_to_face_t *temp_texdef_face_list;
639         texdef_t *tmp_texdef;
640
641         for ( temp_texdef_face_list = texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next )
642         {
643                 tmp_texdef = &temp_texdef_face_list->texdef;
644                 tmp_texdef->flags = ( tmp_texdef->flags & ~surface_mask ) | working_surface_flags;
645                 tmp_texdef->contents = ( tmp_texdef->contents & ~content_mask ) | working_content_flags;
646                 tmp_texdef->value = working_value;
647                 Sys_Printf( "content_flag: %d     content_mask: %d\n",working_content_flags,content_mask );
648                 Sys_Printf( "content: %d\n",tmp_texdef->contents );
649         }
650 }
651
652 inline void change_surfaceflag( GtkWidget *togglebutton, int sur_flag ){ // For Material
653         if ( !setup_buttons ) { // If we're setting up the buttons, we really don't need to
654                                    // set flags that are already set
655                 if ( surface_material_inconsistant ) {
656                         clear_inconsistent( surf_gravel_radiobutton );
657                         clear_inconsistent( surf_metal_radiobutton );
658                         clear_inconsistent( surf_stone_radiobutton );
659                         clear_inconsistent( surf_wood_radiobutton );
660                 }
661                 surface_mask |= ~HERETIC2_SURF_MATERIAL_MASK;
662                 working_surface_flags = ( working_surface_flags & HERETIC2_SURF_MATERIAL_MASK ) | sur_flag;
663         }
664 }
665
666 inline void change_material( GtkWidget *togglebutton ){
667         if ( !setup_buttons ) { // If we're setting up the buttons, we really don't need to
668                                    // set flags that are already set
669                 if ( surface_material_inconsistant ) {
670                         clear_inconsistent( surf_gravel_radiobutton );
671                         clear_inconsistent( surf_metal_radiobutton );
672                         clear_inconsistent( surf_stone_radiobutton );
673                         clear_inconsistent( surf_wood_radiobutton );
674                 }
675                 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_gravel_radiobutton ) )  ) {
676                         surface_mask |= ~HERETIC2_SURF_MATERIAL_MASK;
677                         working_surface_flags = ( working_surface_flags & HERETIC2_SURF_MATERIAL_MASK ) | HERETIC2_SURF_TYPE_GRAVEL;
678                 }
679                 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_metal_radiobutton ) ) ) {
680                         surface_mask |= ~HERETIC2_SURF_MATERIAL_MASK;
681                         working_surface_flags = ( working_surface_flags & HERETIC2_SURF_MATERIAL_MASK ) | HERETIC2_SURF_TYPE_METAL;
682                 }
683                 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_stone_radiobutton ) ) ) {
684                         surface_mask |= ~HERETIC2_SURF_MATERIAL_MASK;
685                         working_surface_flags = ( working_surface_flags & HERETIC2_SURF_MATERIAL_MASK ) | HERETIC2_SURF_TYPE_STONE;
686                 }
687                 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_wood_radiobutton ) ) ) {
688                         surface_mask |= ~HERETIC2_SURF_MATERIAL_MASK;
689                         working_surface_flags = ( working_surface_flags & HERETIC2_SURF_MATERIAL_MASK ) | HERETIC2_SURF_TYPE_WOOD;
690                 }
691         }
692 }
693
694 inline void change_surfaceflag( GtkWidget *togglebutton, int sur_flag, gboolean change_flag_to ){
695
696         if ( !setup_buttons ) { // If we're setting up the buttons, we really don't need to
697                                    // set flags that are already set
698                 if ( gtk_toggle_button_get_inconsistent( GTK_TOGGLE_BUTTON( togglebutton ) ) ) { // Clear out inconsistent, if set
699                         clear_inconsistent( GTK_WIDGET( togglebutton ) );
700                 }
701
702                 surface_mask |= sur_flag;
703
704                 if ( change_flag_to ) {
705                         working_surface_flags |= sur_flag;
706                 }
707                 else{
708                         working_surface_flags &= ~sur_flag;
709                 }
710         }
711 }
712
713 inline void change_contentflag( GtkWidget *togglebutton, int content_flag, gboolean change_flag_to ){
714
715         if ( ( !setup_buttons ) ) { // If we're setting up the buttons, we really don't need to
716                                        // set flags that are already set
717
718                 if ( gtk_toggle_button_get_inconsistent( GTK_TOGGLE_BUTTON( togglebutton ) ) ) {
719                         clear_inconsistent( togglebutton );
720                 }
721                 //if (g_ptrSelectedFaces.GetSize() == 0)  // Only changing content flags on whole brushes, not faces.
722                 //{
723                 content_mask |= content_flag;
724
725                 if ( change_flag_to ) {
726                         working_content_flags |= content_flag;
727                 }
728                 else{
729                         working_content_flags &= ~content_flag;
730                 }
731                 //}
732         }
733 }
734
735 // Surface Flags Callbacks
736 void
737 on_surface_lightbutton_toggled( GtkToggleButton *togglebutton,
738                                                                 gpointer user_data ){
739         change_surfaceflag( surface_lightbutton, HERETIC2_SURF_LIGHT, ( GTK_TOGGLE_BUTTON( surface_lightbutton )->active ) );
740 }
741
742
743 void
744 on_surface_slickbutton_toggled( GtkToggleButton *togglebutton,
745                                                                 gpointer user_data ){
746         change_surfaceflag( surface_slickbutton, HERETIC2_SURF_SLICK, ( GTK_TOGGLE_BUTTON( surface_slickbutton )->active ) );
747 }
748
749
750 void
751 on_surface_skybutton_toggled( GtkToggleButton *togglebutton,
752                                                           gpointer user_data ){
753         change_surfaceflag( surface_skybutton, HERETIC2_SURF_SKY, ( GTK_TOGGLE_BUTTON( surface_skybutton )->active ) );
754 }
755
756
757 void
758 on_surface_warpbutton_toggled( GtkToggleButton *togglebutton,
759                                                            gpointer user_data ){
760         change_surfaceflag( surface_warpbutton, HERETIC2_SURF_WARP, ( GTK_TOGGLE_BUTTON( surface_warpbutton )->active ) );
761 }
762
763
764 void
765 on_surface_trans33button_toggled( GtkToggleButton *togglebutton,
766                                                                   gpointer user_data ){
767         change_surfaceflag( surface_trans33button, HERETIC2_SURF_TRANS33, ( GTK_TOGGLE_BUTTON( surface_trans33button )->active ) );
768 }
769
770
771 void
772 on_surface_trans66button_toggled( GtkToggleButton *togglebutton,
773                                                                   gpointer user_data ){
774         change_surfaceflag( surface_trans66button, HERETIC2_SURF_TRANS66, ( GTK_TOGGLE_BUTTON( surface_trans66button )->active ) );
775 }
776
777
778 void
779 on_surface_flowingbutton_toggled( GtkToggleButton *togglebutton,
780                                                                   gpointer user_data ){
781         change_surfaceflag( surface_flowingbutton, HERETIC2_SURF_FLOWING, ( GTK_TOGGLE_BUTTON( surface_flowingbutton )->active ) );
782 }
783
784
785 void
786 on_surface_nodrawbutton_toggled( GtkToggleButton *togglebutton,
787                                                                  gpointer user_data ){
788         change_surfaceflag( surface_nodrawbutton, HERETIC2_SURF_NODRAW, ( GTK_TOGGLE_BUTTON( surface_nodrawbutton )->active ) );
789 }
790
791
792 void
793 on_surface_tallwallbutton_toggled( GtkToggleButton *togglebutton,
794                                                                    gpointer user_data ){
795         change_surfaceflag( surface_tallwallbutton, HERETIC2_SURF_TALL_WALL, ( GTK_TOGGLE_BUTTON( surface_tallwallbutton )->active ) );
796 }
797
798
799 void
800 on_surface_alphatexbutton_toggled( GtkToggleButton *togglebutton,
801                                                                    gpointer user_data ){
802         change_surfaceflag( surface_alphatexbutton, HERETIC2_SURF_ALPHA_TEXTURE, ( GTK_TOGGLE_BUTTON( surface_alphatexbutton )->active ) );
803 }
804
805
806 void
807 on_surface_animspeedbutton_toggled( GtkToggleButton *togglebutton,
808                                                                         gpointer user_data ){
809         change_surfaceflag( surface_animspeedbutton, HERETIC2_SURF_ANIMSPEED, ( GTK_TOGGLE_BUTTON( surface_animspeedbutton )->active ) );
810 }
811
812
813 void
814 on_surface_undulatebutton_toggled( GtkToggleButton *togglebutton,
815                                                                    gpointer user_data ){
816         change_surfaceflag( surface_undulatebutton, HERETIC2_SURF_UNDULATE, ( GTK_TOGGLE_BUTTON( surface_undulatebutton )->active ) );
817 }
818
819
820 void
821 on_surf_gravel_radiobutton_toggled( GtkToggleButton *togglebutton,
822                                                                         gpointer user_data ){
823         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_gravel_radiobutton ) ) ) {
824                 change_material( GTK_WIDGET( togglebutton ) );
825         }
826 }
827
828 void
829 on_surf_metal_radiobutton_toggled( GtkToggleButton *togglebutton,
830                                                                    gpointer user_data ){
831         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_metal_radiobutton ) ) ) {
832                 change_material( GTK_WIDGET( togglebutton ) );
833         }
834 }
835
836 void
837 on_surf_stone_radiobutton_toggled( GtkToggleButton *togglebutton,
838                                                                    gpointer user_data ){
839         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_stone_radiobutton ) ) ) {
840                 change_material( GTK_WIDGET( togglebutton ) );
841         }
842 }
843
844 void
845 on_surf_wood_radiobutton_toggled( GtkToggleButton *togglebutton,
846                                                                   gpointer user_data ){
847         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( surf_wood_radiobutton ) ) ) {
848                 change_material( GTK_WIDGET( togglebutton ) );
849         }
850 }
851
852 // Content Flags Callbacks
853 void
854 on_content_solidbutton_toggled( GtkToggleButton *togglebutton,
855                                                                 gpointer user_data ){
856         change_contentflag( content_solidbutton, HERETIC2_CONTENTS_SOLID, ( GTK_TOGGLE_BUTTON( content_solidbutton )->active ) );
857 }
858
859
860 void
861 on_content_windowbutton_toggled( GtkToggleButton *togglebutton,
862                                                                  gpointer user_data ){
863         change_contentflag( content_windowbutton, HERETIC2_CONTENTS_WINDOW, ( GTK_TOGGLE_BUTTON( content_windowbutton )->active ) );
864 }
865
866
867 void
868 on_content_illusbutton_toggled( GtkToggleButton *togglebutton,
869                                                                 gpointer user_data ){
870         change_contentflag( content_illusbutton, HERETIC2_CONTENTS_ILLUSIONARY, ( GTK_TOGGLE_BUTTON( content_illusbutton )->active ) );
871 }
872
873
874 void
875 on_content_lavabutton_toggled( GtkToggleButton *togglebutton,
876                                                            gpointer user_data ){
877         change_contentflag( content_lavabutton, HERETIC2_CONTENTS_LAVA, ( GTK_TOGGLE_BUTTON( content_lavabutton )->active ) );
878 }
879
880
881 void
882 on_content_slimebutton_toggled( GtkToggleButton *togglebutton,
883                                                                 gpointer user_data ){
884         change_contentflag( content_slimebutton, HERETIC2_CONTENTS_SLIME, ( GTK_TOGGLE_BUTTON( content_slimebutton )->active ) );
885 }
886
887
888 void
889 on_content_waterbutton_toggled( GtkToggleButton *togglebutton,
890                                                                 gpointer user_data ){
891         change_contentflag( content_waterbutton, HERETIC2_CONTENTS_WATER, ( GTK_TOGGLE_BUTTON( content_waterbutton )->active ) );
892 }
893
894
895 void
896 on_content_mistbutton_toggled( GtkToggleButton *togglebutton,
897                                                            gpointer user_data ){
898         change_contentflag( content_mistbutton, HERETIC2_CONTENTS_MIST, ( GTK_TOGGLE_BUTTON( content_mistbutton )->active ) );
899 }
900
901
902 void
903 on_content_areaportalbutton_toggled( GtkToggleButton *togglebutton,
904                                                                          gpointer user_data ){
905         change_contentflag( content_areaportalbutton, HERETIC2_CONTENTS_AREAPORTAL, ( GTK_TOGGLE_BUTTON( content_areaportalbutton )->active ) );
906 }
907
908
909 void
910 on_content_playerclipbutton_toggled( GtkToggleButton *togglebutton,
911                                                                          gpointer user_data ){
912         change_contentflag( content_playerclipbutton, HERETIC2_CONTENTS_PLAYERCLIP, ( GTK_TOGGLE_BUTTON( content_playerclipbutton )->active ) );
913 }
914
915
916 void
917 on_content_monsterclipbutton_toggled( GtkToggleButton *togglebutton,
918                                                                           gpointer user_data ){
919         change_contentflag( content_monsterclipbutton, HERETIC2_CONTENTS_MONSTERCLIP, ( GTK_TOGGLE_BUTTON( content_monsterclipbutton )->active ) );
920 }
921
922
923 void
924 on_content_current0button_toggled( GtkToggleButton *togglebutton,
925                                                                    gpointer user_data ){
926         change_contentflag( content_current0button, HERETIC2_CONTENTS_CURRENT_0, ( GTK_TOGGLE_BUTTON( content_current0button )->active ) );
927 }
928
929
930 void
931 on_content_current90button_toggled( GtkToggleButton *togglebutton,
932                                                                         gpointer user_data ){
933         change_contentflag( content_current90button, HERETIC2_CONTENTS_CURRENT_90, ( GTK_TOGGLE_BUTTON( content_current90button )->active ) );
934 }
935
936
937 void
938 on_content_current180button_toggled( GtkToggleButton *togglebutton,
939                                                                          gpointer user_data ){
940         change_contentflag( content_current180button, HERETIC2_CONTENTS_CURRENT_180, ( GTK_TOGGLE_BUTTON( content_current180button )->active ) );
941 }
942
943
944 void
945 on_content_current270button_toggled( GtkToggleButton *togglebutton,
946                                                                          gpointer user_data ){
947         change_contentflag( content_current270button, HERETIC2_CONTENTS_CURRENT_270, ( GTK_TOGGLE_BUTTON( content_current270button )->active ) );
948 }
949
950
951 void
952 on_content_currentUPbutton_toggled( GtkToggleButton *togglebutton,
953                                                                         gpointer user_data ){
954         change_contentflag( content_currentUPbutton, HERETIC2_CONTENTS_CURRENT_UP, ( GTK_TOGGLE_BUTTON( content_currentUPbutton )->active ) );
955 }
956
957
958 void
959 on_content_currentDOWNbutton_toggled( GtkToggleButton *togglebutton,
960                                                                           gpointer user_data ){
961         change_contentflag( content_currentDOWNbutton, HERETIC2_CONTENTS_CURRENT_DOWN, ( GTK_TOGGLE_BUTTON( content_currentDOWNbutton )->active ) );
962 }
963
964
965 void
966 on_content_originbutton_toggled( GtkToggleButton *togglebutton,
967                                                                  gpointer user_data ){
968         change_contentflag( content_originbutton, HERETIC2_CONTENTS_ORIGIN, ( GTK_TOGGLE_BUTTON( content_originbutton )->active ) );
969 }
970
971
972 void
973 on_content_detailbutton_toggled( GtkToggleButton *togglebutton,
974                                                                  gpointer user_data ){
975         change_contentflag( content_detailbutton, HERETIC2_CONTENTS_DETAIL, ( GTK_TOGGLE_BUTTON( content_detailbutton )->active ) );
976 }
977
978
979 void
980 on_content_ladderbutton_toggled( GtkToggleButton *togglebutton,
981                                                                  gpointer user_data ){
982         change_contentflag( content_ladderbutton, HERETIC2_CONTENTS_LADDER, ( GTK_TOGGLE_BUTTON( content_ladderbutton )->active ) );
983 }
984
985
986 void
987 on_content_camnoblockbutton_toggled( GtkToggleButton *togglebutton,
988                                                                          gpointer user_data ){
989         change_contentflag( content_camnoblockbutton, HERETIC2_CONTENTS_CAMERANOBLOCK, ( GTK_TOGGLE_BUTTON( content_camnoblockbutton )->active ) );
990 }
991
992 // Value Entry Callback
993 void
994 on_surf_value_entry_changed( GtkEditable     *editable,
995                                                          gpointer user_data ){
996         if ( ( !setup_buttons ) ) { // If we're setting up the buttons, don't change value
997                 working_value = atoi( gtk_entry_get_text( (GtkEntry*)editable ) );
998         }
999 }
1000
1001 void
1002 on_surf_value_entry_insert_text( GtkEditable     *editable,
1003                                                                  gchar           *new_text,
1004                                                                  gint new_text_length,
1005                                                                  gint            *position,
1006                                                                  gpointer user_data ){
1007         int i, count = 0;
1008         gchar *result;
1009
1010         // Limit input to digits, throwing out anything else
1011         // Modified from Gtk FAQ for text filtering of GtkEntry
1012         result = g_new( gchar, new_text_length );
1013
1014         for ( i = 0; i < new_text_length; i++ ) {
1015                 if ( !isdigit( new_text[i] ) ) {
1016                         continue;
1017                 }
1018                 result[count++] = new_text[i];
1019         }
1020
1021         if ( count > 0 ) {
1022                 gtk_signal_handler_block_by_func( GTK_OBJECT( editable ),
1023                                                                                   GTK_SIGNAL_FUNC( on_surf_value_entry_insert_text ),
1024                                                                                   user_data );
1025                 gtk_editable_insert_text( editable, result, count, position );
1026                 gtk_signal_handler_unblock_by_func( GTK_OBJECT( editable ),
1027                                                                                         GTK_SIGNAL_FUNC( on_surf_value_entry_insert_text ),
1028                                                                                         user_data );
1029         }
1030         gtk_signal_emit_stop_by_name( GTK_OBJECT( editable ), "insert_text" );
1031
1032         g_free( result );
1033 }
1034
1035 #define HERETIC2_FLAG_BUTTON_BORDER 3
1036
1037 GtkWidget* Create_Heretic2FlagsDialog( GtkWidget* surfacedialog_widget ){
1038         GtkWidget *frame1;
1039         GtkWidget *notebook1;
1040         GtkWidget *vbox3;
1041         GtkWidget *table1;
1042         GtkWidget *frame2;
1043         GtkWidget *hbox4;
1044         GtkWidget *label4;
1045         GtkWidget *table3;
1046         GtkWidget *label5;
1047
1048         GtkWidget *hbox1;
1049         GtkWidget *hbox2;
1050         GtkWidget *label2;
1051         GtkWidget *table2;
1052         GtkWidget *label3;
1053
1054
1055         frame1 = gtk_frame_new( _( "Brush/Face Flags" ) );
1056         gtk_widget_show( frame1 );
1057         gtk_container_add( GTK_CONTAINER( surfacedialog_widget ), frame1 );
1058
1059         notebook1 = gtk_notebook_new();
1060         gtk_widget_show( notebook1 );
1061         gtk_container_add( GTK_CONTAINER( frame1 ), notebook1 );
1062
1063         vbox3 = gtk_vbox_new( FALSE, 0 );
1064         gtk_widget_show( vbox3 );
1065         gtk_container_add( GTK_CONTAINER( notebook1 ), vbox3 );
1066
1067         table1 = gtk_table_new( 3, 4, TRUE );
1068         gtk_widget_show( table1 );
1069         gtk_box_pack_start( GTK_BOX( vbox3 ), table1, TRUE, TRUE, 0 );
1070
1071         surface_lightbutton = gtk_toggle_button_new_with_mnemonic( _( "Light" ) );
1072         gtk_widget_show( surface_lightbutton );
1073         gtk_table_attach( GTK_TABLE( table1 ), surface_lightbutton, 0, 1, 0, 1,
1074                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1075                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1076
1077         surface_slickbutton = gtk_toggle_button_new_with_mnemonic( _( "Slick" ) );
1078         gtk_widget_show( surface_slickbutton );
1079         gtk_table_attach( GTK_TABLE( table1 ), surface_slickbutton, 1, 2, 0, 1,
1080                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1081                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1082
1083         surface_skybutton = gtk_toggle_button_new_with_mnemonic( _( "Sky" ) );
1084         gtk_widget_show( surface_skybutton );
1085         gtk_table_attach( GTK_TABLE( table1 ), surface_skybutton, 2, 3, 0, 1,
1086                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1087                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1088
1089         surface_warpbutton = gtk_toggle_button_new_with_mnemonic( _( "Warp" ) );
1090         gtk_widget_show( surface_warpbutton );
1091         gtk_table_attach( GTK_TABLE( table1 ), surface_warpbutton, 3, 4, 0, 1,
1092                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1093                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1094
1095         surface_trans33button = gtk_toggle_button_new_with_mnemonic( _( "Trans33" ) );
1096         gtk_widget_show( surface_trans33button );
1097         gtk_table_attach( GTK_TABLE( table1 ), surface_trans33button, 0, 1, 1, 2,
1098                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1099                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1100
1101         surface_trans66button = gtk_toggle_button_new_with_mnemonic( _( "Trans66" ) );
1102         gtk_widget_show( surface_trans66button );
1103         gtk_table_attach( GTK_TABLE( table1 ), surface_trans66button, 1, 2, 1, 2,
1104                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1105                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1106
1107         surface_flowingbutton = gtk_toggle_button_new_with_mnemonic( _( "Flowing" ) );
1108         gtk_widget_show( surface_flowingbutton );
1109         gtk_table_attach( GTK_TABLE( table1 ), surface_flowingbutton, 2, 3, 1, 2,
1110                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1111                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1112
1113         surface_nodrawbutton = gtk_toggle_button_new_with_mnemonic( _( "NoDraw" ) );
1114         gtk_widget_show( surface_nodrawbutton );
1115         gtk_table_attach( GTK_TABLE( table1 ), surface_nodrawbutton, 3, 4, 1, 2,
1116                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1117                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1118
1119         surface_tallwallbutton = gtk_toggle_button_new_with_mnemonic( _( "TallWall" ) );
1120         gtk_widget_show( surface_tallwallbutton );
1121         gtk_table_attach( GTK_TABLE( table1 ), surface_tallwallbutton, 0, 1, 2, 3,
1122                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1123                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1124
1125         surface_alphatexbutton = gtk_toggle_button_new_with_mnemonic( _( "AlphaTex" ) );
1126         gtk_widget_show( surface_alphatexbutton );
1127         gtk_table_attach( GTK_TABLE( table1 ), surface_alphatexbutton, 1, 2, 2, 3,
1128                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1129                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1130
1131         surface_animspeedbutton = gtk_toggle_button_new_with_mnemonic( _( "AnimSpeed" ) );
1132         gtk_widget_show( surface_animspeedbutton );
1133         gtk_table_attach( GTK_TABLE( table1 ), surface_animspeedbutton, 2, 3, 2, 3,
1134                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1135                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1136
1137         surface_undulatebutton = gtk_toggle_button_new_with_mnemonic( _( "Undulate" ) );
1138         gtk_widget_show( surface_undulatebutton );
1139         gtk_table_attach( GTK_TABLE( table1 ), surface_undulatebutton, 3, 4, 2, 3,
1140                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1141                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1142
1143         frame2 = gtk_frame_new( NULL );
1144         gtk_widget_show( frame2 );
1145         gtk_box_pack_start( GTK_BOX( vbox3 ), frame2, FALSE, FALSE, 0 );
1146         gtk_frame_set_shadow_type( GTK_FRAME( frame2 ), GTK_SHADOW_ETCHED_OUT );
1147         gtk_container_set_border_width( GTK_CONTAINER( frame2 ), 4 );
1148
1149         hbox4 = gtk_hbox_new( FALSE, 0 );
1150         gtk_widget_show( hbox4 );
1151         gtk_container_add( GTK_CONTAINER( frame2 ), hbox4 );
1152
1153         surf_gravel_radiobutton = gtk_radio_button_new_with_mnemonic( NULL, _( "Gravel" ) );
1154         gtk_widget_show( surf_gravel_radiobutton );
1155         gtk_box_pack_start( GTK_BOX( hbox4 ), surf_gravel_radiobutton, TRUE, FALSE, 0 );
1156
1157         surf_metal_radiobutton = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON( surf_gravel_radiobutton ), _( "Metal" ) );
1158         gtk_widget_show( surf_metal_radiobutton );
1159         gtk_box_pack_start( GTK_BOX( hbox4 ), surf_metal_radiobutton, TRUE, FALSE, 0 );
1160
1161         surf_stone_radiobutton = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON( surf_metal_radiobutton ), _( "Stone" ) );
1162         gtk_widget_show( surf_stone_radiobutton );
1163         gtk_box_pack_start( GTK_BOX( hbox4 ), surf_stone_radiobutton, TRUE, FALSE, 0 );
1164
1165         surf_wood_radiobutton = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON( surf_stone_radiobutton ), _( "Wood" ) );
1166         gtk_widget_show( surf_wood_radiobutton );
1167         gtk_box_pack_start( GTK_BOX( hbox4 ), surf_wood_radiobutton, TRUE, FALSE, 0 );
1168
1169         label4 = gtk_label_new( _( "Material" ) );
1170         gtk_widget_show( label4 );
1171         gtk_frame_set_label_widget( GTK_FRAME( frame2 ), label4 );
1172         gtk_label_set_justify( GTK_LABEL( label4 ), GTK_JUSTIFY_LEFT );
1173
1174         table3 = gtk_table_new( 1, 4, FALSE );
1175         gtk_widget_show( table3 );
1176         gtk_box_pack_start( GTK_BOX( vbox3 ), table3, FALSE, FALSE, 0 );
1177         gtk_container_set_border_width( GTK_CONTAINER( table3 ), 3 );
1178
1179         hbox1 = gtk_hbox_new( FALSE, 0 );
1180         gtk_widget_show( hbox1 );
1181         gtk_table_attach( GTK_TABLE( table3 ), hbox1, 0, 1, 0, 1,
1182                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1183                                           (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
1184
1185         label5 = gtk_label_new( _( "Value: " ) );
1186         gtk_widget_show( label5 );
1187         gtk_table_attach( GTK_TABLE( table3 ), label5, 1, 2, 0, 1,
1188                                           (GtkAttachOptions) ( 0 ),
1189                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1190         gtk_misc_set_alignment( GTK_MISC( label5 ), 0, 0 );
1191         gtk_label_set_justify( GTK_LABEL( label5 ), GTK_JUSTIFY_RIGHT );
1192
1193         surf_value_entry = gtk_entry_new();
1194         gtk_widget_show( surf_value_entry );
1195         gtk_table_attach( GTK_TABLE( table3 ), surf_value_entry, 2, 3, 0, 1,
1196                                           (GtkAttachOptions) ( GTK_FILL ),
1197                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1198
1199         hbox2 = gtk_hbox_new( FALSE, 0 );
1200         gtk_widget_show( hbox2 );
1201         gtk_table_attach( GTK_TABLE( table3 ), hbox2, 3, 4, 0, 1,
1202                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1203                                           (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
1204
1205         label2 = gtk_label_new( _( "Surface Flags" ) );
1206         gtk_widget_show( label2 );
1207         gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ), gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ), 0 ), label2 );
1208         gtk_label_set_justify( GTK_LABEL( label2 ), GTK_JUSTIFY_LEFT );
1209
1210         table2 = gtk_table_new( 5, 4, TRUE );
1211         gtk_widget_show( table2 );
1212         gtk_container_add( GTK_CONTAINER( notebook1 ), table2 );
1213
1214         content_solidbutton = gtk_toggle_button_new_with_mnemonic( _( "Solid" ) );
1215         gtk_widget_show( content_solidbutton );
1216         gtk_table_attach( GTK_TABLE( table2 ), content_solidbutton, 0, 1, 0, 1,
1217                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1218                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1219
1220         content_windowbutton = gtk_toggle_button_new_with_mnemonic( _( "Window" ) );
1221         gtk_widget_show( content_windowbutton );
1222         gtk_table_attach( GTK_TABLE( table2 ), content_windowbutton, 1, 2, 0, 1,
1223                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1224                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1225
1226         content_illusbutton = gtk_toggle_button_new_with_mnemonic( _( "Illusion" ) );
1227         gtk_widget_show( content_illusbutton );
1228         gtk_table_attach( GTK_TABLE( table2 ), content_illusbutton, 2, 3, 0, 1,
1229                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1230                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1231
1232         content_lavabutton = gtk_toggle_button_new_with_mnemonic( _( "Lava" ) );
1233         gtk_widget_show( content_lavabutton );
1234         gtk_table_attach( GTK_TABLE( table2 ), content_lavabutton, 3, 4, 0, 1,
1235                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1236                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1237
1238         content_slimebutton = gtk_toggle_button_new_with_mnemonic( _( "Slime" ) );
1239         gtk_widget_show( content_slimebutton );
1240         gtk_table_attach( GTK_TABLE( table2 ), content_slimebutton, 0, 1, 1, 2,
1241                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1242                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1243
1244         content_waterbutton = gtk_toggle_button_new_with_mnemonic( _( "Water" ) );
1245         gtk_widget_show( content_waterbutton );
1246         gtk_table_attach( GTK_TABLE( table2 ), content_waterbutton, 1, 2, 1, 2,
1247                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1248                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1249
1250         content_mistbutton = gtk_toggle_button_new_with_mnemonic( _( "Mist" ) );
1251         gtk_widget_show( content_mistbutton );
1252         gtk_table_attach( GTK_TABLE( table2 ), content_mistbutton, 2, 3, 1, 2,
1253                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1254                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1255
1256         content_areaportalbutton = gtk_toggle_button_new_with_mnemonic( _( "AreaPortal" ) );
1257         gtk_widget_show( content_areaportalbutton );
1258         gtk_table_attach( GTK_TABLE( table2 ), content_areaportalbutton, 3, 4, 1, 2,
1259                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1260                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1261
1262         content_playerclipbutton = gtk_toggle_button_new_with_mnemonic( _( "PlayerClip" ) );
1263         gtk_widget_show( content_playerclipbutton );
1264         gtk_table_attach( GTK_TABLE( table2 ), content_playerclipbutton, 0, 1, 2, 3,
1265                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1266                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1267
1268         content_monsterclipbutton = gtk_toggle_button_new_with_mnemonic( _( "MonsterClip" ) );
1269         gtk_widget_show( content_monsterclipbutton );
1270         gtk_table_attach( GTK_TABLE( table2 ), content_monsterclipbutton, 1, 2, 2, 3,
1271                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1272                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1273
1274         content_current0button = gtk_toggle_button_new_with_mnemonic( _( "Current 0" ) );
1275         gtk_widget_show( content_current0button );
1276         gtk_table_attach( GTK_TABLE( table2 ), content_current0button, 2, 3, 2, 3,
1277                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1278                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1279
1280         content_current90button = gtk_toggle_button_new_with_mnemonic( _( "Current 90" ) );
1281         gtk_widget_show( content_current90button );
1282         gtk_table_attach( GTK_TABLE( table2 ), content_current90button, 3, 4, 2, 3,
1283                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1284                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1285
1286         content_current180button = gtk_toggle_button_new_with_mnemonic( _( "Current 180" ) );
1287         gtk_widget_show( content_current180button );
1288         gtk_table_attach( GTK_TABLE( table2 ), content_current180button, 0, 1, 3, 4,
1289                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1290                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1291
1292         content_current270button = gtk_toggle_button_new_with_mnemonic( _( "Current 270" ) );
1293         gtk_widget_show( content_current270button );
1294         gtk_table_attach( GTK_TABLE( table2 ), content_current270button, 1, 2, 3, 4,
1295                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1296                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1297
1298         content_currentUPbutton = gtk_toggle_button_new_with_mnemonic( _( "Current UP" ) );
1299         gtk_widget_show( content_currentUPbutton );
1300         gtk_table_attach( GTK_TABLE( table2 ), content_currentUPbutton, 2, 3, 3, 4,
1301                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1302                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1303
1304         content_currentDOWNbutton = gtk_toggle_button_new_with_mnemonic( _( "Current DOWN" ) );
1305         gtk_widget_show( content_currentDOWNbutton );
1306         gtk_table_attach( GTK_TABLE( table2 ), content_currentDOWNbutton, 3, 4, 3, 4,
1307                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1308                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1309
1310         content_originbutton = gtk_toggle_button_new_with_mnemonic( _( "Origin" ) );
1311         gtk_widget_show( content_originbutton );
1312         gtk_table_attach( GTK_TABLE( table2 ), content_originbutton, 0, 1, 4, 5,
1313                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1314                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1315
1316         content_detailbutton = gtk_toggle_button_new_with_mnemonic( _( "Detail" ) );
1317         gtk_widget_show( content_detailbutton );
1318         gtk_table_attach( GTK_TABLE( table2 ), content_detailbutton, 1, 2, 4, 5,
1319                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1320                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1321
1322         content_ladderbutton = gtk_toggle_button_new_with_mnemonic( _( "Ladder" ) );
1323         gtk_widget_show( content_ladderbutton );
1324         gtk_table_attach( GTK_TABLE( table2 ), content_ladderbutton, 2, 3, 4, 5,
1325                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1326                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1327
1328         content_camnoblockbutton = gtk_toggle_button_new_with_mnemonic( _( "Cam No Block" ) );
1329         gtk_widget_show( content_camnoblockbutton );
1330         gtk_table_attach( GTK_TABLE( table2 ), content_camnoblockbutton, 3, 4, 4, 5,
1331                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1332                                           (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 );
1333
1334         label3 = gtk_label_new( _( "Content Flags" ) );
1335         gtk_widget_show( label3 );
1336         gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ), gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ), 1 ), label3 );
1337         gtk_label_set_justify( GTK_LABEL( label3 ), GTK_JUSTIFY_LEFT );
1338
1339         // Signal Connects
1340         g_signal_connect( (gpointer) surface_lightbutton, "toggled",
1341                                           G_CALLBACK( on_surface_lightbutton_toggled ),
1342                                           NULL );
1343         g_signal_connect( (gpointer) surface_slickbutton, "toggled",
1344                                           G_CALLBACK( on_surface_slickbutton_toggled ),
1345                                           NULL );
1346         g_signal_connect( (gpointer) surface_skybutton, "toggled",
1347                                           G_CALLBACK( on_surface_skybutton_toggled ),
1348                                           NULL );
1349         g_signal_connect( (gpointer) surface_warpbutton, "toggled",
1350                                           G_CALLBACK( on_surface_warpbutton_toggled ),
1351                                           NULL );
1352         g_signal_connect( (gpointer) surface_trans33button, "toggled",
1353                                           G_CALLBACK( on_surface_trans33button_toggled ),
1354                                           NULL );
1355         g_signal_connect( (gpointer) surface_trans66button, "toggled",
1356                                           G_CALLBACK( on_surface_trans66button_toggled ),
1357                                           NULL );
1358         g_signal_connect( (gpointer) surface_flowingbutton, "toggled",
1359                                           G_CALLBACK( on_surface_flowingbutton_toggled ),
1360                                           NULL );
1361         g_signal_connect( (gpointer) surface_nodrawbutton, "toggled",
1362                                           G_CALLBACK( on_surface_nodrawbutton_toggled ),
1363                                           NULL );
1364         g_signal_connect( (gpointer) surface_tallwallbutton, "toggled",
1365                                           G_CALLBACK( on_surface_tallwallbutton_toggled ),
1366                                           NULL );
1367         g_signal_connect( (gpointer) surface_alphatexbutton, "toggled",
1368                                           G_CALLBACK( on_surface_alphatexbutton_toggled ),
1369                                           NULL );
1370         g_signal_connect( (gpointer) surface_animspeedbutton, "toggled",
1371                                           G_CALLBACK( on_surface_animspeedbutton_toggled ),
1372                                           NULL );
1373         g_signal_connect( (gpointer) surface_undulatebutton, "toggled",
1374                                           G_CALLBACK( on_surface_undulatebutton_toggled ),
1375                                           NULL );
1376
1377         g_signal_connect( (gpointer) surf_gravel_radiobutton, "toggled",
1378                                           G_CALLBACK( on_surf_gravel_radiobutton_toggled ),
1379                                           NULL );
1380         g_signal_connect( (gpointer) surf_metal_radiobutton, "toggled",
1381                                           G_CALLBACK( on_surf_metal_radiobutton_toggled ),
1382                                           NULL );
1383         g_signal_connect( (gpointer) surf_stone_radiobutton, "toggled",
1384                                           G_CALLBACK( on_surf_stone_radiobutton_toggled ),
1385                                           NULL );
1386         g_signal_connect( (gpointer) surf_wood_radiobutton, "toggled",
1387                                           G_CALLBACK( on_surf_wood_radiobutton_toggled ),
1388                                           NULL );
1389
1390         g_signal_connect( (gpointer) surf_value_entry, "changed",
1391                                           G_CALLBACK( on_surf_value_entry_changed ),
1392                                           NULL );
1393         g_signal_connect( (gpointer) surf_value_entry, "insert_text",
1394                                           G_CALLBACK( on_surf_value_entry_insert_text ),
1395                                           NULL );
1396         g_signal_connect( (gpointer) content_solidbutton, "toggled",
1397                                           G_CALLBACK( on_content_solidbutton_toggled ),
1398                                           NULL );
1399         g_signal_connect( (gpointer) content_windowbutton, "toggled",
1400                                           G_CALLBACK( on_content_windowbutton_toggled ),
1401                                           NULL );
1402         g_signal_connect( (gpointer) content_illusbutton, "toggled",
1403                                           G_CALLBACK( on_content_illusbutton_toggled ),
1404                                           NULL );
1405         g_signal_connect( (gpointer) content_lavabutton, "toggled",
1406                                           G_CALLBACK( on_content_lavabutton_toggled ),
1407                                           NULL );
1408         g_signal_connect( (gpointer) content_slimebutton, "toggled",
1409                                           G_CALLBACK( on_content_slimebutton_toggled ),
1410                                           NULL );
1411         g_signal_connect( (gpointer) content_waterbutton, "toggled",
1412                                           G_CALLBACK( on_content_waterbutton_toggled ),
1413                                           NULL );
1414         g_signal_connect( (gpointer) content_mistbutton, "toggled",
1415                                           G_CALLBACK( on_content_mistbutton_toggled ),
1416                                           NULL );
1417         g_signal_connect( (gpointer) content_areaportalbutton, "toggled",
1418                                           G_CALLBACK( on_content_areaportalbutton_toggled ),
1419                                           NULL );
1420         g_signal_connect( (gpointer) content_playerclipbutton, "toggled",
1421                                           G_CALLBACK( on_content_playerclipbutton_toggled ),
1422                                           NULL );
1423         g_signal_connect( (gpointer) content_monsterclipbutton, "toggled",
1424                                           G_CALLBACK( on_content_monsterclipbutton_toggled ),
1425                                           NULL );
1426         g_signal_connect( (gpointer) content_current0button, "toggled",
1427                                           G_CALLBACK( on_content_current0button_toggled ),
1428                                           NULL );
1429         g_signal_connect( (gpointer) content_current90button, "toggled",
1430                                           G_CALLBACK( on_content_current90button_toggled ),
1431                                           NULL );
1432         g_signal_connect( (gpointer) content_current180button, "toggled",
1433                                           G_CALLBACK( on_content_current180button_toggled ),
1434                                           NULL );
1435         g_signal_connect( (gpointer) content_current270button, "toggled",
1436                                           G_CALLBACK( on_content_current270button_toggled ),
1437                                           NULL );
1438         g_signal_connect( (gpointer) content_currentUPbutton, "toggled",
1439                                           G_CALLBACK( on_content_currentUPbutton_toggled ),
1440                                           NULL );
1441         g_signal_connect( (gpointer) content_currentDOWNbutton, "toggled",
1442                                           G_CALLBACK( on_content_currentDOWNbutton_toggled ),
1443                                           NULL );
1444         g_signal_connect( (gpointer) content_originbutton, "toggled",
1445                                           G_CALLBACK( on_content_originbutton_toggled ),
1446                                           NULL );
1447         g_signal_connect( (gpointer) content_detailbutton, "toggled",
1448                                           G_CALLBACK( on_content_detailbutton_toggled ),
1449                                           NULL );
1450         g_signal_connect( (gpointer) content_ladderbutton, "toggled",
1451                                           G_CALLBACK( on_content_ladderbutton_toggled ),
1452                                           NULL );
1453         g_signal_connect( (gpointer) content_camnoblockbutton, "toggled",
1454                                           G_CALLBACK( on_content_camnoblockbutton_toggled ),
1455                                           NULL );
1456
1457
1458         return frame1;
1459 }