2 BobToolz plugin for GtkRadiant
3 Copyright (C) 2001 Gordon Biggans
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.
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.
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
20 #include "dialogs-gtk.h"
21 #include "../funchandlers.h"
26 #include "gtkutil/pointer.h"
27 #include "gtkutil/dialog.h"
33 /*--------------------------------
35 ---------------------------------*/
38 ui::Widget cbTexChange{ui::null};
39 ui::Widget editTexOld{ui::null}, editTexNew{ui::null};
41 ui::Widget cbScaleHor{ui::null}, cbScaleVert{ui::null};
42 ui::Widget editScaleHor{ui::null}, editScaleVert{ui::null};
44 ui::Widget cbShiftHor{ui::null}, cbShiftVert{ui::null};
45 ui::Widget editShiftHor{ui::null}, editShiftVert{ui::null};
47 ui::Widget cbRotation{ui::null};
48 ui::Widget editRotation{ui::null};
51 dlg_texReset_t dlgTexReset;
53 void Update_TextureReseter();
55 static void dialog_button_callback_texreset_update(ui::Widget widget, gpointer data ){
56 Update_TextureReseter();
59 void Update_TextureReseter(){
62 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
63 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexNew ), check );
64 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editTexOld ), check );
66 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
67 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleHor ), check );
69 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
70 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleVert ), check );
72 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
73 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftHor ), check );
75 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
76 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftVert ), check );
78 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
79 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check );
82 static void dialog_button_callback( ui::Widget widget, gpointer data ){
84 EMessageBoxReturn *ret;
86 auto parent = widget.window();
87 loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
88 ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" );
91 *ret = (EMessageBoxReturn)gpointer_to_int( data );
94 static gint custom_dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
96 int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
101 static void dialog_button_callback_settex(ui::Widget widget, gpointer data ){
102 TwinWidget* tw = (TwinWidget*)data;
104 auto entry = ui::Entry::from( tw->one );
105 auto combo = tw->two;
107 const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
108 gtk_entry_set_text( entry, tex );
111 /*--------------------------------
112 Data validation Routines
113 ---------------------------------*/
115 bool ValidateTextFloat( const char* pData, const char* error_title, float* value ){
117 float testNum = (float)atof( pData );
119 if ( ( testNum == 0.0f ) && strcmp( pData, "0" ) ) {
120 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
130 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
134 bool ValidateTextFloatRange( const char* pData, float min, float max, const char* error_title, float* value ){
135 char error_buffer[256];
136 sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max );
139 float testNum = (float)atof( pData );
141 if ( ( testNum < min ) || ( testNum > max ) ) {
142 DoMessageBox( error_buffer, error_title, eMB_OK );
152 DoMessageBox( error_buffer, error_title, eMB_OK );
156 bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){
157 char error_buffer[256];
158 sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max );
161 int testNum = atoi( pData );
163 if ( ( testNum < min ) || ( testNum > max ) ) {
164 DoMessageBox( error_buffer, error_title, eMB_OK );
174 DoMessageBox( error_buffer, error_title, eMB_OK );
178 bool ValidateTextInt( const char* pData, const char* error_title, int* value ){
180 int testNum = atoi( pData );
182 if ( ( testNum == 0 ) && strcmp( pData, "0" ) ) {
183 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
193 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
197 /*--------------------------------
199 ---------------------------------*/
203 Major clean up of variable names etc required, excluding Mars's ones,
204 which are nicely done :)
208 EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){
209 ui::Widget w{ui::null};
210 EMessageBoxReturn ret;
213 auto window = ui::Window( ui::window_type::TOP );
214 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
215 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
216 gtk_window_set_title( window, lpCaption );
217 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
218 g_object_set_data( G_OBJECT( window ), "loop", &loop );
219 g_object_set_data( G_OBJECT( window ), "ret", &ret );
220 gtk_widget_realize( window );
222 auto vbox = ui::VBox( FALSE, 10 );
226 w = ui::Label( lpText );
227 vbox.pack_start( w, FALSE, FALSE, 2 );
228 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
231 w = ui::Widget::from(gtk_hseparator_new());
232 vbox.pack_start( w, FALSE, FALSE, 2 );
235 auto hbox = ui::HBox( FALSE, 10 );
236 vbox.pack_start( hbox, FALSE, FALSE, 2 );
239 if ( type == eMB_OK ) {
240 w = ui::Button( "Ok" );
241 hbox.pack_start( w, TRUE, TRUE, 0 );
242 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
243 gtk_widget_set_can_default(w, true);
244 gtk_widget_grab_default( w );
248 else if ( type == eMB_OKCANCEL ) {
249 w = ui::Button( "Ok" );
250 hbox.pack_start( w, TRUE, TRUE, 0 );
251 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
252 gtk_widget_set_can_default( w, true );
253 gtk_widget_grab_default( w );
256 w = ui::Button( "Cancel" );
257 hbox.pack_start( w, TRUE, TRUE, 0 );
258 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
262 else if ( type == eMB_YESNOCANCEL ) {
263 w = ui::Button( "Yes" );
264 hbox.pack_start( w, TRUE, TRUE, 0 );
265 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
266 gtk_widget_set_can_default( w, true );
267 gtk_widget_grab_default( w );
270 w = ui::Button( "No" );
271 hbox.pack_start( w, TRUE, TRUE, 0 );
272 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
275 w = ui::Button( "Cancel" );
276 hbox.pack_start( w, TRUE, TRUE, 0 );
277 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
281 else /* if (mode == MB_YESNO) */
283 w = ui::Button( "Yes" );
284 hbox.pack_start( w, TRUE, TRUE, 0 );
285 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
286 gtk_widget_set_can_default( w, true );
287 gtk_widget_grab_default( w );
290 w = ui::Button( "No" );
291 hbox.pack_start( w, TRUE, TRUE, 0 );
292 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
297 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
299 gtk_grab_add( window );
302 gtk_main_iteration();
304 gtk_grab_remove( window );
310 EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
311 EMessageBoxReturn ret;
314 auto window = ui::Window( ui::window_type::TOP );
316 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
317 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
319 gtk_window_set_title( window, "Intersect" );
320 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
322 g_object_set_data( G_OBJECT( window ), "loop", &loop );
323 g_object_set_data( G_OBJECT( window ), "ret", &ret );
325 gtk_widget_realize( window );
329 auto vbox = ui::VBox( FALSE, 10 );
336 auto radio1 = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
337 vbox.pack_start( radio1, FALSE, FALSE, 2 );
340 auto radio2 = ui::Widget::from(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ));
341 vbox.pack_start( radio2, FALSE, FALSE, 2 );
344 auto hsep = ui::Widget::from(gtk_hseparator_new());
345 vbox.pack_start( hsep, FALSE, FALSE, 2 );
348 auto check1 = ui::CheckButton( "Include Detail Brushes" );
349 vbox.pack_start( check1, FALSE, FALSE, 0 );
352 auto check2 = ui::CheckButton( "Select Duplicate Brushes Only" );
353 vbox.pack_start( check2, FALSE, FALSE, 0 );
356 auto hbox = ui::HBox( FALSE, 10 );
357 vbox.pack_start( hbox, FALSE, FALSE, 2 );
360 // ---- hbox ---- ok/cancel buttons
362 auto w = ui::Button( "Ok" );
363 hbox.pack_start( w, TRUE, TRUE, 0 );
364 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
366 gtk_widget_set_can_default( w, true );
367 gtk_widget_grab_default( w );
370 w = ui::Button( "Cancel" );
371 hbox.pack_start( w, TRUE, TRUE, 0 );
372 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
380 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
382 gtk_grab_add( window );
385 gtk_main_iteration();
387 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio1) ) ) {
388 rs->nBrushOptions = BRUSH_OPT_WHOLE_MAP;
390 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio2) ) ) {
391 rs->nBrushOptions = BRUSH_OPT_SELECTED;
394 rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check1) ) ? true : false;
395 rs->bDuplicateOnly = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
397 gtk_grab_remove( window );
403 EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
404 EMessageBoxReturn ret;
407 auto window = ui::Window( ui::window_type::TOP );
409 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
410 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
412 gtk_window_set_title( window, "Polygon Builder" );
413 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
415 g_object_set_data( G_OBJECT( window ), "loop", &loop );
416 g_object_set_data( G_OBJECT( window ), "ret", &ret );
418 gtk_widget_realize( window );
422 auto vbox = ui::VBox( FALSE, 10 );
428 auto hbox = ui::HBox( FALSE, 10 );
429 vbox.pack_start( hbox, FALSE, FALSE, 2 );
435 auto vbox2 = ui::VBox( FALSE, 10 );
436 hbox.pack_start( vbox2, FALSE, FALSE, 2 );
441 auto hbox2 = ui::HBox( FALSE, 10 );
442 vbox2.pack_start( hbox2, FALSE, FALSE, 2 );
447 auto text1 = ui::Entry( 256 );
448 gtk_entry_set_text( text1, "3" );
449 hbox2.pack_start( text1, FALSE, FALSE, 2 );
452 auto l = ui::Label( "Number Of Sides" );
453 hbox2.pack_start( l, FALSE, FALSE, 2 );
454 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
459 hbox2 = ui::HBox( FALSE, 10 );
460 vbox2.pack_start( hbox2, FALSE, FALSE, 2 );
465 auto text2 = ui::Entry( 256 );
466 gtk_entry_set_text( text2, "8" );
467 hbox2.pack_start( text2, FALSE, FALSE, 2 );
470 l = ui::Label( "Border Width" );
471 hbox2.pack_start( l, FALSE, FALSE, 2 );
472 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
481 vbox2 = ui::VBox( FALSE, 10 );
482 hbox.pack_start( vbox2, FALSE, FALSE, 2 );
487 auto check1 = ui::CheckButton( "Use Border" );
488 vbox2.pack_start( check1, FALSE, FALSE, 0 );
492 auto check2 = ui::CheckButton( "Inverse Polygon" );
493 vbox2.pack_start( check2, FALSE, FALSE, 0 );
497 auto check3 = ui::CheckButton( "Align Top Edge" );
498 vbox2.pack_start( check3, FALSE, FALSE, 0 );
505 hbox = ui::HBox( FALSE, 10 );
506 vbox.pack_start( hbox, FALSE, FALSE, 2 );
511 auto w = ui::Button( "Ok" );
512 hbox.pack_start( w, TRUE, TRUE, 0 );
513 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
515 gtk_widget_set_can_default( w, true );
516 gtk_widget_grab_default( w );
519 w = ui::Button( "Cancel" );
520 hbox.pack_start( w, TRUE, TRUE, 0 );
521 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
529 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
531 gtk_grab_add( window );
533 bool dialogError = TRUE;
534 while ( dialogError )
538 gtk_main_iteration();
542 if ( ret == eIDOK ) {
543 rs->bUseBorder = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check1) ) ? true : false;
544 rs->bInverse = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
545 rs->bAlignTop = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check3) ) ? true : false;
547 if ( !ValidateTextIntRange( gtk_entry_get_text( text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
551 if ( rs->bUseBorder ) {
552 if ( !ValidateTextIntRange( gtk_entry_get_text( text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
559 gtk_grab_remove( window );
566 // for stair builder stuck as close as i could to the MFC version
567 // obviously feel free to change it at will :)
568 EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
569 GSList *radioDirection, *radioStyle;
570 EMessageBoxReturn ret;
573 const char *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
575 auto window = ui::Window( ui::window_type::TOP );
577 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
578 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
580 gtk_window_set_title( window, "Stair Builder" );
582 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
584 g_object_set_data( G_OBJECT( window ), "loop", &loop );
585 g_object_set_data( G_OBJECT( window ), "ret", &ret );
587 gtk_widget_realize( window );
590 auto vbox = ui::VBox( FALSE, 10 );
594 auto hbox = ui::HBox( FALSE, 10 );
598 // dunno if you want this text or not ...
599 ui::Widget w = ui::Label( text );
600 hbox.pack_start( w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
603 w = ui::Widget::from(gtk_hseparator_new());
604 vbox.pack_start( w, FALSE, FALSE, 0 );
607 // ------------------------- // indenting == good way of keeping track of lines :)
610 hbox = ui::HBox( FALSE, 10 );
611 vbox.pack_start( hbox, FALSE, FALSE, 0 );
614 auto textStairHeight = ui::Entry( 256 );
615 hbox.pack_start( textStairHeight, FALSE, FALSE, 1 );
616 textStairHeight.show();
618 w = ui::Label( "Stair Height" );
619 hbox.pack_start( w, FALSE, FALSE, 1 );
622 // ------------------------- //
624 hbox = ui::HBox( FALSE, 10 );
625 vbox.pack_start( hbox, FALSE, FALSE, 0 );
628 w = ui::Label( "Direction:" );
629 hbox.pack_start( w, FALSE, FALSE, 5 );
632 // -------------------------- //
634 hbox = ui::HBox( FALSE, 10 );
635 vbox.pack_start( hbox, FALSE, FALSE, 0 );
638 // radio buttons confuse me ...
639 // but this _looks_ right
641 // djbob: actually it looks very nice :), slightly better than the way i did it
642 // edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
644 auto radioNorth = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North" ));
645 hbox.pack_start( radioNorth, FALSE, FALSE, 3 );
648 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
650 auto radioSouth = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "South" ));
651 hbox.pack_start( radioSouth, FALSE, FALSE, 2 );
654 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
656 auto radioEast = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "East" ));
657 hbox.pack_start( radioEast, FALSE, FALSE, 1 );
660 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
662 auto radioWest = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "West" ));
663 hbox.pack_start( radioWest, FALSE, FALSE, 0 );
666 // --------------------------- //
668 hbox = ui::HBox( FALSE, 10 );
669 vbox.pack_start( hbox, FALSE, FALSE, 0 );
672 w = ui::Label( "Style:" );
673 hbox.pack_start( w, FALSE, FALSE, 5 );
676 // --------------------------- //
678 hbox = ui::HBox( FALSE, 10 );
679 vbox.pack_start( hbox, FALSE, FALSE, 0 );
682 auto radioOldStyle = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Original" ));
683 hbox.pack_start( radioOldStyle, FALSE, FALSE, 0 );
684 radioOldStyle.show();
686 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
688 auto radioBobStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ));
689 hbox.pack_start( radioBobStyle, FALSE, FALSE, 0 );
690 radioBobStyle.show();
692 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
694 auto radioCornerStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Corner Style" ));
695 hbox.pack_start( radioCornerStyle, FALSE, FALSE, 0 );
696 radioCornerStyle.show();
698 // err, the q3r has an if or something so you need bob style checked before this
699 // is "ungreyed out" but you'll need to do that, as i suck :)
701 // djbob: er.... yeah um, im not at all sure how i'm gonna sort this
702 // djbob: think we need some button callback functions or smuffin
703 // FIXME: actually get around to doing what i suggested!!!!
705 auto checkUseDetail = ui::CheckButton( "Use Detail Brushes" );
706 hbox.pack_start( checkUseDetail, FALSE, FALSE, 0 );
707 checkUseDetail.show();
709 // --------------------------- //
711 hbox = ui::HBox( FALSE, 10 );
712 vbox.pack_start( hbox, FALSE, FALSE, 0 );
715 auto textMainTex = ui::Entry( 512 );
716 gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture );
717 hbox.pack_start( textMainTex, FALSE, FALSE, 0 );
720 w = ui::Label( "Main Texture" );
721 hbox.pack_start( w, FALSE, FALSE, 1 );
724 // -------------------------- //
726 hbox = ui::HBox( FALSE, 10 );
727 vbox.pack_start( hbox, FALSE, FALSE, 0 );
730 auto textRiserTex = ui::Entry( 512 );
731 hbox.pack_start( textRiserTex, FALSE, FALSE, 0 );
734 w = ui::Label( "Riser Texture" );
735 hbox.pack_start( w, FALSE, FALSE, 1 );
738 // -------------------------- //
739 w = ui::Widget::from(gtk_hseparator_new());
740 vbox.pack_start( w, FALSE, FALSE, 0 );
743 hbox = ui::HBox( FALSE, 10 );
744 vbox.pack_start( hbox, FALSE, FALSE, 0 );
747 w = ui::Button( "OK" );
748 hbox.pack_start( w, TRUE, TRUE, 0 );
749 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
750 gtk_widget_set_can_default( w, true );
751 gtk_widget_grab_default( w );
754 w = ui::Button( "Cancel" );
755 hbox.pack_start( w, TRUE, TRUE, 0 );
756 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
761 // +djbob: need our "little" modal loop mars :P
762 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
764 gtk_grab_add( window );
766 bool dialogError = TRUE;
767 while ( dialogError )
771 gtk_main_iteration();
775 if ( ret == eIDOK ) {
776 rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(checkUseDetail) ) ? true : false;
778 strcpy( rs->riserTexture, gtk_entry_get_text( textRiserTex ) );
779 strcpy( rs->mainTexture, gtk_entry_get_text( textMainTex ) );
781 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioNorth) ) ) {
782 rs->direction = MOVE_NORTH;
784 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioSouth) ) ) {
785 rs->direction = MOVE_SOUTH;
787 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioEast) ) ) {
788 rs->direction = MOVE_EAST;
790 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioWest) ) ) {
791 rs->direction = MOVE_WEST;
794 if ( !ValidateTextInt( gtk_entry_get_text( textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
798 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioOldStyle) ) ) {
799 rs->style = STYLE_ORIGINAL;
801 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioBobStyle) ) ) {
802 rs->style = STYLE_BOB;
804 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioCornerStyle) ) ) {
805 rs->style = STYLE_CORNER;
810 gtk_grab_remove( window );
816 // there we go, all done ... on my end at least, not bad for a night's work
819 EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
820 GSList *radioOrientation;
822 EMessageBoxReturn ret;
825 auto window = ui::Window( ui::window_type::TOP );
827 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
828 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
830 gtk_window_set_title( window, "Door Builder" );
832 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
834 g_object_set_data( G_OBJECT( window ), "loop", &loop );
835 g_object_set_data( G_OBJECT( window ), "ret", &ret );
837 gtk_widget_realize( window );
840 auto listMainTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
841 auto listTrimTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
842 LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
843 LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
845 auto vbox = ui::VBox( FALSE, 10 );
849 // -------------------------- //
851 auto hbox = ui::HBox( FALSE, 10 );
852 vbox.pack_start( hbox, FALSE, FALSE, 0 );
855 auto textFrontBackTex = ui::Entry( 512 );
856 gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture );
857 hbox.pack_start( textFrontBackTex, FALSE, FALSE, 0 );
858 textFrontBackTex.show();
860 ui::Widget w = ui::Label( "Door Front/Back Texture" );
861 hbox.pack_start( w, FALSE, FALSE, 0 );
864 // ------------------------ //
866 hbox = ui::HBox( FALSE, 10 );
867 vbox.pack_start( hbox, FALSE, FALSE, 0 );
870 auto textTrimTex = ui::Entry( 512 );
871 hbox.pack_start( textTrimTex, FALSE, FALSE, 0 );
874 w = ui::Label( "Door Trim Texture" );
875 hbox.pack_start( w, FALSE, FALSE, 0 );
878 // ----------------------- //
880 hbox = ui::HBox( FALSE, 10 );
881 vbox.pack_start( hbox, FALSE, FALSE, 0 );
884 // sp: horizontally ????
885 // djbob: yes mars, u can spell :]
886 auto checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" );
887 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE );
888 hbox.pack_start( checkScaleMainH, FALSE, FALSE, 0 );
889 checkScaleMainH.show();
891 auto checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" );
892 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE );
893 hbox.pack_start( checkScaleTrimH, FALSE, FALSE, 0 );
894 checkScaleTrimH.show();
896 // ---------------------- //
898 hbox = ui::HBox( FALSE, 10 );
899 vbox.pack_start( hbox, FALSE, FALSE, 0 );
902 auto checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" );
903 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE );
904 hbox.pack_start( checkScaleMainV, FALSE, FALSE, 0 );
905 checkScaleMainV.show();
907 auto checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" );
908 hbox.pack_start( checkScaleTrimV, FALSE, FALSE, 0 );
909 checkScaleTrimV.show();
911 // --------------------- //
913 hbox = ui::HBox( FALSE, 10 );
914 vbox.pack_start( hbox, FALSE, FALSE, 0 );
917 // djbob: lists added
919 auto comboMain = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listMainTextures));
920 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
921 hbox.pack_start( comboMain, FALSE, FALSE, 0 );
924 tw1.one = textFrontBackTex;
927 auto buttonSetMain = ui::Button( "Set As Main Texture" );
928 buttonSetMain.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 );
929 hbox.pack_start( buttonSetMain, FALSE, FALSE, 0 );
930 buttonSetMain.show();
932 // ------------------- //
934 hbox = ui::HBox( FALSE, 10 );
935 vbox.pack_start( hbox, FALSE, FALSE, 0 );
938 auto comboTrim = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listTrimTextures));
939 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
940 hbox.pack_start( comboTrim, FALSE, FALSE, 0 );
943 tw2.one = textTrimTex;
946 auto buttonSetTrim = ui::Button( "Set As Trim Texture" );
947 buttonSetTrim.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 );
948 hbox.pack_start( buttonSetTrim, FALSE, FALSE, 0 );
949 buttonSetTrim.show();
951 // ------------------ //
953 hbox = ui::HBox( FALSE, 10 );
954 vbox.pack_start( hbox, FALSE, FALSE, 0 );
957 w = ui::Label( "Orientation" );
958 hbox.pack_start( w, FALSE, FALSE, 0 );
961 // argh more radio buttons!
962 auto radioNS = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North - South" ));
963 hbox.pack_start( radioNS, FALSE, FALSE, 0 );
966 radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
968 auto radioEW = ui::Widget::from(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
969 hbox.pack_start( radioEW, FALSE, FALSE, 0 );
972 // ----------------- //
974 w = ui::Widget::from(gtk_hseparator_new());
975 vbox.pack_start( w, FALSE, FALSE, 0 );
978 // ----------------- //
980 hbox = ui::HBox( FALSE, 10 );
981 vbox.pack_start( hbox, FALSE, FALSE, 0 );
984 w = ui::Button( "OK" );
985 hbox.pack_start( w, TRUE, TRUE, 0 );
986 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
987 gtk_widget_set_can_default( w, true );
988 gtk_widget_grab_default( w );
991 w = ui::Button( "Cancel" );
992 hbox.pack_start( w, TRUE, TRUE, 0 );
993 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
997 // ----------------- //
1000 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1002 gtk_grab_add( window );
1005 gtk_main_iteration();
1007 strcpy( rs->mainTexture, gtk_entry_get_text( GTK_ENTRY( textFrontBackTex ) ) );
1008 strcpy( rs->trimTexture, gtk_entry_get_text( GTK_ENTRY( textTrimTex ) ) );
1010 rs->bScaleMainH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainH ) ) ? true : false;
1011 rs->bScaleMainV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainV ) ) ? true : false;
1012 rs->bScaleTrimH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ) ) ? true : false;
1013 rs->bScaleTrimV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimV ) ) ? true : false;
1015 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioNS ) ) ) {
1016 rs->nOrientation = DIRECTION_NS;
1018 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioEW ) ) ) {
1019 rs->nOrientation = DIRECTION_EW;
1022 gtk_grab_remove( window );
1029 EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs, ui::Window main_window ){
1030 ui::Widget w{ui::null};
1033 EMessageBoxReturn ret;
1036 auto window = main_window.create_dialog_window( "Path Plotter", G_CALLBACK( custom_dialog_delete_callback ), &dialog );
1038 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1040 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1042 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1043 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1045 gtk_widget_realize( window );
1047 auto vbox = ui::VBox( FALSE, 10 );
1053 auto hbox = ui::HBox( FALSE, 10 );
1054 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1059 auto text1 = ui::Entry( 256 );
1060 gtk_entry_set_text( text1, "25" );
1061 hbox.pack_start( text1, FALSE, FALSE, 2 );
1064 w = ui::Label( "Number Of Points" );
1065 hbox.pack_start( w, FALSE, FALSE, 2 );
1066 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1071 hbox = ui::HBox( FALSE, 10 );
1072 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1077 auto text2 = ui::Entry( 256 );
1078 gtk_entry_set_text( text2, "3" );
1079 hbox.pack_start( text2, FALSE, FALSE, 2 );
1082 w = ui::Label( "Multipler" );
1083 hbox.pack_start( w, FALSE, FALSE, 2 );
1084 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1089 w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" );
1090 vbox.pack_start( w, FALSE, FALSE, 0 );
1091 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1094 hbox = ui::HBox( FALSE, 10 );
1095 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1100 auto text3 = ui::Entry( 256 );
1101 gtk_entry_set_text( text3, "-800" );
1102 hbox.pack_start( text3, FALSE, FALSE, 2 );
1105 w = ui::Label( "Gravity" );
1106 hbox.pack_start( w, FALSE, FALSE, 2 );
1107 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1112 w = ui::Widget::from(gtk_hseparator_new());
1113 vbox.pack_start( w, FALSE, FALSE, 0 );
1116 auto check1 = ui::CheckButton( "No Dynamic Update" );
1117 vbox.pack_start( check1, FALSE, FALSE, 0 );
1120 auto check2 = ui::CheckButton( "Show Bounding Lines" );
1121 vbox.pack_start( check2, FALSE, FALSE, 0 );
1127 // ----------------- //
1129 w = ui::Widget::from(gtk_hseparator_new());
1130 vbox.pack_start( w, FALSE, FALSE, 0 );
1133 // ----------------- //
1135 hbox = ui::HBox( FALSE, 10 );
1136 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1139 w = ui::Button( "Enable" );
1140 hbox.pack_start( w, TRUE, TRUE, 0 );
1141 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1144 gtk_widget_set_can_default( w, true );
1145 gtk_widget_grab_default( w );
1147 w = ui::Button( "Disable" );
1148 hbox.pack_start( w, TRUE, TRUE, 0 );
1149 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
1152 w = ui::Button( "Cancel" );
1153 hbox.pack_start( w, TRUE, TRUE, 0 );
1154 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1159 // ----------------- //
1161 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1163 gtk_grab_add( window );
1165 bool dialogError = TRUE;
1166 while ( dialogError )
1170 gtk_main_iteration();
1172 dialogError = FALSE;
1174 if ( ret == eIDYES ) {
1175 if ( !ValidateTextIntRange( gtk_entry_get_text( GTK_ENTRY( text1 ) ), 1, 200, "Number Of Points", &rs->nPoints ) ) {
1179 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text2 ) ), 1.0f, 10.0f, "Multiplier", &rs->fMultiplier ) ) {
1183 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text3 ) ), -10000.0f, -1.0f, "Gravity", &rs->fGravity ) ) {
1187 rs->bNoUpdate = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check1 ) ) ? true : false;
1188 rs->bShowExtra = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check2 ) ) ? true : false;
1192 gtk_grab_remove( window );
1198 EMessageBoxReturn DoCTFColourChangeBox(){
1199 ui::Widget w{ui::null};
1200 EMessageBoxReturn ret;
1203 auto window = ui::Window( ui::window_type::TOP );
1205 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
1206 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1208 gtk_window_set_title( window, "CTF Colour Changer" );
1209 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1211 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1212 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1214 gtk_widget_realize( window );
1218 auto vbox = ui::VBox( FALSE, 10 );
1224 auto hbox = ui::HBox( FALSE, 10 );
1225 vbox.pack_start( hbox, TRUE, TRUE, 0 );
1228 // ---- hbox ---- ok/cancel buttons
1230 w = ui::Button( "Red->Blue" );
1231 hbox.pack_start( w, TRUE, TRUE, 0 );
1232 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1234 gtk_widget_set_can_default( w, true );
1235 gtk_widget_grab_default( w );
1238 w = ui::Button( "Blue->Red" );
1239 hbox.pack_start( w, TRUE, TRUE, 0 );
1240 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1243 w = ui::Button( "Cancel" );
1244 hbox.pack_start( w, TRUE, TRUE, 0 );
1245 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1253 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1255 gtk_grab_add( window );
1258 gtk_main_iteration();
1260 gtk_grab_remove( window );
1266 EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs, ui::Window main_window ){
1269 ui::Widget w{ui::null};
1272 EMessageBoxReturn ret;
1275 auto window = main_window.create_dialog_window( "Texture Reset", G_CALLBACK( custom_dialog_delete_callback ), &dialog );
1277 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1279 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1281 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1282 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1284 gtk_widget_realize( window );
1286 auto vbox = ui::VBox( FALSE, 10 );
1292 auto hbox = ui::HBox( FALSE, 10 );
1293 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1298 texSelected = "Currently Selected Texture: ";
1299 texSelected += GetCurrentTexture();
1301 w = ui::Label( texSelected );
1302 hbox.pack_start( w, FALSE, FALSE, 2 );
1303 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1308 auto frame = ui::Frame( "Reset Texture Names" );
1310 vbox.pack_start( frame, FALSE, TRUE, 0 );
1312 auto table = ui::Table( 2, 3, TRUE );
1315 gtk_table_set_row_spacings(table, 5);
1316 gtk_table_set_col_spacings(table, 5);
1317 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1321 dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
1322 dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1323 dlgTexReset.cbTexChange.show();
1324 table.attach(dlgTexReset.cbTexChange, {0, 1, 0, 1}, {GTK_FILL, 0});
1326 w = ui::Label( "Old Name: " );
1327 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1330 dlgTexReset.editTexOld = ui::Entry( 256 );
1331 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
1332 table.attach(dlgTexReset.editTexOld, {2, 3, 0, 1}, {GTK_FILL, 0});
1333 dlgTexReset.editTexOld.show();
1335 w = ui::Label( "New Name: " );
1336 table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
1339 dlgTexReset.editTexNew = ui::Entry( 256 );
1340 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
1341 table.attach(dlgTexReset.editTexNew, {2, 3, 1, 2}, {GTK_FILL, 0});
1342 dlgTexReset.editTexNew.show();
1346 frame = ui::Frame( "Reset Scales" );
1348 vbox.pack_start( frame, FALSE, TRUE, 0 );
1350 table = ui::Table( 2, 3, TRUE );
1353 gtk_table_set_row_spacings(table, 5);
1354 gtk_table_set_col_spacings(table, 5);
1355 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1359 dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
1360 dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1361 dlgTexReset.cbScaleHor.show();
1362 table.attach(dlgTexReset.cbScaleHor, {0, 1, 0, 1}, {GTK_FILL, 0});
1364 w = ui::Label( "New Horizontal Scale: " );
1365 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1368 dlgTexReset.editScaleHor = ui::Entry( 256 );
1369 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
1370 table.attach(dlgTexReset.editScaleHor, {2, 3, 0, 1}, {GTK_FILL, 0});
1371 dlgTexReset.editScaleHor.show();
1374 dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
1375 dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1376 dlgTexReset.cbScaleVert.show();
1377 table.attach(dlgTexReset.cbScaleVert, {0, 1, 1, 2}, {GTK_FILL, 0});
1379 w = ui::Label( "New Vertical Scale: " );
1380 table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
1383 dlgTexReset.editScaleVert = ui::Entry( 256 );
1384 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
1385 table.attach(dlgTexReset.editScaleVert, {2, 3, 1, 2}, {GTK_FILL, 0});
1386 dlgTexReset.editScaleVert.show();
1390 frame = ui::Frame( "Reset Shift" );
1392 vbox.pack_start( frame, FALSE, TRUE, 0 );
1394 table = ui::Table( 2, 3, TRUE );
1397 gtk_table_set_row_spacings(table, 5);
1398 gtk_table_set_col_spacings(table, 5);
1399 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1403 dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
1404 dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1405 dlgTexReset.cbShiftHor.show();
1406 table.attach(dlgTexReset.cbShiftHor, {0, 1, 0, 1}, {GTK_FILL, 0});
1408 w = ui::Label( "New Horizontal Shift: " );
1409 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1412 dlgTexReset.editShiftHor = ui::Entry( 256 );
1413 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
1414 table.attach(dlgTexReset.editShiftHor, {2, 3, 0, 1}, {GTK_FILL, 0});
1415 dlgTexReset.editShiftHor.show();
1418 dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
1419 dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1420 dlgTexReset.cbShiftVert.show();
1421 table.attach(dlgTexReset.cbShiftVert, {0, 1, 1, 2}, {GTK_FILL, 0});
1423 w = ui::Label( "New Vertical Shift: " );
1424 table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
1427 dlgTexReset.editShiftVert = ui::Entry( 256 );
1428 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
1429 table.attach(dlgTexReset.editShiftVert, {2, 3, 1, 2}, {GTK_FILL, 0});
1430 dlgTexReset.editShiftVert.show();
1434 frame = ui::Frame( "Reset Rotation" );
1436 vbox.pack_start( frame, FALSE, TRUE, 0 );
1438 table = ui::Table( 1, 3, TRUE );
1441 gtk_table_set_row_spacings(table, 5);
1442 gtk_table_set_col_spacings(table, 5);
1443 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1447 dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
1448 dlgTexReset.cbRotation.show();
1449 table.attach(dlgTexReset.cbRotation, {0, 1, 0, 1}, {GTK_FILL, 0});
1451 w = ui::Label( "New Rotation Value: " );
1452 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1455 dlgTexReset.editRotation = ui::Entry( 256 );
1456 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
1457 table.attach(dlgTexReset.editRotation, {2, 3, 0, 1}, {GTK_FILL, 0});
1458 dlgTexReset.editRotation.show();
1462 hbox = ui::HBox( FALSE, 10 );
1463 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1468 w = ui::Button( "Use Selected Brushes" );
1469 hbox.pack_start( w, TRUE, TRUE, 0 );
1470 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1472 gtk_widget_set_can_default( w, true );
1473 gtk_widget_grab_default( w );
1476 w = ui::Button( "Use All Brushes" );
1477 hbox.pack_start( w, TRUE, TRUE, 0 );
1478 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1481 w = ui::Button( "Cancel" );
1482 hbox.pack_start( w, TRUE, TRUE, 0 );
1483 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1492 gtk_grab_add( window );
1494 Update_TextureReseter();
1496 bool dialogError = TRUE;
1497 while ( dialogError )
1501 gtk_main_iteration();
1503 dialogError = FALSE;
1505 if ( ret != eIDCANCEL ) {
1506 rs->bResetRotation = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
1507 if ( rs->bResetRotation ) {
1508 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editRotation ) ), "Rotation", &rs->rotation ) ) {
1513 rs->bResetScale[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
1514 if ( rs->bResetScale[0] ) {
1515 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleHor ) ), "Horizontal Scale", &rs->fScale[0] ) ) {
1520 rs->bResetScale[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
1521 if ( rs->bResetScale[1] ) {
1522 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleVert ) ), "Vertical Scale", &rs->fScale[1] ) ) {
1527 rs->bResetShift[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
1528 if ( rs->bResetShift[0] ) {
1529 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftHor ) ), "Horizontal Shift", &rs->fShift[0] ) ) {
1534 rs->bResetShift[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
1535 if ( rs->bResetShift[1] ) {
1536 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftVert ) ), "Vertical Shift", &rs->fShift[1] ) ) {
1541 rs->bResetTextureName = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
1542 if ( rs->bResetTextureName ) {
1543 strcpy( rs->textureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexOld ) ) );
1544 strcpy( rs->newTextureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexNew ) ) );
1549 gtk_grab_remove( window );
1555 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
1558 ui::Widget w{ui::null};
1560 ui::Widget radiusX{ui::null}, radiusY{ui::null};
1561 ui::Widget angleStart{ui::null}, angleEnd{ui::null};
1562 ui::Widget heightStart{ui::null}, heightEnd{ui::null};
1563 ui::Widget numPoints{ui::null};
1565 EMessageBoxReturn ret;
1568 auto window = ui::Window( ui::window_type::TOP );
1570 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
1571 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1573 gtk_window_set_title( window, "Train Thing" );
1574 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1576 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1577 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1579 gtk_widget_realize( window );
1581 auto vbox = ui::VBox( FALSE, 10 );
1587 auto hbox = ui::HBox( FALSE, 10 );
1588 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1593 auto frame = ui::Frame( "Radii" );
1595 vbox.pack_start( frame, FALSE, TRUE, 0 );
1597 auto table = ui::Table( 2, 3, TRUE );
1600 gtk_table_set_row_spacings(table, 5);
1601 gtk_table_set_col_spacings(table, 5);
1602 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1606 w = ui::Label( "X: " );
1607 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1610 radiusX = ui::Entry( 256 );
1611 gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
1612 table.attach(radiusX, {1, 2, 0, 1}, {GTK_FILL, 0});
1617 w = ui::Label( "Y: " );
1618 table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
1621 radiusY = ui::Entry( 256 );
1622 gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
1623 table.attach(radiusY, {1, 2, 1, 2}, {GTK_FILL, 0});
1628 frame = ui::Frame( "Angles" );
1630 vbox.pack_start( frame, FALSE, TRUE, 0 );
1632 table = ui::Table( 2, 3, TRUE );
1635 gtk_table_set_row_spacings((table), 5);
1636 gtk_table_set_col_spacings((table), 5);
1637 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1641 w = ui::Label( "Start: " );
1642 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1645 angleStart = ui::Entry( 256 );
1646 gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
1647 table.attach(angleStart, {1, 2, 0, 1}, {GTK_FILL, 0});
1652 w = ui::Label( "End: " );
1653 table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
1656 angleEnd = ui::Entry( 256 );
1657 gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
1658 table.attach(angleEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
1662 frame = ui::Frame( "Height" );
1664 vbox.pack_start( frame, FALSE, TRUE, 0 );
1666 table = ui::Table( 2, 3, TRUE );
1669 gtk_table_set_row_spacings(table, 5);
1670 gtk_table_set_col_spacings(table, 5);
1671 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1675 w = ui::Label( "Start: " );
1676 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1679 heightStart = ui::Entry( 256 );
1680 gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
1681 table.attach(heightStart, {1, 2, 0, 1}, {GTK_FILL, 0});
1686 w = ui::Label( "End: " );
1687 table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
1690 heightEnd = ui::Entry( 256 );
1691 gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
1692 table.attach(heightEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
1697 frame = ui::Frame( "Points" );
1699 vbox.pack_start( frame, FALSE, TRUE, 0 );
1701 table = ui::Table( 2, 3, TRUE );
1704 gtk_table_set_row_spacings(table, 5);
1705 gtk_table_set_col_spacings(table, 5);
1706 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1710 w = ui::Label( "Number: " );
1711 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1714 numPoints = ui::Entry( 256 );
1715 gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
1716 table.attach(numPoints, {1, 2, 0, 1}, {GTK_FILL, 0});
1720 hbox = ui::HBox( FALSE, 10 );
1721 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1726 w = ui::Button( "Ok" );
1727 hbox.pack_start( w, TRUE, TRUE, 0 );
1728 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1730 gtk_widget_set_can_default( w, true );
1731 gtk_widget_grab_default( w );
1734 w = ui::Button( "Cancel" );
1735 hbox.pack_start( w, TRUE, TRUE, 0 );
1736 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1744 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1746 gtk_grab_add( window );
1748 bool dialogError = TRUE;
1749 while ( dialogError )
1753 gtk_main_iteration();
1755 dialogError = FALSE;
1757 if ( ret != eIDCANCEL ) {
1758 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusX ) ), "Radius (X)", &rs->fRadiusX ) ) {
1762 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusY ) ), "Radius (Y)", &rs->fRadiusY ) ) {
1766 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleStart ) ), "Angle (Start)", &rs->fStartAngle ) ) {
1770 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleEnd ) ), "Angle (End)", &rs->fEndAngle ) ) {
1774 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightStart ) ), "Height (Start)", &rs->fStartHeight ) ) {
1778 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightEnd ) ), "Height (End)", &rs->fEndHeight ) ) {
1782 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( numPoints ) ), "Num Points", &rs->iNumPoints ) ) {
1788 gtk_grab_remove( window );
1794 // add a simple input for the MakeChain thing..
1795 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
1796 ui::Widget w{ui::null};
1797 ui::Entry textlinkNum{ui::null}, textlinkName{ui::null};
1798 EMessageBoxReturn ret;
1801 const char *text = "Please set a value in the boxes below and press 'OK' to make a chain";
1803 auto window = ui::Window( ui::window_type::TOP );
1805 window.connect( "delete_event", G_CALLBACK( custom_dialog_delete_callback ), NULL );
1806 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1808 gtk_window_set_title( window, "Make Chain" );
1810 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1812 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1813 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1815 gtk_widget_realize( window );
1818 auto vbox = ui::VBox( FALSE, 10 );
1822 auto hbox = ui::HBox( FALSE, 10 );
1826 // dunno if you want this text or not ...
1827 w = ui::Label( text );
1828 hbox.pack_start( w, FALSE, FALSE, 0 );
1831 w = ui::Widget::from(gtk_hseparator_new());
1832 vbox.pack_start( w, FALSE, FALSE, 0 );
1835 // ------------------------- //
1838 hbox = ui::HBox( FALSE, 10 );
1839 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1842 textlinkNum = ui::Entry( 256 );
1843 hbox.pack_start( textlinkNum, FALSE, FALSE, 1 );
1846 w = ui::Label( "Number of elements in chain" );
1847 hbox.pack_start( w, FALSE, FALSE, 1 );
1850 // -------------------------- //
1852 hbox = ui::HBox( FALSE, 10 );
1853 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1856 textlinkName = ui::Entry( 256 );
1857 hbox.pack_start( textlinkName, FALSE, FALSE, 0 );
1858 textlinkName.show();
1860 w = ui::Label( "Basename for chain's targetnames." );
1861 hbox.pack_start( w, FALSE, FALSE, 1 );
1865 w = ui::Button( "OK" );
1866 hbox.pack_start( w, TRUE, TRUE, 0 );
1867 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1868 gtk_widget_set_can_default( w, true );
1869 gtk_widget_grab_default( w );
1872 w = ui::Button( "Cancel" );
1873 hbox.pack_start( w, TRUE, TRUE, 0 );
1874 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1879 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1881 gtk_grab_add( window );
1883 bool dialogError = TRUE;
1884 while ( dialogError )
1888 gtk_main_iteration();
1890 dialogError = FALSE;
1892 if ( ret == eIDOK ) {
1893 strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) );
1894 if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) {
1900 gtk_grab_remove( window );