]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/bobtoolz/dialogs/dialogs-gtk.cpp
183d163ac4c5d8eb0c3088539e0dc53581d10fde
[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, 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 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         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   *textFrontBackTex, *textTrimTex;
836         GtkWidget   *checkScaleMainH, *checkScaleMainV, *checkScaleTrimH, *checkScaleTrimV;
837         GtkWidget   *comboMain, *comboTrim;
838         GtkWidget   *radioNS, *radioEW;
839         GSList      *radioOrientation;
840         TwinWidget tw1, tw2;
841         EMessageBoxReturn ret;
842         int loop = 1;
843
844         auto window = ui::Window( ui::window_type::TOP );
845
846         window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
847         window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
848
849         gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" );
850
851         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
852
853         g_object_set_data( G_OBJECT( window ), "loop", &loop );
854         g_object_set_data( G_OBJECT( window ), "ret", &ret );
855
856         gtk_widget_realize( window );
857
858         char buffer[256];
859         ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
860         ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
861         LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
862         LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
863
864         auto vbox = ui::VBox( FALSE, 10 );
865         window.add(vbox);
866         gtk_widget_show( vbox );
867
868         // -------------------------- //
869
870         hbox = ui::HBox( FALSE, 10 );
871         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
872         gtk_widget_show( hbox );
873
874         textFrontBackTex = ui::Entry( 512 );
875         gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture );
876         gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 );
877         gtk_widget_show( textFrontBackTex );
878
879         ui::Widget w = ui::Label( "Door Front/Back Texture" );
880         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
881         gtk_widget_show( w );
882
883         // ------------------------ //
884
885         hbox = ui::HBox( FALSE, 10 );
886         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
887         gtk_widget_show( hbox );
888
889         textTrimTex = ui::Entry( 512 );
890         gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 );
891         gtk_widget_show( textTrimTex );
892
893         w = ui::Label( "Door Trim Texture" );
894         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
895         gtk_widget_show( w );
896
897         // ----------------------- //
898
899         hbox = ui::HBox( FALSE, 10 );
900         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
901         gtk_widget_show( hbox );
902
903         // sp: horizontally ????
904         // djbob: yes mars, u can spell :]
905         checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" );
906         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE );
907         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainH, FALSE, FALSE, 0 );
908         gtk_widget_show( checkScaleMainH );
909
910         checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" );
911         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE );
912         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimH, FALSE, FALSE, 0 );
913         gtk_widget_show( checkScaleTrimH );
914
915         // ---------------------- //
916
917         hbox = ui::HBox( FALSE, 10 );
918         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
919         gtk_widget_show( hbox );
920
921         checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" );
922         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE );
923         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainV, FALSE, FALSE, 0 );
924         gtk_widget_show( checkScaleMainV );
925
926         checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" );
927         gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimV, FALSE, FALSE, 0 );
928         gtk_widget_show( checkScaleTrimV );
929
930         // --------------------- //
931
932         hbox = ui::HBox( FALSE, 10 );
933         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
934         gtk_widget_show( hbox );
935
936         // djbob: lists added
937
938         comboMain = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures));
939         gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
940         gtk_box_pack_start( GTK_BOX( hbox ), comboMain, FALSE, FALSE, 0 );
941         gtk_widget_show( comboMain );
942
943         tw1.one = textFrontBackTex;
944         tw1.two = GTK_COMBO_BOX(comboMain);
945
946         auto buttonSetMain = ui::Button( "Set As Main Texture" );
947         buttonSetMain.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 );
948         gtk_box_pack_start( GTK_BOX( hbox ), buttonSetMain, FALSE, FALSE, 0 );
949         gtk_widget_show( buttonSetMain );
950
951         // ------------------- //
952
953         hbox = ui::HBox( FALSE, 10 );
954         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
955         gtk_widget_show( hbox );
956
957         comboTrim = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures));
958         gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
959         gtk_box_pack_start( GTK_BOX( hbox ), comboTrim, FALSE, FALSE, 0 );
960         gtk_widget_show( comboTrim );
961
962         tw2.one = textTrimTex;
963         tw2.two = GTK_COMBO_BOX(comboTrim);
964
965         auto buttonSetTrim = ui::Button( "Set As Trim Texture" );
966         buttonSetTrim.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 );
967         gtk_box_pack_start( GTK_BOX( hbox ), buttonSetTrim, FALSE, FALSE, 0 );
968         gtk_widget_show( buttonSetTrim );
969
970         // ------------------ //
971
972         hbox = ui::HBox( FALSE, 10 );
973         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
974         gtk_widget_show( hbox );
975
976         w = ui::Label( "Orientation" );
977         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
978         gtk_widget_show( w );
979
980         // argh more radio buttons!
981         radioNS = gtk_radio_button_new_with_label( NULL, "North - South" );
982         gtk_box_pack_start( GTK_BOX( hbox ), radioNS, FALSE, FALSE, 0 );
983         gtk_widget_show( radioNS );
984
985         radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
986
987         radioEW = gtk_radio_button_new_with_label( radioOrientation, "East - West" );
988         gtk_box_pack_start( GTK_BOX( hbox ), radioEW, FALSE, FALSE, 0 );
989         gtk_widget_show( radioEW );
990
991         // ----------------- //
992
993         w = ui::Widget(gtk_hseparator_new());
994         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
995         gtk_widget_show( w );
996
997         // ----------------- //
998
999         hbox = ui::HBox( FALSE, 10 );
1000         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1001         gtk_widget_show( hbox );
1002
1003         w = ui::Button( "OK" );
1004         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1005         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1006         gtk_widget_set_can_default( w, true );
1007         gtk_widget_grab_default( w );
1008         gtk_widget_show( w );
1009
1010         w = ui::Button( "Cancel" );
1011         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1012         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1013         gtk_widget_show( w );
1014         ret = eIDCANCEL;
1015
1016         // ----------------- //
1017
1018 //+djbob
1019         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1020         gtk_widget_show( window );
1021         gtk_grab_add( window );
1022
1023         while ( loop )
1024                 gtk_main_iteration();
1025
1026         strcpy( rs->mainTexture, gtk_entry_get_text( GTK_ENTRY( textFrontBackTex ) ) );
1027         strcpy( rs->trimTexture, gtk_entry_get_text( GTK_ENTRY( textTrimTex ) ) );
1028
1029         rs->bScaleMainH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainH ) ) ? true : false;
1030         rs->bScaleMainV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainV ) ) ? true : false;
1031         rs->bScaleTrimH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ) ) ? true : false;
1032         rs->bScaleTrimV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimV ) ) ? true : false;
1033
1034         if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioNS ) ) ) {
1035                 rs->nOrientation = DIRECTION_NS;
1036         }
1037         else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioEW ) ) ) {
1038                 rs->nOrientation = DIRECTION_EW;
1039         }
1040
1041         gtk_grab_remove( window );
1042         gtk_widget_destroy( window );
1043
1044         return ret;
1045 //-djbob
1046 }
1047
1048 EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
1049         ui::Widget w, hbox;
1050
1051         ui::Entry text1, text2, text3;
1052         ui::Widget check1, check2;
1053
1054         EMessageBoxReturn ret;
1055         int loop = 1;
1056
1057         auto window = ui::Window( ui::window_type::TOP );
1058
1059         window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1060         window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1061
1062         gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1063         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1064
1065         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1066         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1067
1068         gtk_widget_realize( window );
1069
1070
1071
1072         auto vbox = ui::VBox( FALSE, 10 );
1073         window.add(vbox);
1074         gtk_widget_show( vbox );
1075
1076         // ---- vbox ----
1077
1078         hbox = ui::HBox( FALSE, 10 );
1079         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1080         gtk_widget_show( hbox );
1081
1082         // ---- hbox ----
1083
1084         text1 = ui::Entry( 256 );
1085         gtk_entry_set_text( text1, "25" );
1086         gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 );
1087         gtk_widget_show( text1 );
1088
1089         w = ui::Label( "Number Of Points" );
1090         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1091         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1092         gtk_widget_show( w );
1093
1094         // ---- /hbox ----
1095
1096         hbox = ui::HBox( FALSE, 10 );
1097         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1098         gtk_widget_show( hbox );
1099
1100         // ---- hbox ----
1101
1102         text2 = ui::Entry( 256 );
1103         gtk_entry_set_text( text2, "3" );
1104         gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 );
1105         gtk_widget_show( text2 );
1106
1107         w = ui::Label( "Multipler" );
1108         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1109         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1110         gtk_widget_show( w );
1111
1112         // ---- /hbox ----
1113
1114         w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" );
1115         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1116         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1117         gtk_widget_show( w );
1118
1119         hbox = ui::HBox( FALSE, 10 );
1120         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1121         gtk_widget_show( hbox );
1122
1123         // ---- hbox ----
1124
1125         text3 = ui::Entry( 256 );
1126         gtk_entry_set_text( text3, "-800" );
1127         gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 );
1128         gtk_widget_show( text3 );
1129
1130         w = ui::Label( "Gravity" );
1131         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1132         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1133         gtk_widget_show( w );
1134
1135         // ---- /hbox ----
1136
1137         w = ui::Widget(gtk_hseparator_new());
1138         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1139         gtk_widget_show( w );
1140
1141         check1 = ui::CheckButton( "No Dynamic Update" );
1142         gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
1143         gtk_widget_show( check1 );
1144
1145         check2 = ui::CheckButton( "Show Bounding Lines" );
1146         gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
1147         gtk_widget_show( check2 );
1148
1149         // ---- /vbox ----
1150
1151
1152         // ----------------- //
1153
1154         w = ui::Widget(gtk_hseparator_new());
1155         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1156         gtk_widget_show( w );
1157
1158         // ----------------- //
1159
1160         hbox = ui::HBox( FALSE, 10 );
1161         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1162         gtk_widget_show( hbox );
1163
1164         w = ui::Button( "Enable" );
1165         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1166         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1167         gtk_widget_show( w );
1168
1169         gtk_widget_set_can_default( w, true );
1170         gtk_widget_grab_default( w );
1171
1172         w = ui::Button( "Disable" );
1173         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1174         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
1175         gtk_widget_show( w );
1176
1177         w = ui::Button( "Cancel" );
1178         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1179         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1180         gtk_widget_show( w );
1181
1182         ret = eIDCANCEL;
1183
1184         // ----------------- //
1185
1186         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1187         gtk_widget_show( window );
1188         gtk_grab_add( window );
1189
1190         bool dialogError = TRUE;
1191         while ( dialogError )
1192         {
1193                 loop = 1;
1194                 while ( loop )
1195                         gtk_main_iteration();
1196
1197                 dialogError = FALSE;
1198
1199                 if ( ret == eIDYES ) {
1200                         if ( !ValidateTextIntRange( gtk_entry_get_text( GTK_ENTRY( text1 ) ), 1, 200, "Number Of Points", &rs->nPoints ) ) {
1201                                 dialogError = TRUE;
1202                         }
1203
1204                         if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text2 ) ), 1.0f, 10.0f, "Multiplier", &rs->fMultiplier ) ) {
1205                                 dialogError = TRUE;
1206                         }
1207
1208                         if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text3 ) ), -10000.0f, -1.0f, "Gravity", &rs->fGravity ) ) {
1209                                 dialogError = TRUE;
1210                         }
1211
1212                         rs->bNoUpdate = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check1 ) ) ? true : false;
1213                         rs->bShowExtra = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check2 ) ) ? true : false;
1214                 }
1215         }
1216
1217         gtk_grab_remove( window );
1218         gtk_widget_destroy( window );
1219
1220         return ret;
1221 }
1222
1223 EMessageBoxReturn DoCTFColourChangeBox(){
1224         ui::Widget w, hbox;
1225         EMessageBoxReturn ret;
1226         int loop = 1;
1227
1228         auto window = ui::Window( ui::window_type::TOP );
1229
1230         window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1231         window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1232
1233         gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" );
1234         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1235
1236         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1237         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1238
1239         gtk_widget_realize( window );
1240
1241
1242
1243         auto vbox = ui::VBox( FALSE, 10 );
1244         window.add(vbox);
1245         gtk_widget_show( vbox );
1246
1247         // ---- vbox ----
1248
1249         hbox = ui::HBox( FALSE, 10 );
1250         gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
1251         gtk_widget_show( hbox );
1252
1253         // ---- hbox ---- ok/cancel buttons
1254
1255         w = ui::Button( "Red->Blue" );
1256         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1257         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1258
1259         gtk_widget_set_can_default( w, true );
1260         gtk_widget_grab_default( w );
1261         gtk_widget_show( w );
1262
1263         w = ui::Button( "Blue->Red" );
1264         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1265         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1266         gtk_widget_show( w );
1267
1268         w = ui::Button( "Cancel" );
1269         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1270         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1271         gtk_widget_show( w );
1272         ret = eIDCANCEL;
1273
1274         // ---- /hbox ----
1275
1276         // ---- /vbox ----
1277
1278         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1279         gtk_widget_show( window );
1280         gtk_grab_add( window );
1281
1282         while ( loop )
1283                 gtk_main_iteration();
1284
1285         gtk_grab_remove( window );
1286         gtk_widget_destroy( window );
1287
1288         return ret;
1289 }
1290
1291 EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
1292         Str texSelected;
1293
1294         ui::Widget w, hbox;
1295
1296         EMessageBoxReturn ret;
1297         int loop = 1;
1298
1299         auto window = ui::Window( ui::window_type::TOP );
1300
1301         window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1302         window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1303
1304         gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1305         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1306
1307         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1308         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1309
1310         gtk_widget_realize( window );
1311
1312         auto vbox = ui::VBox( FALSE, 10 );
1313         window.add(vbox);
1314         vbox.show();
1315
1316         // ---- vbox ----
1317
1318         hbox = ui::HBox( FALSE, 10 );
1319         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1320         gtk_widget_show( hbox );
1321
1322         // ---- hbox ----
1323
1324         texSelected = "Currently Selected Texture:   ";
1325         texSelected += GetCurrentTexture();
1326
1327         w = ui::Label( texSelected );
1328         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1329         gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1330         gtk_widget_show( w );
1331
1332         // ---- /hbox ----
1333
1334         auto frame = ui::Frame( "Reset Texture Names" );
1335         gtk_widget_show( frame );
1336         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1337
1338         auto table = ui::Table( 2, 3, TRUE );
1339         table.show();
1340         frame.add(table);
1341         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1342         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1343         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1344
1345         // ---- frame ----
1346
1347         dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
1348         dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1349         gtk_widget_show( dlgTexReset.cbTexChange );
1350         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1,
1351                                           (GtkAttachOptions) ( GTK_FILL ),
1352                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1353
1354         w = ui::Label( "Old Name: " );
1355         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1356                                           (GtkAttachOptions) ( GTK_FILL ),
1357                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1358         gtk_widget_show( w );
1359
1360         dlgTexReset.editTexOld = ui::Entry( 256 );
1361         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
1362         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1,
1363                                           (GtkAttachOptions) ( GTK_FILL ),
1364                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1365         gtk_widget_show( dlgTexReset.editTexOld );
1366
1367         w = ui::Label( "New Name: " );
1368         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1369                                           (GtkAttachOptions) ( GTK_FILL ),
1370                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1371         gtk_widget_show( w );
1372
1373         dlgTexReset.editTexNew = ui::Entry( 256 );
1374         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
1375         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2,
1376                                           (GtkAttachOptions) ( GTK_FILL ),
1377                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1378         gtk_widget_show( dlgTexReset.editTexNew );
1379
1380         // ---- /frame ----
1381
1382         frame = ui::Frame( "Reset Scales" );
1383         gtk_widget_show( frame );
1384         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1385
1386         table = ui::Table( 2, 3, TRUE );
1387         table.show();
1388         frame.add(table);
1389         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1390         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1391         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1392
1393         // ---- frame ----
1394
1395         dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
1396         dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1397         gtk_widget_show( dlgTexReset.cbScaleHor );
1398         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1,
1399                                           (GtkAttachOptions) ( GTK_FILL ),
1400                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1401
1402         w = ui::Label( "New Horizontal Scale: " );
1403         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1404                                           (GtkAttachOptions) ( GTK_FILL ),
1405                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1406         gtk_widget_show( w );
1407
1408         dlgTexReset.editScaleHor = ui::Entry( 256 );
1409         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
1410         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1,
1411                                           (GtkAttachOptions) ( GTK_FILL ),
1412                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1413         gtk_widget_show( dlgTexReset.editScaleHor );
1414
1415
1416         dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
1417         dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1418         gtk_widget_show( dlgTexReset.cbScaleVert );
1419         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2,
1420                                           (GtkAttachOptions) ( GTK_FILL ),
1421                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1422
1423         w = ui::Label( "New Vertical Scale: " );
1424         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1425                                           (GtkAttachOptions) ( GTK_FILL ),
1426                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1427         gtk_widget_show( w );
1428
1429         dlgTexReset.editScaleVert = ui::Entry( 256 );
1430         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
1431         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2,
1432                                           (GtkAttachOptions) ( GTK_FILL ),
1433                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1434         gtk_widget_show( dlgTexReset.editScaleVert );
1435
1436         // ---- /frame ----
1437
1438         frame = ui::Frame( "Reset Shift" );
1439         gtk_widget_show( frame );
1440         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1441
1442         table = ui::Table( 2, 3, TRUE );
1443         table.show();
1444         frame.add(table);
1445         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1446         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1447         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1448
1449         // ---- frame ----
1450
1451         dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
1452         dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1453         gtk_widget_show( dlgTexReset.cbShiftHor );
1454         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1,
1455                                           (GtkAttachOptions) ( GTK_FILL ),
1456                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1457
1458         w = ui::Label( "New Horizontal Shift: " );
1459         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1460                                           (GtkAttachOptions) ( GTK_FILL ),
1461                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1462         gtk_widget_show( w );
1463
1464         dlgTexReset.editShiftHor = ui::Entry( 256 );
1465         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
1466         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1,
1467                                           (GtkAttachOptions) ( GTK_FILL ),
1468                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1469         gtk_widget_show( dlgTexReset.editShiftHor );
1470
1471
1472         dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
1473         dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1474         gtk_widget_show( dlgTexReset.cbShiftVert );
1475         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2,
1476                                           (GtkAttachOptions) ( GTK_FILL ),
1477                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1478
1479         w = ui::Label( "New Vertical Shift: " );
1480         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1481                                           (GtkAttachOptions) ( GTK_FILL ),
1482                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1483         gtk_widget_show( w );
1484
1485         dlgTexReset.editShiftVert = ui::Entry( 256 );
1486         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
1487         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2,
1488                                           (GtkAttachOptions) ( GTK_FILL ),
1489                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1490         gtk_widget_show( dlgTexReset.editShiftVert );
1491
1492         // ---- /frame ----
1493
1494         frame = ui::Frame( "Reset Rotation" );
1495         gtk_widget_show( frame );
1496         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1497
1498         table = ui::Table( 1, 3, TRUE );
1499         table.show();
1500         frame.add(table);
1501         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1502         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1503         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1504
1505         // ---- frame ----
1506
1507         dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
1508         gtk_widget_show( dlgTexReset.cbRotation );
1509         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1,
1510                                           (GtkAttachOptions) ( GTK_FILL ),
1511                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1512
1513         w = ui::Label( "New Rotation Value: " );
1514         gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1515                                           (GtkAttachOptions) ( GTK_FILL ),
1516                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1517         gtk_widget_show( w );
1518
1519         dlgTexReset.editRotation = ui::Entry( 256 );
1520         gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
1521         gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1,
1522                                           (GtkAttachOptions) ( GTK_FILL ),
1523                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1524         gtk_widget_show( dlgTexReset.editRotation );
1525
1526         // ---- /frame ----
1527
1528         hbox = ui::HBox( FALSE, 10 );
1529         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1530         gtk_widget_show( hbox );
1531
1532         // ---- hbox ----
1533
1534         w = ui::Button( "Use Selected Brushes" );
1535         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1536         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1537
1538         gtk_widget_set_can_default( w, true );
1539         gtk_widget_grab_default( w );
1540         gtk_widget_show( w );
1541
1542         w = ui::Button( "Use All Brushes" );
1543         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1544         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1545         gtk_widget_show( w );
1546
1547         w = ui::Button( "Cancel" );
1548         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1549         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1550         gtk_widget_show( w );
1551         ret = eIDCANCEL;
1552
1553         // ---- /hbox ----
1554
1555         // ---- /vbox ----
1556
1557         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1558         gtk_widget_show( window );
1559         gtk_grab_add( window );
1560
1561         Update_TextureReseter();
1562
1563         bool dialogError = TRUE;
1564         while ( dialogError )
1565         {
1566                 loop = 1;
1567                 while ( loop )
1568                         gtk_main_iteration();
1569
1570                 dialogError = FALSE;
1571
1572                 if ( ret != eIDCANCEL ) {
1573                         rs->bResetRotation =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
1574                         if ( rs->bResetRotation ) {
1575                                 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editRotation ) ), "Rotation", &rs->rotation ) ) {
1576                                         dialogError = TRUE;
1577                                 }
1578                         }
1579
1580                         rs->bResetScale[0] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
1581                         if ( rs->bResetScale[0] ) {
1582                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleHor ) ), "Horizontal Scale", &rs->fScale[0] ) ) {
1583                                         dialogError = TRUE;
1584                                 }
1585                         }
1586
1587                         rs->bResetScale[1] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
1588                         if ( rs->bResetScale[1] ) {
1589                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleVert ) ), "Vertical Scale", &rs->fScale[1] ) ) {
1590                                         dialogError = TRUE;
1591                                 }
1592                         }
1593
1594                         rs->bResetShift[0] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
1595                         if ( rs->bResetShift[0] ) {
1596                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftHor ) ), "Horizontal Shift", &rs->fShift[0] ) ) {
1597                                         dialogError = TRUE;
1598                                 }
1599                         }
1600
1601                         rs->bResetShift[1] =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
1602                         if ( rs->bResetShift[1] ) {
1603                                 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftVert ) ), "Vertical Shift", &rs->fShift[1] ) ) {
1604                                         dialogError = TRUE;
1605                                 }
1606                         }
1607
1608                         rs->bResetTextureName =  gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
1609                         if ( rs->bResetTextureName ) {
1610                                 strcpy( rs->textureName,     gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexOld ) ) );
1611                                 strcpy( rs->newTextureName,  gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexNew ) ) );
1612                         }
1613                 }
1614         }
1615
1616         gtk_grab_remove( window );
1617         gtk_widget_destroy( window );
1618
1619         return ret;
1620 }
1621
1622 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
1623         Str texSelected;
1624
1625         ui::Widget w, hbox;
1626
1627         ui::Widget radiusX, radiusY;
1628         ui::Widget angleStart, angleEnd;
1629         ui::Widget heightStart, heightEnd;
1630         ui::Widget numPoints;
1631
1632         EMessageBoxReturn ret;
1633         int loop = 1;
1634
1635         auto window = ui::Window( ui::window_type::TOP );
1636
1637         window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1638         window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1639
1640         gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" );
1641         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1642
1643         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1644         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1645
1646         gtk_widget_realize( window );
1647
1648         auto vbox = ui::VBox( FALSE, 10 );
1649         window.add(vbox);
1650         vbox.show();
1651
1652         // ---- vbox ----
1653
1654         hbox = ui::HBox( FALSE, 10 );
1655         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1656         gtk_widget_show( hbox );
1657
1658         // ---- /hbox ----
1659
1660         auto frame = ui::Frame( "Radii" );
1661         gtk_widget_show( frame );
1662         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1663
1664         auto table = ui::Table( 2, 3, TRUE );
1665         table.show();
1666         frame.add(table);
1667         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1668         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1669         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1670
1671         // ---- frame ----
1672
1673         w = ui::Label( "X: " );
1674         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1675                                           (GtkAttachOptions) ( GTK_FILL ),
1676                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1677         gtk_widget_show( w );
1678
1679         radiusX = ui::Entry( 256 );
1680         gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
1681         gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1,
1682                                           (GtkAttachOptions) ( GTK_FILL ),
1683                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1684         gtk_widget_show( radiusX );
1685
1686
1687
1688         w = ui::Label( "Y: " );
1689         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1690                                           (GtkAttachOptions) ( GTK_FILL ),
1691                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1692         gtk_widget_show( w );
1693
1694         radiusY = ui::Entry( 256 );
1695         gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
1696         gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2,
1697                                           (GtkAttachOptions) ( GTK_FILL ),
1698                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1699         gtk_widget_show( radiusY );
1700
1701
1702
1703         frame = ui::Frame( "Angles" );
1704         gtk_widget_show( frame );
1705         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1706
1707         table = ui::Table( 2, 3, TRUE );
1708         table.show();
1709         frame.add(table);
1710         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1711         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1712         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1713
1714         // ---- frame ----
1715
1716         w = ui::Label( "Start: " );
1717         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1718                                           (GtkAttachOptions) ( GTK_FILL ),
1719                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1720         gtk_widget_show( w );
1721
1722         angleStart = ui::Entry( 256 );
1723         gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
1724         gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1,
1725                                           (GtkAttachOptions) ( GTK_FILL ),
1726                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1727         gtk_widget_show( angleStart );
1728
1729
1730
1731         w = ui::Label( "End: " );
1732         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1733                                           (GtkAttachOptions) ( GTK_FILL ),
1734                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1735         gtk_widget_show( w );
1736
1737         angleEnd = ui::Entry( 256 );
1738         gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
1739         gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2,
1740                                           (GtkAttachOptions) ( GTK_FILL ),
1741                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1742         gtk_widget_show( angleEnd );
1743
1744
1745         frame = ui::Frame( "Height" );
1746         gtk_widget_show( frame );
1747         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1748
1749         table = ui::Table( 2, 3, TRUE );
1750         table.show();
1751         frame.add(table);
1752         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1753         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1754         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1755
1756         // ---- frame ----
1757
1758         w = ui::Label( "Start: " );
1759         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1760                                           (GtkAttachOptions) ( GTK_FILL ),
1761                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1762         gtk_widget_show( w );
1763
1764         heightStart = ui::Entry( 256 );
1765         gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
1766         gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1,
1767                                           (GtkAttachOptions) ( GTK_FILL ),
1768                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1769         gtk_widget_show( heightStart );
1770
1771
1772
1773         w = ui::Label( "End: " );
1774         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1775                                           (GtkAttachOptions) ( GTK_FILL ),
1776                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1777         gtk_widget_show( w );
1778
1779         heightEnd = ui::Entry( 256 );
1780         gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
1781         gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2,
1782                                           (GtkAttachOptions) ( GTK_FILL ),
1783                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1784         gtk_widget_show( heightEnd );
1785
1786
1787
1788         frame = ui::Frame( "Points" );
1789         gtk_widget_show( frame );
1790         gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1791
1792         table = ui::Table( 2, 3, TRUE );
1793         table.show();
1794         frame.add(table);
1795         gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1796         gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1797         gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1798
1799         // ---- frame ----
1800
1801         w = ui::Label( "Number: " );
1802         gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1803                                           (GtkAttachOptions) ( GTK_FILL ),
1804                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1805         gtk_widget_show( w );
1806
1807         numPoints = ui::Entry( 256 );
1808         gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
1809         gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1,
1810                                           (GtkAttachOptions) ( GTK_FILL ),
1811                                           (GtkAttachOptions) ( 0 ), 0, 0 );
1812         gtk_widget_show( numPoints );
1813
1814
1815         hbox = ui::HBox( FALSE, 10 );
1816         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1817         gtk_widget_show( hbox );
1818
1819         // ---- hbox ----
1820
1821         w = ui::Button( "Ok" );
1822         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1823         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1824
1825         gtk_widget_set_can_default( w, true );
1826         gtk_widget_grab_default( w );
1827         gtk_widget_show( w );
1828
1829         w = ui::Button( "Cancel" );
1830         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1831         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1832         gtk_widget_show( w );
1833         ret = eIDCANCEL;
1834
1835         // ---- /hbox ----
1836
1837
1838
1839         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1840         gtk_widget_show( window );
1841         gtk_grab_add( window );
1842
1843         bool dialogError = TRUE;
1844         while ( dialogError )
1845         {
1846                 loop = 1;
1847                 while ( loop )
1848                         gtk_main_iteration();
1849
1850                 dialogError = FALSE;
1851
1852                 if ( ret != eIDCANCEL ) {
1853                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusX ) ), "Radius (X)", &rs->fRadiusX ) ) {
1854                                 dialogError = TRUE;
1855                         }
1856
1857                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusY ) ), "Radius (Y)", &rs->fRadiusY ) ) {
1858                                 dialogError = TRUE;
1859                         }
1860
1861                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleStart ) ), "Angle (Start)", &rs->fStartAngle ) ) {
1862                                 dialogError = TRUE;
1863                         }
1864
1865                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleEnd ) ), "Angle (End)", &rs->fEndAngle ) ) {
1866                                 dialogError = TRUE;
1867                         }
1868
1869                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightStart ) ), "Height (Start)", &rs->fStartHeight ) ) {
1870                                 dialogError = TRUE;
1871                         }
1872
1873                         if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightEnd ) ), "Height (End)", &rs->fEndHeight ) ) {
1874                                 dialogError = TRUE;
1875                         }
1876
1877                         if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( numPoints ) ), "Num Points", &rs->iNumPoints ) ) {
1878                                 dialogError = TRUE;
1879                         }
1880                 }
1881         }
1882
1883         gtk_grab_remove( window );
1884         gtk_widget_destroy( window );
1885
1886         return ret;
1887 }
1888 // ailmanki
1889 // add a simple input for the MakeChain thing..
1890 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
1891         ui::Widget   w;
1892         ui::Entry textlinkNum, textlinkName;
1893         EMessageBoxReturn ret;
1894         int loop = 1;
1895
1896         char const *text = "Please set a value in the boxes below and press 'OK' to make a chain";
1897
1898         auto window = ui::Window( ui::window_type::TOP );
1899
1900         window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1901         window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1902
1903         gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" );
1904
1905         gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1906
1907         g_object_set_data( G_OBJECT( window ), "loop", &loop );
1908         g_object_set_data( G_OBJECT( window ), "ret", &ret );
1909
1910         gtk_widget_realize( window );
1911
1912         // new vbox
1913         auto vbox = ui::VBox( FALSE, 10 );
1914         window.add(vbox);
1915         vbox.show();
1916
1917         auto hbox = ui::HBox( FALSE, 10 );
1918         vbox.add(hbox);
1919         hbox.show();
1920
1921         // dunno if you want this text or not ...
1922         w = ui::Label( text );
1923         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1924         gtk_widget_show( w );
1925
1926         w = ui::Widget(gtk_hseparator_new());
1927         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1928         gtk_widget_show( w );
1929
1930         // ------------------------- //
1931
1932         // new hbox
1933         hbox = ui::HBox( FALSE, 10 );
1934         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1935         gtk_widget_show( hbox );
1936
1937         textlinkNum = ui::Entry( 256 );
1938         gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 );
1939         gtk_widget_show( textlinkNum );
1940
1941         w = ui::Label( "Number of elements in chain" );
1942         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1943         gtk_widget_show( w );
1944
1945         // -------------------------- //
1946
1947         hbox = ui::HBox( FALSE, 10 );
1948         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1949         gtk_widget_show( hbox );
1950
1951         textlinkName = ui::Entry( 256 );
1952         gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 );
1953         gtk_widget_show( textlinkName );
1954
1955         w = ui::Label( "Basename for chain's targetnames." );
1956         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1957         gtk_widget_show( w );
1958
1959
1960         w = ui::Button( "OK" );
1961         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1962         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1963         gtk_widget_set_can_default( w, true );
1964         gtk_widget_grab_default( w );
1965         gtk_widget_show( w );
1966
1967         w = ui::Button( "Cancel" );
1968         gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1969         w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1970         gtk_widget_show( w );
1971
1972         ret = eIDCANCEL;
1973
1974         gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1975         gtk_widget_show( window );
1976         gtk_grab_add( window );
1977
1978         bool dialogError = TRUE;
1979         while ( dialogError )
1980         {
1981                 loop = 1;
1982                 while ( loop )
1983                         gtk_main_iteration();
1984
1985                 dialogError = FALSE;
1986
1987                 if ( ret == eIDOK ) {
1988                         strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) );
1989                         if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) {
1990                                 dialogError = TRUE;
1991                         }
1992                 }
1993         }
1994
1995         gtk_grab_remove( window );
1996         gtk_widget_destroy( window );
1997
1998         return ret;
1999 }