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