Wrap GtkListStore
[xonotic/netradiant.git] / contrib / bobtoolz / dialogs / dialogs-gtk.cpp
1 /*
2    BobToolz plugin for GtkRadiant
3    Copyright (C) 2001 Gordon Biggans
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include "dialogs-gtk.h"
21 #include "../funchandlers.h"
22
23 #include "str.h"
24 #include <list>
25 #include <gtk/gtk.h>
26 #include "gtkutil/pointer.h"
27
28 #include "../lists.h"
29 #include "../misc.h"
30
31
32 /*--------------------------------
33         Callback Functions
34    ---------------------------------*/
35
36 typedef struct {
37         GtkWidget *cbTexChange;
38         GtkWidget *editTexOld, *editTexNew;
39
40         GtkWidget *cbScaleHor, *cbScaleVert;
41         GtkWidget *editScaleHor, *editScaleVert;
42
43         GtkWidget *cbShiftHor, *cbShiftVert;
44         GtkWidget *editShiftHor, *editShiftVert;
45
46         GtkWidget *cbRotation;
47         GtkWidget *editRotation;
48 }dlg_texReset_t;
49
50 dlg_texReset_t dlgTexReset;
51
52 void Update_TextureReseter();
53
54 static void dialog_button_callback_texreset_update( GtkWidget *widget, gpointer data ){
55         Update_TextureReseter();
56 }
57
58 void Update_TextureReseter(){
59         gboolean check;
60
61         check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
62         gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexNew ), check );
63         gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexOld ), check );
64
65         check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
66         gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleHor ), check );
67
68         check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
69         gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleVert ), check );
70
71         check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
72         gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftHor ), check );
73
74         check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
75         gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftVert ), check );
76
77         check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
78         gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check );
79 }
80
81 static void dialog_button_callback( GtkWidget *widget, gpointer data ){
82         GtkWidget *parent;
83         int *loop;
84         EMessageBoxReturn *ret;
85
86         parent = gtk_widget_get_toplevel( widget );
87         loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
88         ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" );
89
90         *loop = 0;
91         *ret = (EMessageBoxReturn)gpointer_to_int( data );
92 }
93
94 static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
95         int *loop;
96
97         gtk_widget_hide( widget );
98         loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
99         *loop = 0;
100
101         return TRUE;
102 }
103
104 static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){
105         TwinWidget* tw = (TwinWidget*)data;
106
107         GtkEntry* entry = GTK_ENTRY( tw->one );
108         auto* combo = GTK_BIN(tw->two);
109
110         const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
111         gtk_entry_set_text( entry, tex );
112 }
113
114 /*--------------------------------
115     Data validation Routines
116    ---------------------------------*/
117
118 bool ValidateTextFloat( const char* pData, char* error_title, float* value ){
119         if ( pData ) {
120                 float testNum = (float)atof( pData );
121
122                 if ( ( testNum == 0.0f ) && strcmp( pData, "0" ) ) {
123                         DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
124                         return FALSE;
125                 }
126                 else
127                 {
128                         *value = testNum;
129                         return TRUE;
130                 }
131         }
132
133         DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
134         return FALSE;
135 }
136
137 bool ValidateTextFloatRange( const char* pData, float min, float max, char* error_title, float* value ){
138         char error_buffer[256];
139         sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max );
140
141         if ( pData ) {
142                 float testNum = (float)atof( pData );
143
144                 if ( ( testNum < min ) || ( testNum > max ) ) {
145                         DoMessageBox( error_buffer, error_title, eMB_OK );
146                         return FALSE;
147                 }
148                 else
149                 {
150                         *value = testNum;
151                         return TRUE;
152                 }
153         }
154
155         DoMessageBox( error_buffer, error_title, eMB_OK );
156         return FALSE;
157 }
158
159 bool ValidateTextIntRange( const char* pData, int min, int max, char* error_title, int* value ){
160         char error_buffer[256];
161         sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max );
162
163         if ( pData ) {
164                 int testNum = atoi( pData );
165
166                 if ( ( testNum < min ) || ( testNum > max ) ) {
167                         DoMessageBox( error_buffer, error_title, eMB_OK );
168                         return FALSE;
169                 }
170                 else
171                 {
172                         *value = testNum;
173                         return TRUE;
174                 }
175         }
176
177         DoMessageBox( error_buffer, error_title, eMB_OK );
178         return FALSE;
179 }
180
181 bool ValidateTextInt( const char* pData, char* error_title, int* value ){
182         if ( pData ) {
183                 int testNum = atoi( pData );
184
185                 if ( ( testNum == 0 ) && strcmp( pData, "0" ) ) {
186                         DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
187                         return FALSE;
188                 }
189                 else
190                 {
191                         *value = testNum;
192                         return TRUE;
193                 }
194         }
195
196         DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
197         return FALSE;
198 }
199
200 /*--------------------------------
201         Modal Dialog Boxes
202    ---------------------------------*/
203
204 /*
205
206    Major clean up of variable names etc required, excluding Mars's ones,
207    which are nicely done :)
208
209  */
210
211 EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){
212         ui::Widget window, w, vbox, hbox;
213         EMessageBoxReturn ret;
214         int loop = 1;
215
216         window = ui::Window( ui::window_type::TOP );
217         g_signal_connect( GTK_OBJECT( window ), "delete_event",
218                                                 G_CALLBACK( dialog_delete_callback ), NULL );
219         g_signal_connect( GTK_OBJECT( window ), "destroy",
220                                                 G_CALLBACK( gtk_widget_destroy ), NULL );
221         gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
222         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
223         g_object_set_data( G_OBJECT( window ), "loop", &loop );
224         g_object_set_data( G_OBJECT( window ), "ret", &ret );
225         gtk_widget_realize( window );
226
227         vbox = ui::VBox( FALSE, 10 );
228         gtk_container_add( GTK_CONTAINER( window ), vbox );
229         gtk_widget_show( vbox );
230
231         w = ui::Label( lpText );
232         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
233         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
234         gtk_widget_show( w );
235
236         w = ui::Widget(gtk_hseparator_new());
237         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
238         gtk_widget_show( w );
239
240         hbox = ui::HBox( FALSE, 10 );
241         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
242         gtk_widget_show( hbox );
243
244         if ( type == eMB_OK ) {
245                 w = ui::Button( "Ok" );
246                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
247                 g_signal_connect( GTK_OBJECT( w ), "clicked",
248                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
249                 gtk_widget_set_can_default(w, true);
250                 gtk_widget_grab_default( w );
251                 gtk_widget_show( w );
252                 ret = eIDOK;
253         }
254         else if ( type ==  eMB_OKCANCEL ) {
255                 w = ui::Button( "Ok" );
256                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
257                 g_signal_connect( GTK_OBJECT( w ), "clicked",
258                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
259                 gtk_widget_set_can_default( w, true );
260                 gtk_widget_grab_default( w );
261                 gtk_widget_show( w );
262
263                 w = ui::Button( "Cancel" );
264                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
265                 g_signal_connect( GTK_OBJECT( w ), "clicked",
266                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
267                 gtk_widget_show( w );
268                 ret = eIDCANCEL;
269         }
270         else if ( type == eMB_YESNOCANCEL ) {
271                 w = ui::Button( "Yes" );
272                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
273                 g_signal_connect( GTK_OBJECT( w ), "clicked",
274                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
275                 gtk_widget_set_can_default( w, true );
276                 gtk_widget_grab_default( w );
277                 gtk_widget_show( w );
278
279                 w = ui::Button( "No" );
280                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
281                 g_signal_connect( GTK_OBJECT( w ), "clicked",
282                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
283                 gtk_widget_show( w );
284
285                 w = ui::Button( "Cancel" );
286                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
287                 g_signal_connect( GTK_OBJECT( w ), "clicked",
288                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
289                 gtk_widget_show( w );
290                 ret = eIDCANCEL;
291         }
292         else /* if (mode == MB_YESNO) */
293         {
294                 w = ui::Button( "Yes" );
295                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
296                 g_signal_connect( GTK_OBJECT( w ), "clicked",
297                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
298                 gtk_widget_set_can_default( w, true );
299                 gtk_widget_grab_default( w );
300                 gtk_widget_show( w );
301
302                 w = ui::Button( "No" );
303                 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
304                 g_signal_connect( GTK_OBJECT( w ), "clicked",
305                                                         G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
306                 gtk_widget_show( w );
307                 ret = eIDNO;
308         }
309
310         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
311         gtk_widget_show( window );
312         gtk_grab_add( window );
313
314         while ( loop )
315                 gtk_main_iteration();
316
317         gtk_grab_remove( window );
318         gtk_widget_destroy( window );
319
320         return ret;
321 }
322
323 EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
324         GtkWidget *window, *w, *vbox, *hbox;
325         GtkWidget *check1, *check2;
326         EMessageBoxReturn ret;
327         int loop = 1;
328
329         window = ui::Window( ui::window_type::TOP );
330
331         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
332         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
333
334         gtk_window_set_title( GTK_WINDOW( window ), "Intersect" );
335         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
336
337         g_object_set_data( G_OBJECT( window ), "loop", &loop );
338         g_object_set_data( G_OBJECT( window ), "ret", &ret );
339
340         gtk_widget_realize( window );
341
342
343
344         vbox = ui::VBox( FALSE, 10 );
345         gtk_container_add( GTK_CONTAINER( window ), vbox );
346         gtk_widget_show( vbox );
347
348         // ---- vbox ----
349
350
351         auto radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" );
352         gtk_box_pack_start( GTK_BOX( vbox ), radio1, FALSE, FALSE, 2 );
353         gtk_widget_show( radio1 );
354
355         auto radio2 = gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" );
356         gtk_box_pack_start( GTK_BOX( vbox ), radio2, FALSE, FALSE, 2 );
357         gtk_widget_show( radio2 );
358
359         w = gtk_hseparator_new();
360         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
361         gtk_widget_show( w );
362
363         check1 = ui::CheckButton( "Include Detail Brushes" );
364         gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
365         gtk_widget_show( check1 );
366
367         check2 = ui::CheckButton( "Select Duplicate Brushes Only" );
368         gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
369         gtk_widget_show( check2 );
370
371         hbox = ui::HBox( FALSE, 10 );
372         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
373         gtk_widget_show( hbox );
374
375         // ---- hbox ---- ok/cancel buttons
376
377         w = ui::Button( "Ok" );
378         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
379         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
380
381         gtk_widget_set_can_default( w, true );
382         gtk_widget_grab_default( w );
383         gtk_widget_show( w );
384
385         w = ui::Button( "Cancel" );
386         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
387         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
388         gtk_widget_show( w );
389         ret = eIDCANCEL;
390
391         // ---- /hbox ----
392
393         // ---- /vbox ----
394
395         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
396         gtk_widget_show( window );
397         gtk_grab_add( window );
398
399         while ( loop )
400                 gtk_main_iteration();
401
402         if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio1 ) ) {
403                 rs->nBrushOptions = BRUSH_OPT_WHOLE_MAP;
404         }
405         else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio2 ) ) {
406                 rs->nBrushOptions = BRUSH_OPT_SELECTED;
407         }
408
409         rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
410         rs->bDuplicateOnly = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
411
412         gtk_grab_remove( window );
413         gtk_widget_destroy( window );
414
415         return ret;
416 }
417
418 EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
419         GtkWidget *window, *w, *vbox, *hbox, *vbox2, *hbox2;
420
421         GtkWidget *check1, *check2, *check3;
422         GtkWidget *text1, *text2;
423
424         EMessageBoxReturn ret;
425         int loop = 1;
426
427         window = ui::Window( ui::window_type::TOP );
428
429         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
430         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
431
432         gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" );
433         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
434
435         g_object_set_data( G_OBJECT( window ), "loop", &loop );
436         g_object_set_data( G_OBJECT( window ), "ret", &ret );
437
438         gtk_widget_realize( window );
439
440
441
442         vbox = ui::VBox( FALSE, 10 );
443         gtk_container_add( GTK_CONTAINER( window ), vbox );
444         gtk_widget_show( vbox );
445
446         // ---- vbox ----
447
448         hbox = ui::HBox( FALSE, 10 );
449         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
450         gtk_widget_show( hbox );
451
452         // ---- hbox ----
453
454
455         vbox2 = ui::VBox( FALSE, 10 );
456         gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
457         gtk_widget_show( vbox2 );
458
459         // ---- vbox2 ----
460
461         hbox2 = ui::HBox( FALSE, 10 );
462         gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
463         gtk_widget_show( hbox2 );
464
465         // ---- hbox2 ----
466
467         text1 = ui::Entry( 256 );
468         gtk_entry_set_text( (GtkEntry*)text1, "3" );
469         gtk_box_pack_start( GTK_BOX( hbox2 ), text1, FALSE, FALSE, 2 );
470         gtk_widget_show( text1 );
471
472         w = ui::Label( "Number Of Sides" );
473         gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 );
474         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
475         gtk_widget_show( w );
476
477         // ---- /hbox2 ----
478
479         hbox2 = ui::HBox( FALSE, 10 );
480         gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
481         gtk_widget_show( hbox2 );
482
483         // ---- hbox2 ----
484
485         text2 = ui::Entry( 256 );
486         gtk_entry_set_text( (GtkEntry*)text2, "8" );
487         gtk_box_pack_start( GTK_BOX( hbox2 ), text2, FALSE, FALSE, 2 );
488         gtk_widget_show( text2 );
489
490         w = ui::Label( "Border Width" );
491         gtk_box_pack_start( GTK_BOX( hbox2 ), w, FALSE, FALSE, 2 );
492         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
493         gtk_widget_show( w );
494
495         // ---- /hbox2 ----
496
497         // ---- /vbox2 ----
498
499
500
501         vbox2 = ui::VBox( FALSE, 10 );
502         gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
503         gtk_widget_show( vbox2 );
504
505         // ---- vbox2 ----
506
507         check1 = ui::CheckButton( "Use Border" );
508         gtk_box_pack_start( GTK_BOX( vbox2 ), check1, FALSE, FALSE, 0 );
509         gtk_widget_show( check1 );
510
511
512         check2 = ui::CheckButton( "Inverse Polygon" );
513         gtk_box_pack_start( GTK_BOX( vbox2 ), check2, FALSE, FALSE, 0 );
514         gtk_widget_show( check2 );
515
516
517         check3 = ui::CheckButton( "Align Top Edge" );
518         gtk_box_pack_start( GTK_BOX( vbox2 ), check3, FALSE, FALSE, 0 );
519         gtk_widget_show( check3 );
520
521         // ---- /vbox2 ----
522
523         // ---- /hbox ----
524
525         hbox = ui::HBox( FALSE, 10 );
526         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
527         gtk_widget_show( hbox );
528
529         // ---- hbox ----
530
531         w = ui::Button( "Ok" );
532         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
533         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
534
535         gtk_widget_set_can_default( w, true );
536         gtk_widget_grab_default( w );
537         gtk_widget_show( w );
538
539         w = ui::Button( "Cancel" );
540         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
541         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
542         gtk_widget_show( w );
543         ret = eIDCANCEL;
544
545         // ---- /hbox ----
546
547         // ---- /vbox ----
548
549         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
550         gtk_widget_show( window );
551         gtk_grab_add( window );
552
553         bool dialogError = TRUE;
554         while ( dialogError )
555         {
556                 loop = 1;
557                 while ( loop )
558                         gtk_main_iteration();
559
560                 dialogError = FALSE;
561
562                 if ( ret == eIDOK ) {
563                         rs->bUseBorder = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
564                         rs->bInverse = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
565                         rs->bAlignTop = gtk_toggle_button_get_active( (GtkToggleButton*)check3 ) ? true : false;
566
567                         if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
568                                 dialogError = TRUE;
569                         }
570
571                         if ( rs->bUseBorder ) {
572                                 if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
573                                         dialogError = TRUE;
574                                 }
575                         }
576                 }
577         }
578
579         gtk_grab_remove( window );
580         gtk_widget_destroy( window );
581
582         return ret;
583 }
584
585 // mars
586 // for stair builder stuck as close as i could to the MFC version
587 // obviously feel free to change it at will :)
588 EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
589         // i made widgets for just about everything ... i think that's what i need to do  dunno tho
590         GtkWidget   *window, *w, *vbox, *hbox;
591         GtkWidget   *textStairHeight, *textRiserTex, *textMainTex;
592         GtkWidget   *radioNorth, *radioSouth, *radioEast, *radioWest;   // i'm guessing we can't just abuse 'w' for these if we're getting a value
593         GtkWidget   *radioOldStyle, *radioBobStyle, *radioCornerStyle;
594         GtkWidget   *checkUseDetail;
595         GSList      *radioDirection, *radioStyle;
596         EMessageBoxReturn ret;
597         int loop = 1;
598
599         char *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
600
601         window = ui::Window( ui::window_type::TOP );
602
603         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
604         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
605
606         gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" );
607
608         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
609
610         g_object_set_data( G_OBJECT( window ), "loop", &loop );
611         g_object_set_data( G_OBJECT( window ), "ret", &ret );
612
613         gtk_widget_realize( window );
614
615         // new vbox
616         vbox = ui::VBox( FALSE, 10 );
617         gtk_container_add( GTK_CONTAINER( window ), vbox );
618         gtk_widget_show( vbox );
619
620         hbox = ui::HBox( FALSE, 10 );
621         gtk_container_add( GTK_CONTAINER( vbox ), hbox );
622         gtk_widget_show( hbox );
623
624         // dunno if you want this text or not ...
625         w = ui::Label( text );
626         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
627         gtk_widget_show( w );
628
629         w = gtk_hseparator_new();
630         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
631         gtk_widget_show( w );
632
633         // ------------------------- // indenting == good way of keeping track of lines :)
634
635         // new hbox
636         hbox = ui::HBox( FALSE, 10 );
637         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
638         gtk_widget_show( hbox );
639
640         textStairHeight = ui::Entry( 256 );
641         gtk_box_pack_start( GTK_BOX( hbox ), textStairHeight, FALSE, FALSE, 1 );
642         gtk_widget_show( textStairHeight );
643
644         w = ui::Label( "Stair Height" );
645         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
646         gtk_widget_show( w );
647
648         // ------------------------- //
649
650         hbox = ui::HBox( FALSE, 10 );
651         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
652         gtk_widget_show( hbox );
653
654         w = ui::Label( "Direction:" );
655         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
656         gtk_widget_show( w );
657
658         // -------------------------- //
659
660         hbox = ui::HBox( FALSE, 10 );
661         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
662         gtk_widget_show( hbox );
663
664         // radio buttons confuse me ...
665         // but this _looks_ right
666
667         // djbob: actually it looks very nice :), slightly better than the way i did it
668         // edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
669
670         radioNorth = gtk_radio_button_new_with_label( NULL, "North" );
671         gtk_box_pack_start( GTK_BOX( hbox ), radioNorth, FALSE, FALSE, 3 );
672         gtk_widget_show( radioNorth );
673
674         radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
675
676         radioSouth = gtk_radio_button_new_with_label( radioDirection, "South" );
677         gtk_box_pack_start( GTK_BOX( hbox ), radioSouth, FALSE, FALSE, 2 );
678         gtk_widget_show( radioSouth );
679
680         radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
681
682         radioEast = gtk_radio_button_new_with_label( radioDirection, "East" );
683         gtk_box_pack_start( GTK_BOX( hbox ), radioEast, FALSE, FALSE, 1 );
684         gtk_widget_show( radioEast );
685
686         radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
687
688         radioWest = gtk_radio_button_new_with_label( radioDirection, "West" );
689         gtk_box_pack_start( GTK_BOX( hbox ), radioWest, FALSE, FALSE, 0 );
690         gtk_widget_show( radioWest );
691
692         // --------------------------- //
693
694         hbox = ui::HBox( FALSE, 10 );
695         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
696         gtk_widget_show( hbox );
697
698         w = ui::Label( "Style:" );
699         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
700         gtk_widget_show( w );
701
702         // --------------------------- //
703
704         hbox = ui::HBox( FALSE, 10 );
705         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
706         gtk_widget_show( hbox );
707
708         radioOldStyle = gtk_radio_button_new_with_label( NULL, "Original" );
709         gtk_box_pack_start( GTK_BOX( hbox ), radioOldStyle, FALSE, FALSE, 0 );
710         gtk_widget_show( radioOldStyle );
711
712         radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
713
714         radioBobStyle = gtk_radio_button_new_with_label( radioStyle, "Bob's Style" );
715         gtk_box_pack_start( GTK_BOX( hbox ), radioBobStyle, FALSE, FALSE, 0 );
716         gtk_widget_show( radioBobStyle );
717
718         radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
719
720         radioCornerStyle = gtk_radio_button_new_with_label( radioStyle, "Corner Style" );
721         gtk_box_pack_start( GTK_BOX( hbox ), radioCornerStyle, FALSE, FALSE, 0 );
722         gtk_widget_show( radioCornerStyle );
723
724         // err, the q3r has an if or something so you need bob style checked before this
725         // is "ungreyed out" but you'll need to do that, as i suck :)
726
727         // djbob: er.... yeah um, im not at all sure how i'm gonna sort this
728         // djbob: think we need some button callback functions or smuffin
729         // FIXME: actually get around to doing what i suggested!!!!
730
731         checkUseDetail = ui::CheckButton( "Use Detail Brushes" );
732         gtk_box_pack_start( GTK_BOX( hbox ), checkUseDetail, FALSE, FALSE, 0 );
733         gtk_widget_show( checkUseDetail );
734
735         // --------------------------- //
736
737         hbox = ui::HBox( FALSE, 10 );
738         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
739         gtk_widget_show( hbox );
740
741         textMainTex = ui::Entry( 512 );
742         gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture );
743         gtk_box_pack_start( GTK_BOX( hbox ), textMainTex, FALSE, FALSE, 0 );
744         gtk_widget_show( textMainTex );
745
746         w = ui::Label( "Main Texture" );
747         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
748         gtk_widget_show( w );
749
750         // -------------------------- //
751
752         hbox = ui::HBox( FALSE, 10 );
753         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
754         gtk_widget_show( hbox );
755
756         textRiserTex = ui::Entry( 512 );
757         gtk_box_pack_start( GTK_BOX( hbox ), textRiserTex, FALSE, FALSE, 0 );
758         gtk_widget_show( textRiserTex );
759
760         w = ui::Label( "Riser Texture" );
761         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
762         gtk_widget_show( w );
763
764         // -------------------------- //
765         w = gtk_hseparator_new();
766         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
767         gtk_widget_show( w );
768
769         hbox = ui::HBox( FALSE, 10 );
770         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
771         gtk_widget_show( hbox );
772
773         w = ui::Button( "OK" );
774         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
775         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
776         gtk_widget_set_can_default( w, true );
777         gtk_widget_grab_default( w );
778         gtk_widget_show( w );
779
780         w = ui::Button( "Cancel" );
781         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
782         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
783         gtk_widget_show( w );
784
785         ret = eIDCANCEL;
786
787 // +djbob: need our "little" modal loop mars :P
788         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
789         gtk_widget_show( window );
790         gtk_grab_add( window );
791
792         bool dialogError = TRUE;
793         while ( dialogError )
794         {
795                 loop = 1;
796                 while ( loop )
797                         gtk_main_iteration();
798
799                 dialogError = FALSE;
800
801                 if ( ret == eIDOK ) {
802                         rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)checkUseDetail ) ? true : false;
803
804                         strcpy( rs->riserTexture, gtk_entry_get_text( (GtkEntry*)textRiserTex ) );
805                         strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)textMainTex ) );
806
807                         if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioNorth ) ) {
808                                 rs->direction = MOVE_NORTH;
809                         }
810                         else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioSouth ) ) {
811                                 rs->direction = MOVE_SOUTH;
812                         }
813                         else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioEast ) ) {
814                                 rs->direction = MOVE_EAST;
815                         }
816                         else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioWest ) ) {
817                                 rs->direction = MOVE_WEST;
818                         }
819
820                         if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
821                                 dialogError = TRUE;
822                         }
823
824                         if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioOldStyle ) ) {
825                                 rs->style = STYLE_ORIGINAL;
826                         }
827                         else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioBobStyle ) ) {
828                                 rs->style = STYLE_BOB;
829                         }
830                         else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioCornerStyle ) ) {
831                                 rs->style = STYLE_CORNER;
832                         }
833                 }
834         }
835
836         gtk_grab_remove( window );
837         gtk_widget_destroy( window );
838
839         return ret;
840 // -djbob
841
842         // there we go, all done ... on my end at least, not bad for a night's work
843 }
844
845 EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
846         GtkWidget   *window, *hbox, *vbox, *w;
847         GtkWidget   *textFrontBackTex, *textTrimTex;
848         GtkWidget   *checkScaleMainH, *checkScaleMainV, *checkScaleTrimH, *checkScaleTrimV;
849         GtkWidget   *comboMain, *comboTrim;
850         GtkWidget   *buttonSetMain, *buttonSetTrim;
851         GtkWidget   *radioNS, *radioEW;
852         GSList      *radioOrientation;
853         TwinWidget tw1, tw2;
854         EMessageBoxReturn ret;
855         int loop = 1;
856
857         window = ui::Window( ui::window_type::TOP );
858
859         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
860         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
861
862         gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" );
863
864         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
865
866         g_object_set_data( G_OBJECT( window ), "loop", &loop );
867         g_object_set_data( G_OBJECT( window ), "ret", &ret );
868
869         gtk_widget_realize( window );
870
871         char buffer[256];
872         ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
873         ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
874         LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
875         LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
876
877         vbox = ui::VBox( FALSE, 10 );
878         gtk_container_add( GTK_CONTAINER( window ), vbox );
879         gtk_widget_show( vbox );
880
881         // -------------------------- //
882
883         hbox = ui::HBox( FALSE, 10 );
884         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
885         gtk_widget_show( hbox );
886
887         textFrontBackTex = ui::Entry( 512 );
888         gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture );
889         gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 );
890         gtk_widget_show( textFrontBackTex );
891
892         w = ui::Label( "Door Front/Back Texture" );
893         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
894         gtk_widget_show( w );
895
896         // ------------------------ //
897
898         hbox = ui::HBox( FALSE, 10 );
899         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
900         gtk_widget_show( hbox );
901
902         textTrimTex = ui::Entry( 512 );
903         gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 );
904         gtk_widget_show( textTrimTex );
905
906         w = ui::Label( "Door Trim Texture" );
907         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
908         gtk_widget_show( w );
909
910         // ----------------------- //
911
912         hbox = ui::HBox( FALSE, 10 );
913         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
914         gtk_widget_show( hbox );
915
916         // sp: horizontally ????
917         // djbob: yes mars, u can spell :]
918         checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" );
919         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE );
920         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainH, FALSE, FALSE, 0 );
921         gtk_widget_show( checkScaleMainH );
922
923         checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" );
924         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE );
925         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimH, FALSE, FALSE, 0 );
926         gtk_widget_show( checkScaleTrimH );
927
928         // ---------------------- //
929
930         hbox = ui::HBox( FALSE, 10 );
931         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
932         gtk_widget_show( hbox );
933
934         checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" );
935         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE );
936         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainV, FALSE, FALSE, 0 );
937         gtk_widget_show( checkScaleMainV );
938
939         checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" );
940         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimV, FALSE, FALSE, 0 );
941         gtk_widget_show( checkScaleTrimV );
942
943         // --------------------- //
944
945         hbox = ui::HBox( FALSE, 10 );
946         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
947         gtk_widget_show( hbox );
948
949         // djbob: lists added
950
951         comboMain = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures));
952         gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
953         gtk_box_pack_start( GTK_BOX( hbox ), comboMain, FALSE, FALSE, 0 );
954         gtk_widget_show( comboMain );
955
956         tw1.one = textFrontBackTex;
957         tw1.two = GTK_COMBO_BOX(comboMain);
958
959         buttonSetMain = ui::Button( "Set As Main Texture" );
960         g_signal_connect( GTK_OBJECT( buttonSetMain ), "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 );
961         gtk_box_pack_start( GTK_BOX( hbox ), buttonSetMain, FALSE, FALSE, 0 );
962         gtk_widget_show( buttonSetMain );
963
964         // ------------------- //
965
966         hbox = ui::HBox( FALSE, 10 );
967         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
968         gtk_widget_show( hbox );
969
970         comboTrim = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures));
971         gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
972         gtk_box_pack_start( GTK_BOX( hbox ), comboTrim, FALSE, FALSE, 0 );
973         gtk_widget_show( comboTrim );
974
975         tw2.one = textTrimTex;
976         tw2.two = GTK_COMBO_BOX(comboTrim);
977
978         buttonSetTrim = ui::Button( "Set As Trim Texture" );
979         g_signal_connect( GTK_OBJECT( buttonSetTrim ), "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 );
980         gtk_box_pack_start( GTK_BOX( hbox ), buttonSetTrim, FALSE, FALSE, 0 );
981         gtk_widget_show( buttonSetTrim );
982
983         // ------------------ //
984
985         hbox = ui::HBox( FALSE, 10 );
986         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
987         gtk_widget_show( hbox );
988
989         w = ui::Label( "Orientation" );
990         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
991         gtk_widget_show( w );
992
993         // argh more radio buttons!
994         radioNS = gtk_radio_button_new_with_label( NULL, "North - South" );
995         gtk_box_pack_start( GTK_BOX( hbox ), radioNS, FALSE, FALSE, 0 );
996         gtk_widget_show( radioNS );
997
998         radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
999
1000         radioEW = gtk_radio_button_new_with_label( radioOrientation, "East - West" );
1001         gtk_box_pack_start( GTK_BOX( hbox ), radioEW, FALSE, FALSE, 0 );
1002         gtk_widget_show( radioEW );
1003
1004         // ----------------- //
1005
1006         w = gtk_hseparator_new();
1007         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1008         gtk_widget_show( w );
1009
1010         // ----------------- //
1011
1012         hbox = ui::HBox( FALSE, 10 );
1013         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1014         gtk_widget_show( hbox );
1015
1016         w = ui::Button( "OK" );
1017         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1018         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1019         gtk_widget_set_can_default( w, true );
1020         gtk_widget_grab_default( w );
1021         gtk_widget_show( w );
1022
1023         w = ui::Button( "Cancel" );
1024         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1025         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1026         gtk_widget_show( w );
1027         ret = eIDCANCEL;
1028
1029         // ----------------- //
1030
1031 //+djbob
1032         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1033         gtk_widget_show( window );
1034         gtk_grab_add( window );
1035
1036         while ( loop )
1037                 gtk_main_iteration();
1038
1039         strcpy( rs->mainTexture, gtk_entry_get_text( GTK_ENTRY( textFrontBackTex ) ) );
1040         strcpy( rs->trimTexture, gtk_entry_get_text( GTK_ENTRY( textTrimTex ) ) );
1041
1042         rs->bScaleMainH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainH ) ) ? true : false;
1043         rs->bScaleMainV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainV ) ) ? true : false;
1044         rs->bScaleTrimH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ) ) ? true : false;
1045         rs->bScaleTrimV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimV ) ) ? true : false;
1046
1047         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioNS ) ) ) {
1048                 rs->nOrientation = DIRECTION_NS;
1049         }
1050         else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioEW ) ) ) {
1051                 rs->nOrientation = DIRECTION_EW;
1052         }
1053
1054         gtk_grab_remove( window );
1055         gtk_widget_destroy( window );
1056
1057         return ret;
1058 //-djbob
1059 }
1060
1061 EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
1062         GtkWidget *window, *w, *vbox, *hbox;
1063
1064         GtkWidget *text1, *text2, *text3;
1065         GtkWidget *check1, *check2;
1066
1067         EMessageBoxReturn ret;
1068         int loop = 1;
1069
1070         window = ui::Window( ui::window_type::TOP );
1071
1072         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1073         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1074
1075         gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1076         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1077
1078         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1079         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1080
1081         gtk_widget_realize( window );
1082
1083
1084
1085         vbox = ui::VBox( FALSE, 10 );
1086         gtk_container_add( GTK_CONTAINER( window ), vbox );
1087         gtk_widget_show( vbox );
1088
1089         // ---- vbox ----
1090
1091         hbox = ui::HBox( FALSE, 10 );
1092         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1093         gtk_widget_show( hbox );
1094
1095         // ---- hbox ----
1096
1097         text1 = ui::Entry( 256 );
1098         gtk_entry_set_text( (GtkEntry*)text1, "25" );
1099         gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 );
1100         gtk_widget_show( text1 );
1101
1102         w = ui::Label( "Number Of Points" );
1103         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1104         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1105         gtk_widget_show( w );
1106
1107         // ---- /hbox ----
1108
1109         hbox = ui::HBox( FALSE, 10 );
1110         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1111         gtk_widget_show( hbox );
1112
1113         // ---- hbox ----
1114
1115         text2 = ui::Entry( 256 );
1116         gtk_entry_set_text( (GtkEntry*)text2, "3" );
1117         gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 );
1118         gtk_widget_show( text2 );
1119
1120         w = ui::Label( "Multipler" );
1121         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1122         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1123         gtk_widget_show( w );
1124
1125         // ---- /hbox ----
1126
1127         w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" );
1128         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1129         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1130         gtk_widget_show( w );
1131
1132         hbox = ui::HBox( FALSE, 10 );
1133         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1134         gtk_widget_show( hbox );
1135
1136         // ---- hbox ----
1137
1138         text3 = ui::Entry( 256 );
1139         gtk_entry_set_text( (GtkEntry*)text3, "-800" );
1140         gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 );
1141         gtk_widget_show( text3 );
1142
1143         w = ui::Label( "Gravity" );
1144         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1145         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1146         gtk_widget_show( w );
1147
1148         // ---- /hbox ----
1149
1150         w = gtk_hseparator_new();
1151         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1152         gtk_widget_show( w );
1153
1154         check1 = ui::CheckButton( "No Dynamic Update" );
1155         gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
1156         gtk_widget_show( check1 );
1157
1158         check2 = ui::CheckButton( "Show Bounding Lines" );
1159         gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
1160         gtk_widget_show( check2 );
1161
1162         // ---- /vbox ----
1163
1164
1165         // ----------------- //
1166
1167         w = gtk_hseparator_new();
1168         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1169         gtk_widget_show( w );
1170
1171         // ----------------- //
1172
1173         hbox = ui::HBox( FALSE, 10 );
1174         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1175         gtk_widget_show( hbox );
1176
1177         w = ui::Button( "Enable" );
1178         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1179         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1180         gtk_widget_show( w );
1181
1182         gtk_widget_set_can_default( w, true );
1183         gtk_widget_grab_default( w );
1184
1185         w = ui::Button( "Disable" );
1186         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1187         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
1188         gtk_widget_show( w );
1189
1190         w = ui::Button( "Cancel" );
1191         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1192         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1193         gtk_widget_show( w );
1194
1195         ret = eIDCANCEL;
1196
1197         // ----------------- //
1198
1199         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1200         gtk_widget_show( window );
1201         gtk_grab_add( window );
1202
1203         bool dialogError = TRUE;
1204         while ( dialogError )
1205         {
1206                 loop = 1;
1207                 while ( loop )
1208                         gtk_main_iteration();
1209
1210                 dialogError = FALSE;
1211
1212                 if ( ret == eIDYES ) {
1213                         if ( !ValidateTextIntRange( gtk_entry_get_text( GTK_ENTRY( text1 ) ), 1, 200, "Number Of Points", &rs->nPoints ) ) {
1214                                 dialogError = TRUE;
1215                         }
1216
1217                         if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text2 ) ), 1.0f, 10.0f, "Multiplier", &rs->fMultiplier ) ) {
1218                                 dialogError = TRUE;
1219                         }
1220
1221                         if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text3 ) ), -10000.0f, -1.0f, "Gravity", &rs->fGravity ) ) {
1222                                 dialogError = TRUE;
1223                         }
1224
1225                         rs->bNoUpdate = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check1 ) ) ? true : false;
1226                         rs->bShowExtra = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check2 ) ) ? true : false;
1227                 }
1228         }
1229
1230         gtk_grab_remove( window );
1231         gtk_widget_destroy( window );
1232
1233         return ret;
1234 }
1235
1236 EMessageBoxReturn DoCTFColourChangeBox(){
1237         GtkWidget *window, *w, *vbox, *hbox;
1238         EMessageBoxReturn ret;
1239         int loop = 1;
1240
1241         window = ui::Window( ui::window_type::TOP );
1242
1243         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1244         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1245
1246         gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" );
1247         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1248
1249         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1250         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1251
1252         gtk_widget_realize( window );
1253
1254
1255
1256         vbox = ui::VBox( FALSE, 10 );
1257         gtk_container_add( GTK_CONTAINER( window ), vbox );
1258         gtk_widget_show( vbox );
1259
1260         // ---- vbox ----
1261
1262         hbox = ui::HBox( FALSE, 10 );
1263         gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
1264         gtk_widget_show( hbox );
1265
1266         // ---- hbox ---- ok/cancel buttons
1267
1268         w = ui::Button( "Red->Blue" );
1269         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1270         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1271
1272         gtk_widget_set_can_default( w, true );
1273         gtk_widget_grab_default( w );
1274         gtk_widget_show( w );
1275
1276         w = ui::Button( "Blue->Red" );
1277         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1278         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1279         gtk_widget_show( w );
1280
1281         w = ui::Button( "Cancel" );
1282         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1283         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1284         gtk_widget_show( w );
1285         ret = eIDCANCEL;
1286
1287         // ---- /hbox ----
1288
1289         // ---- /vbox ----
1290
1291         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1292         gtk_widget_show( window );
1293         gtk_grab_add( window );
1294
1295         while ( loop )
1296                 gtk_main_iteration();
1297
1298         gtk_grab_remove( window );
1299         gtk_widget_destroy( window );
1300
1301         return ret;
1302 }
1303
1304 EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
1305         Str texSelected;
1306
1307         GtkWidget *window, *w, *vbox, *hbox, *frame, *table;
1308
1309         EMessageBoxReturn ret;
1310         int loop = 1;
1311
1312         window = ui::Window( ui::window_type::TOP );
1313
1314         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1315         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1316
1317         gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1318         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1319
1320         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1321         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1322
1323         gtk_widget_realize( window );
1324
1325         vbox = ui::VBox( FALSE, 10 );
1326         gtk_container_add( GTK_CONTAINER( window ), vbox );
1327         gtk_widget_show( vbox );
1328
1329         // ---- vbox ----
1330
1331         hbox = ui::HBox( FALSE, 10 );
1332         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1333         gtk_widget_show( hbox );
1334
1335         // ---- hbox ----
1336
1337         texSelected = "Currently Selected Texture:   ";
1338         texSelected += GetCurrentTexture();
1339
1340         w = ui::Label( texSelected );
1341         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1342         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1343         gtk_widget_show( w );
1344
1345         // ---- /hbox ----
1346
1347         frame = ui::Frame( "Reset Texture Names" );
1348         gtk_widget_show( frame );
1349         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1350
1351         table = ui::Table( 2, 3, TRUE );
1352         gtk_widget_show( table );
1353         gtk_container_add( GTK_CONTAINER( frame ), table );
1354         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1355         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1356         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1357
1358         // ---- frame ----
1359
1360         dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
1361         g_signal_connect( GTK_OBJECT( dlgTexReset.cbTexChange ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1362         gtk_widget_show( dlgTexReset.cbTexChange );
1363         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1,
1364                                           (GtkAttachOptions) ( GTK_FILL ),
1365                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1366
1367         w = ui::Label( "Old Name: " );
1368         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1369                                           (GtkAttachOptions) ( GTK_FILL ),
1370                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1371         gtk_widget_show( w );
1372
1373         dlgTexReset.editTexOld = ui::Entry( 256 );
1374         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
1375         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1,
1376                                           (GtkAttachOptions) ( GTK_FILL ),
1377                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1378         gtk_widget_show( dlgTexReset.editTexOld );
1379
1380         w = ui::Label( "New Name: " );
1381         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1382                                           (GtkAttachOptions) ( GTK_FILL ),
1383                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1384         gtk_widget_show( w );
1385
1386         dlgTexReset.editTexNew = ui::Entry( 256 );
1387         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
1388         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2,
1389                                           (GtkAttachOptions) ( GTK_FILL ),
1390                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1391         gtk_widget_show( dlgTexReset.editTexNew );
1392
1393         // ---- /frame ----
1394
1395         frame = ui::Frame( "Reset Scales" );
1396         gtk_widget_show( frame );
1397         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1398
1399         table = ui::Table( 2, 3, TRUE );
1400         gtk_widget_show( table );
1401         gtk_container_add( GTK_CONTAINER( frame ), table );
1402         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1403         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1404         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1405
1406         // ---- frame ----
1407
1408         dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
1409         g_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleHor ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1410         gtk_widget_show( dlgTexReset.cbScaleHor );
1411         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1,
1412                                           (GtkAttachOptions) ( GTK_FILL ),
1413                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1414
1415         w = ui::Label( "New Horizontal Scale: " );
1416         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1417                                           (GtkAttachOptions) ( GTK_FILL ),
1418                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1419         gtk_widget_show( w );
1420
1421         dlgTexReset.editScaleHor = ui::Entry( 256 );
1422         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
1423         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1,
1424                                           (GtkAttachOptions) ( GTK_FILL ),
1425                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1426         gtk_widget_show( dlgTexReset.editScaleHor );
1427
1428
1429         dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
1430         g_signal_connect( GTK_OBJECT( dlgTexReset.cbScaleVert ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1431         gtk_widget_show( dlgTexReset.cbScaleVert );
1432         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2,
1433                                           (GtkAttachOptions) ( GTK_FILL ),
1434                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1435
1436         w = ui::Label( "New Vertical Scale: " );
1437         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1438                                           (GtkAttachOptions) ( GTK_FILL ),
1439                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1440         gtk_widget_show( w );
1441
1442         dlgTexReset.editScaleVert = ui::Entry( 256 );
1443         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
1444         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2,
1445                                           (GtkAttachOptions) ( GTK_FILL ),
1446                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1447         gtk_widget_show( dlgTexReset.editScaleVert );
1448
1449         // ---- /frame ----
1450
1451         frame = ui::Frame( "Reset Shift" );
1452         gtk_widget_show( frame );
1453         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1454
1455         table = ui::Table( 2, 3, TRUE );
1456         gtk_widget_show( table );
1457         gtk_container_add( GTK_CONTAINER( frame ), table );
1458         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1459         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1460         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1461
1462         // ---- frame ----
1463
1464         dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
1465         g_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftHor ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1466         gtk_widget_show( dlgTexReset.cbShiftHor );
1467         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1,
1468                                           (GtkAttachOptions) ( GTK_FILL ),
1469                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1470
1471         w = ui::Label( "New Horizontal Shift: " );
1472         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1473                                           (GtkAttachOptions) ( GTK_FILL ),
1474                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1475         gtk_widget_show( w );
1476
1477         dlgTexReset.editShiftHor = ui::Entry( 256 );
1478         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
1479         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1,
1480                                           (GtkAttachOptions) ( GTK_FILL ),
1481                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1482         gtk_widget_show( dlgTexReset.editShiftHor );
1483
1484
1485         dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
1486         g_signal_connect( GTK_OBJECT( dlgTexReset.cbShiftVert ), "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1487         gtk_widget_show( dlgTexReset.cbShiftVert );
1488         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2,
1489                                           (GtkAttachOptions) ( GTK_FILL ),
1490                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1491
1492         w = ui::Label( "New Vertical Shift: " );
1493         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1494                                           (GtkAttachOptions) ( GTK_FILL ),
1495                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1496         gtk_widget_show( w );
1497
1498         dlgTexReset.editShiftVert = ui::Entry( 256 );
1499         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
1500         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2,
1501                                           (GtkAttachOptions) ( GTK_FILL ),
1502                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1503         gtk_widget_show( dlgTexReset.editShiftVert );
1504
1505         // ---- /frame ----
1506
1507         frame = ui::Frame( "Reset Rotation" );
1508         gtk_widget_show( frame );
1509         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1510
1511         table = ui::Table( 1, 3, TRUE );
1512         gtk_widget_show( table );
1513         gtk_container_add( GTK_CONTAINER( frame ), table );
1514         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1515         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1516         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1517
1518         // ---- frame ----
1519
1520         dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
1521         gtk_widget_show( dlgTexReset.cbRotation );
1522         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1,
1523                                           (GtkAttachOptions) ( GTK_FILL ),
1524                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1525
1526         w = ui::Label( "New Rotation Value: " );
1527         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1528                                           (GtkAttachOptions) ( GTK_FILL ),
1529                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1530         gtk_widget_show( w );
1531
1532         dlgTexReset.editRotation = ui::Entry( 256 );
1533         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
1534         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1,
1535                                           (GtkAttachOptions) ( GTK_FILL ),
1536                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1537         gtk_widget_show( dlgTexReset.editRotation );
1538
1539         // ---- /frame ----
1540
1541         hbox = ui::HBox( FALSE, 10 );
1542         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1543         gtk_widget_show( hbox );
1544
1545         // ---- hbox ----
1546
1547         w = ui::Button( "Use Selected Brushes" );
1548         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1549         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1550
1551         gtk_widget_set_can_default( w, true );
1552         gtk_widget_grab_default( w );
1553         gtk_widget_show( w );
1554
1555         w = ui::Button( "Use All Brushes" );
1556         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1557         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1558         gtk_widget_show( w );
1559
1560         w = ui::Button( "Cancel" );
1561         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1562         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1563         gtk_widget_show( w );
1564         ret = eIDCANCEL;
1565
1566         // ---- /hbox ----
1567
1568         // ---- /vbox ----
1569
1570         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1571         gtk_widget_show( window );
1572         gtk_grab_add( window );
1573
1574         Update_TextureReseter();
1575
1576         bool dialogError = TRUE;
1577         while ( dialogError )
1578         {
1579                 loop = 1;
1580                 while ( loop )
1581                         gtk_main_iteration();
1582
1583                 dialogError = FALSE;
1584
1585                 if ( ret != eIDCANCEL ) {
1586                         rs->bResetRotation =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
1587                         if ( rs->bResetRotation ) {
1588                                 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editRotation ) ), "Rotation", &rs->rotation ) ) {
1589                                         dialogError = TRUE;
1590                                 }
1591                         }
1592
1593                         rs->bResetScale[0] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
1594                         if ( rs->bResetScale[0] ) {
1595                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleHor ) ), "Horizontal Scale", &rs->fScale[0] ) ) {
1596                                         dialogError = TRUE;
1597                                 }
1598                         }
1599
1600                         rs->bResetScale[1] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
1601                         if ( rs->bResetScale[1] ) {
1602                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleVert ) ), "Vertical Scale", &rs->fScale[1] ) ) {
1603                                         dialogError = TRUE;
1604                                 }
1605                         }
1606
1607                         rs->bResetShift[0] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
1608                         if ( rs->bResetShift[0] ) {
1609                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftHor ) ), "Horizontal Shift", &rs->fShift[0] ) ) {
1610                                         dialogError = TRUE;
1611                                 }
1612                         }
1613
1614                         rs->bResetShift[1] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
1615                         if ( rs->bResetShift[1] ) {
1616                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftVert ) ), "Vertical Shift", &rs->fShift[1] ) ) {
1617                                         dialogError = TRUE;
1618                                 }
1619                         }
1620
1621                         rs->bResetTextureName =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
1622                         if ( rs->bResetTextureName ) {
1623                                 strcpy( rs->textureName,     gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexOld ) ) );
1624                                 strcpy( rs->newTextureName,  gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexNew ) ) );
1625                         }
1626                 }
1627         }
1628
1629         gtk_grab_remove( window );
1630         gtk_widget_destroy( window );
1631
1632         return ret;
1633 }
1634
1635 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
1636         Str texSelected;
1637
1638         GtkWidget *window, *w, *vbox, *hbox, *frame, *table;
1639
1640         GtkWidget *radiusX, *radiusY;
1641         GtkWidget *angleStart, *angleEnd;
1642         GtkWidget *heightStart, *heightEnd;
1643         GtkWidget *numPoints;
1644
1645         EMessageBoxReturn ret;
1646         int loop = 1;
1647
1648         window = ui::Window( ui::window_type::TOP );
1649
1650         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1651         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1652
1653         gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" );
1654         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1655
1656         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1657         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1658
1659         gtk_widget_realize( window );
1660
1661         vbox = ui::VBox( FALSE, 10 );
1662         gtk_container_add( GTK_CONTAINER( window ), vbox );
1663         gtk_widget_show( vbox );
1664
1665         // ---- vbox ----
1666
1667         hbox = ui::HBox( FALSE, 10 );
1668         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1669         gtk_widget_show( hbox );
1670
1671         // ---- /hbox ----
1672
1673         frame = ui::Frame( "Radii" );
1674         gtk_widget_show( frame );
1675         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1676
1677         table = ui::Table( 2, 3, TRUE );
1678         gtk_widget_show( table );
1679         gtk_container_add( GTK_CONTAINER( frame ), table );
1680         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1681         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1682         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1683
1684         // ---- frame ----
1685
1686         w = ui::Label( "X: " );
1687         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1688                                           (GtkAttachOptions) ( GTK_FILL ),
1689                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1690         gtk_widget_show( w );
1691
1692         radiusX = ui::Entry( 256 );
1693         gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
1694         gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1,
1695                                           (GtkAttachOptions) ( GTK_FILL ),
1696                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1697         gtk_widget_show( radiusX );
1698
1699
1700
1701         w = ui::Label( "Y: " );
1702         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1703                                           (GtkAttachOptions) ( GTK_FILL ),
1704                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1705         gtk_widget_show( w );
1706
1707         radiusY = ui::Entry( 256 );
1708         gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
1709         gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2,
1710                                           (GtkAttachOptions) ( GTK_FILL ),
1711                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1712         gtk_widget_show( radiusY );
1713
1714
1715
1716         frame = ui::Frame( "Angles" );
1717         gtk_widget_show( frame );
1718         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1719
1720         table = ui::Table( 2, 3, TRUE );
1721         gtk_widget_show( table );
1722         gtk_container_add( GTK_CONTAINER( frame ), table );
1723         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1724         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1725         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1726
1727         // ---- frame ----
1728
1729         w = ui::Label( "Start: " );
1730         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1731                                           (GtkAttachOptions) ( GTK_FILL ),
1732                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1733         gtk_widget_show( w );
1734
1735         angleStart = ui::Entry( 256 );
1736         gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
1737         gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1,
1738                                           (GtkAttachOptions) ( GTK_FILL ),
1739                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1740         gtk_widget_show( angleStart );
1741
1742
1743
1744         w = ui::Label( "End: " );
1745         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1746                                           (GtkAttachOptions) ( GTK_FILL ),
1747                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1748         gtk_widget_show( w );
1749
1750         angleEnd = ui::Entry( 256 );
1751         gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
1752         gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2,
1753                                           (GtkAttachOptions) ( GTK_FILL ),
1754                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1755         gtk_widget_show( angleEnd );
1756
1757
1758         frame = ui::Frame( "Height" );
1759         gtk_widget_show( frame );
1760         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1761
1762         table = ui::Table( 2, 3, TRUE );
1763         gtk_widget_show( table );
1764         gtk_container_add( GTK_CONTAINER( frame ), table );
1765         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1766         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1767         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1768
1769         // ---- frame ----
1770
1771         w = ui::Label( "Start: " );
1772         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1773                                           (GtkAttachOptions) ( GTK_FILL ),
1774                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1775         gtk_widget_show( w );
1776
1777         heightStart = ui::Entry( 256 );
1778         gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
1779         gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1,
1780                                           (GtkAttachOptions) ( GTK_FILL ),
1781                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1782         gtk_widget_show( heightStart );
1783
1784
1785
1786         w = ui::Label( "End: " );
1787         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1788                                           (GtkAttachOptions) ( GTK_FILL ),
1789                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1790         gtk_widget_show( w );
1791
1792         heightEnd = ui::Entry( 256 );
1793         gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
1794         gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2,
1795                                           (GtkAttachOptions) ( GTK_FILL ),
1796                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1797         gtk_widget_show( heightEnd );
1798
1799
1800
1801         frame = ui::Frame( "Points" );
1802         gtk_widget_show( frame );
1803         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1804
1805         table = ui::Table( 2, 3, TRUE );
1806         gtk_widget_show( table );
1807         gtk_container_add( GTK_CONTAINER( frame ), table );
1808         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1809         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1810         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1811
1812         // ---- frame ----
1813
1814         w = ui::Label( "Number: " );
1815         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1816                                           (GtkAttachOptions) ( GTK_FILL ),
1817                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1818         gtk_widget_show( w );
1819
1820         numPoints = ui::Entry( 256 );
1821         gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
1822         gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1,
1823                                           (GtkAttachOptions) ( GTK_FILL ),
1824                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1825         gtk_widget_show( numPoints );
1826
1827
1828         hbox = ui::HBox( FALSE, 10 );
1829         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1830         gtk_widget_show( hbox );
1831
1832         // ---- hbox ----
1833
1834         w = ui::Button( "Ok" );
1835         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1836         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1837
1838         gtk_widget_set_can_default( w, true );
1839         gtk_widget_grab_default( w );
1840         gtk_widget_show( w );
1841
1842         w = ui::Button( "Cancel" );
1843         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1844         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1845         gtk_widget_show( w );
1846         ret = eIDCANCEL;
1847
1848         // ---- /hbox ----
1849
1850
1851
1852         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1853         gtk_widget_show( window );
1854         gtk_grab_add( window );
1855
1856         bool dialogError = TRUE;
1857         while ( dialogError )
1858         {
1859                 loop = 1;
1860                 while ( loop )
1861                         gtk_main_iteration();
1862
1863                 dialogError = FALSE;
1864
1865                 if ( ret != eIDCANCEL ) {
1866                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusX ) ), "Radius (X)", &rs->fRadiusX ) ) {
1867                                 dialogError = TRUE;
1868                         }
1869
1870                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusY ) ), "Radius (Y)", &rs->fRadiusY ) ) {
1871                                 dialogError = TRUE;
1872                         }
1873
1874                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleStart ) ), "Angle (Start)", &rs->fStartAngle ) ) {
1875                                 dialogError = TRUE;
1876                         }
1877
1878                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleEnd ) ), "Angle (End)", &rs->fEndAngle ) ) {
1879                                 dialogError = TRUE;
1880                         }
1881
1882                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightStart ) ), "Height (Start)", &rs->fStartHeight ) ) {
1883                                 dialogError = TRUE;
1884                         }
1885
1886                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightEnd ) ), "Height (End)", &rs->fEndHeight ) ) {
1887                                 dialogError = TRUE;
1888                         }
1889
1890                         if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( numPoints ) ), "Num Points", &rs->iNumPoints ) ) {
1891                                 dialogError = TRUE;
1892                         }
1893                 }
1894         }
1895
1896         gtk_grab_remove( window );
1897         gtk_widget_destroy( window );
1898
1899         return ret;
1900 }
1901 // ailmanki
1902 // add a simple input for the MakeChain thing..
1903 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
1904         GtkWidget   *window, *w, *vbox, *hbox;
1905         GtkWidget   *textlinkNum, *textlinkName;
1906         EMessageBoxReturn ret;
1907         int loop = 1;
1908
1909         char    *text = "Please set a value in the boxes below and press 'OK' to make a chain";
1910
1911         window = ui::Window( ui::window_type::TOP );
1912
1913         g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1914         g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1915
1916         gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" );
1917
1918         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1919
1920         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1921         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1922
1923         gtk_widget_realize( window );
1924
1925         // new vbox
1926         vbox = ui::VBox( FALSE, 10 );
1927         gtk_container_add( GTK_CONTAINER( window ), vbox );
1928         gtk_widget_show( vbox );
1929
1930         hbox = ui::HBox( FALSE, 10 );
1931         gtk_container_add( GTK_CONTAINER( vbox ), hbox );
1932         gtk_widget_show( hbox );
1933
1934         // dunno if you want this text or not ...
1935         w = ui::Label( text );
1936         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1937         gtk_widget_show( w );
1938
1939         w = gtk_hseparator_new();
1940         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1941         gtk_widget_show( w );
1942
1943         // ------------------------- //
1944
1945         // new hbox
1946         hbox = ui::HBox( FALSE, 10 );
1947         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1948         gtk_widget_show( hbox );
1949
1950         textlinkNum = ui::Entry( 256 );
1951         gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 );
1952         gtk_widget_show( textlinkNum );
1953
1954         w = ui::Label( "Number of elements in chain" );
1955         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1956         gtk_widget_show( w );
1957
1958         // -------------------------- //
1959
1960         hbox = ui::HBox( FALSE, 10 );
1961         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1962         gtk_widget_show( hbox );
1963
1964         textlinkName = ui::Entry( 256 );
1965         gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 );
1966         gtk_widget_show( textlinkName );
1967
1968         w = ui::Label( "Basename for chain's targetnames." );
1969         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1970         gtk_widget_show( w );
1971
1972
1973         w = ui::Button( "OK" );
1974         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1975         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1976         gtk_widget_set_can_default( w, true );
1977         gtk_widget_grab_default( w );
1978         gtk_widget_show( w );
1979
1980         w = ui::Button( "Cancel" );
1981         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1982         g_signal_connect( GTK_OBJECT( w ), "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1983         gtk_widget_show( w );
1984
1985         ret = eIDCANCEL;
1986
1987         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1988         gtk_widget_show( window );
1989         gtk_grab_add( window );
1990
1991         bool dialogError = TRUE;
1992         while ( dialogError )
1993         {
1994                 loop = 1;
1995                 while ( loop )
1996                         gtk_main_iteration();
1997
1998                 dialogError = FALSE;
1999
2000                 if ( ret == eIDOK ) {
2001                         strcpy( rs->linkName, gtk_entry_get_text( (GtkEntry*)textlinkName ) );
2002                         if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textlinkNum ), "Elements", &rs->linkNum ) ) {
2003                                 dialogError = TRUE;
2004                         }
2005                 }
2006         }
2007
2008         gtk_grab_remove( window );
2009         gtk_widget_destroy( window );
2010
2011         return ret;
2012 }