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"
32 /*--------------------------------
34 ---------------------------------*/
37 ui::Widget cbTexChange{ui::null};
38 ui::Widget editTexOld{ui::null}, editTexNew{ui::null};
40 ui::Widget cbScaleHor{ui::null}, cbScaleVert{ui::null};
41 ui::Widget editScaleHor{ui::null}, editScaleVert{ui::null};
43 ui::Widget cbShiftHor{ui::null}, cbShiftVert{ui::null};
44 ui::Widget editShiftHor{ui::null}, editShiftVert{ui::null};
46 ui::Widget cbRotation{ui::null};
47 ui::Widget editRotation{ui::null};
50 dlg_texReset_t dlgTexReset;
52 void Update_TextureReseter();
54 static void dialog_button_callback_texreset_update(ui::Widget widget, gpointer data ){
55 Update_TextureReseter();
58 void Update_TextureReseter(){
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 );
65 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
66 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleHor ), check );
68 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
69 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editScaleVert ), check );
71 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
72 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftHor ), check );
74 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
75 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editShiftVert ), check );
77 check = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
78 gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check );
81 static void dialog_button_callback( ui::Widget widget, gpointer data ){
83 EMessageBoxReturn *ret;
85 auto parent = widget.window();
86 loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
87 ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" );
90 *ret = (EMessageBoxReturn)gpointer_to_int( data );
93 static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
95 int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
100 static void dialog_button_callback_settex(ui::Widget widget, gpointer data ){
101 TwinWidget* tw = (TwinWidget*)data;
103 auto entry = ui::Entry::from( tw->one );
104 auto combo = tw->two;
106 const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
107 gtk_entry_set_text( entry, tex );
110 /*--------------------------------
111 Data validation Routines
112 ---------------------------------*/
114 bool ValidateTextFloat( const char* pData, const char* error_title, float* value ){
116 float testNum = (float)atof( pData );
118 if ( ( testNum == 0.0f ) && strcmp( pData, "0" ) ) {
119 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
129 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
133 bool ValidateTextFloatRange( const char* pData, float min, float max, const char* error_title, float* value ){
134 char error_buffer[256];
135 sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max );
138 float testNum = (float)atof( pData );
140 if ( ( testNum < min ) || ( testNum > max ) ) {
141 DoMessageBox( error_buffer, error_title, eMB_OK );
151 DoMessageBox( error_buffer, error_title, eMB_OK );
155 bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){
156 char error_buffer[256];
157 sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max );
160 int testNum = atoi( pData );
162 if ( ( testNum < min ) || ( testNum > max ) ) {
163 DoMessageBox( error_buffer, error_title, eMB_OK );
173 DoMessageBox( error_buffer, error_title, eMB_OK );
177 bool ValidateTextInt( const char* pData, const char* error_title, int* value ){
179 int testNum = atoi( pData );
181 if ( ( testNum == 0 ) && strcmp( pData, "0" ) ) {
182 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
192 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
196 /*--------------------------------
198 ---------------------------------*/
202 Major clean up of variable names etc required, excluding Mars's ones,
203 which are nicely done :)
207 EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){
208 ui::Widget w{ui::null};
209 EMessageBoxReturn ret;
212 auto window = ui::Window( ui::window_type::TOP );
213 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
214 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
215 gtk_window_set_title( window, lpCaption );
216 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
217 g_object_set_data( G_OBJECT( window ), "loop", &loop );
218 g_object_set_data( G_OBJECT( window ), "ret", &ret );
219 gtk_widget_realize( window );
221 auto vbox = ui::VBox( FALSE, 10 );
225 w = ui::Label( lpText );
226 vbox.pack_start( w, FALSE, FALSE, 2 );
227 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
230 w = ui::Widget::from(gtk_hseparator_new());
231 vbox.pack_start( w, FALSE, FALSE, 2 );
234 auto hbox = ui::HBox( FALSE, 10 );
235 vbox.pack_start( hbox, FALSE, FALSE, 2 );
238 if ( type == eMB_OK ) {
239 w = ui::Button( "Ok" );
240 hbox.pack_start( w, TRUE, TRUE, 0 );
241 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
242 gtk_widget_set_can_default(w, true);
243 gtk_widget_grab_default( w );
247 else if ( type == eMB_OKCANCEL ) {
248 w = ui::Button( "Ok" );
249 hbox.pack_start( w, TRUE, TRUE, 0 );
250 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
251 gtk_widget_set_can_default( w, true );
252 gtk_widget_grab_default( w );
255 w = ui::Button( "Cancel" );
256 hbox.pack_start( w, TRUE, TRUE, 0 );
257 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
261 else if ( type == eMB_YESNOCANCEL ) {
262 w = ui::Button( "Yes" );
263 hbox.pack_start( w, TRUE, TRUE, 0 );
264 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
265 gtk_widget_set_can_default( w, true );
266 gtk_widget_grab_default( w );
269 w = ui::Button( "No" );
270 hbox.pack_start( w, TRUE, TRUE, 0 );
271 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
274 w = ui::Button( "Cancel" );
275 hbox.pack_start( w, TRUE, TRUE, 0 );
276 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
280 else /* if (mode == MB_YESNO) */
282 w = ui::Button( "Yes" );
283 hbox.pack_start( w, TRUE, TRUE, 0 );
284 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
285 gtk_widget_set_can_default( w, true );
286 gtk_widget_grab_default( w );
289 w = ui::Button( "No" );
290 hbox.pack_start( w, TRUE, TRUE, 0 );
291 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
296 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
298 gtk_grab_add( window );
301 gtk_main_iteration();
303 gtk_grab_remove( window );
309 EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
310 EMessageBoxReturn ret;
313 auto window = ui::Window( ui::window_type::TOP );
315 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
316 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
318 gtk_window_set_title( window, "Intersect" );
319 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
321 g_object_set_data( G_OBJECT( window ), "loop", &loop );
322 g_object_set_data( G_OBJECT( window ), "ret", &ret );
324 gtk_widget_realize( window );
328 auto vbox = ui::VBox( FALSE, 10 );
335 auto radio1 = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
336 vbox.pack_start( radio1, FALSE, FALSE, 2 );
339 auto radio2 = ui::Widget::from(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ));
340 vbox.pack_start( radio2, FALSE, FALSE, 2 );
343 auto hsep = ui::Widget::from(gtk_hseparator_new());
344 vbox.pack_start( hsep, FALSE, FALSE, 2 );
347 auto check1 = ui::CheckButton( "Include Detail Brushes" );
348 vbox.pack_start( check1, FALSE, FALSE, 0 );
351 auto check2 = ui::CheckButton( "Select Duplicate Brushes Only" );
352 vbox.pack_start( check2, FALSE, FALSE, 0 );
355 auto hbox = ui::HBox( FALSE, 10 );
356 vbox.pack_start( hbox, FALSE, FALSE, 2 );
359 // ---- hbox ---- ok/cancel buttons
361 auto w = ui::Button( "Ok" );
362 hbox.pack_start( w, TRUE, TRUE, 0 );
363 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
365 gtk_widget_set_can_default( w, true );
366 gtk_widget_grab_default( w );
369 w = ui::Button( "Cancel" );
370 hbox.pack_start( w, TRUE, TRUE, 0 );
371 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
379 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
381 gtk_grab_add( window );
384 gtk_main_iteration();
386 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio1) ) ) {
387 rs->nBrushOptions = BRUSH_OPT_WHOLE_MAP;
389 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio2) ) ) {
390 rs->nBrushOptions = BRUSH_OPT_SELECTED;
393 rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check1) ) ? true : false;
394 rs->bDuplicateOnly = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
396 gtk_grab_remove( window );
402 EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
403 EMessageBoxReturn ret;
406 auto window = ui::Window( ui::window_type::TOP );
408 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
409 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
411 gtk_window_set_title( window, "Polygon Builder" );
412 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
414 g_object_set_data( G_OBJECT( window ), "loop", &loop );
415 g_object_set_data( G_OBJECT( window ), "ret", &ret );
417 gtk_widget_realize( window );
421 auto vbox = ui::VBox( FALSE, 10 );
427 auto hbox = ui::HBox( FALSE, 10 );
428 vbox.pack_start( hbox, FALSE, FALSE, 2 );
434 auto vbox2 = ui::VBox( FALSE, 10 );
435 hbox.pack_start( vbox2, FALSE, FALSE, 2 );
440 auto hbox2 = ui::HBox( FALSE, 10 );
441 vbox2.pack_start( hbox2, FALSE, FALSE, 2 );
446 auto text1 = ui::Entry( 256 );
447 gtk_entry_set_text( text1, "3" );
448 hbox2.pack_start( text1, FALSE, FALSE, 2 );
451 auto l = ui::Label( "Number Of Sides" );
452 hbox2.pack_start( l, FALSE, FALSE, 2 );
453 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
458 hbox2 = ui::HBox( FALSE, 10 );
459 vbox2.pack_start( hbox2, FALSE, FALSE, 2 );
464 auto text2 = ui::Entry( 256 );
465 gtk_entry_set_text( text2, "8" );
466 hbox2.pack_start( text2, FALSE, FALSE, 2 );
469 l = ui::Label( "Border Width" );
470 hbox2.pack_start( l, FALSE, FALSE, 2 );
471 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
480 vbox2 = ui::VBox( FALSE, 10 );
481 hbox.pack_start( vbox2, FALSE, FALSE, 2 );
486 auto check1 = ui::CheckButton( "Use Border" );
487 vbox2.pack_start( check1, FALSE, FALSE, 0 );
491 auto check2 = ui::CheckButton( "Inverse Polygon" );
492 vbox2.pack_start( check2, FALSE, FALSE, 0 );
496 auto check3 = ui::CheckButton( "Align Top Edge" );
497 vbox2.pack_start( check3, FALSE, FALSE, 0 );
504 hbox = ui::HBox( FALSE, 10 );
505 vbox.pack_start( hbox, FALSE, FALSE, 2 );
510 auto w = ui::Button( "Ok" );
511 hbox.pack_start( w, TRUE, TRUE, 0 );
512 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
514 gtk_widget_set_can_default( w, true );
515 gtk_widget_grab_default( w );
518 w = ui::Button( "Cancel" );
519 hbox.pack_start( w, TRUE, TRUE, 0 );
520 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
528 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
530 gtk_grab_add( window );
532 bool dialogError = TRUE;
533 while ( dialogError )
537 gtk_main_iteration();
541 if ( ret == eIDOK ) {
542 rs->bUseBorder = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check1) ) ? true : false;
543 rs->bInverse = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
544 rs->bAlignTop = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check3) ) ? true : false;
546 if ( !ValidateTextIntRange( gtk_entry_get_text( text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
550 if ( rs->bUseBorder ) {
551 if ( !ValidateTextIntRange( gtk_entry_get_text( text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
558 gtk_grab_remove( window );
565 // for stair builder stuck as close as i could to the MFC version
566 // obviously feel free to change it at will :)
567 EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
568 GSList *radioDirection, *radioStyle;
569 EMessageBoxReturn ret;
572 const char *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
574 auto window = ui::Window( ui::window_type::TOP );
576 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
577 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
579 gtk_window_set_title( window, "Stair Builder" );
581 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
583 g_object_set_data( G_OBJECT( window ), "loop", &loop );
584 g_object_set_data( G_OBJECT( window ), "ret", &ret );
586 gtk_widget_realize( window );
589 auto vbox = ui::VBox( FALSE, 10 );
593 auto hbox = ui::HBox( FALSE, 10 );
597 // dunno if you want this text or not ...
598 ui::Widget w = ui::Label( text );
599 hbox.pack_start( w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
602 w = ui::Widget::from(gtk_hseparator_new());
603 vbox.pack_start( w, FALSE, FALSE, 0 );
606 // ------------------------- // indenting == good way of keeping track of lines :)
609 hbox = ui::HBox( FALSE, 10 );
610 vbox.pack_start( hbox, FALSE, FALSE, 0 );
613 auto textStairHeight = ui::Entry( 256 );
614 hbox.pack_start( textStairHeight, FALSE, FALSE, 1 );
615 textStairHeight.show();
617 w = ui::Label( "Stair Height" );
618 hbox.pack_start( w, FALSE, FALSE, 1 );
621 // ------------------------- //
623 hbox = ui::HBox( FALSE, 10 );
624 vbox.pack_start( hbox, FALSE, FALSE, 0 );
627 w = ui::Label( "Direction:" );
628 hbox.pack_start( w, FALSE, FALSE, 5 );
631 // -------------------------- //
633 hbox = ui::HBox( FALSE, 10 );
634 vbox.pack_start( hbox, FALSE, FALSE, 0 );
637 // radio buttons confuse me ...
638 // but this _looks_ right
640 // djbob: actually it looks very nice :), slightly better than the way i did it
641 // edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
643 auto radioNorth = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North" ));
644 hbox.pack_start( radioNorth, FALSE, FALSE, 3 );
647 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
649 auto radioSouth = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "South" ));
650 hbox.pack_start( radioSouth, FALSE, FALSE, 2 );
653 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
655 auto radioEast = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "East" ));
656 hbox.pack_start( radioEast, FALSE, FALSE, 1 );
659 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
661 auto radioWest = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "West" ));
662 hbox.pack_start( radioWest, FALSE, FALSE, 0 );
665 // --------------------------- //
667 hbox = ui::HBox( FALSE, 10 );
668 vbox.pack_start( hbox, FALSE, FALSE, 0 );
671 w = ui::Label( "Style:" );
672 hbox.pack_start( w, FALSE, FALSE, 5 );
675 // --------------------------- //
677 hbox = ui::HBox( FALSE, 10 );
678 vbox.pack_start( hbox, FALSE, FALSE, 0 );
681 auto radioOldStyle = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Original" ));
682 hbox.pack_start( radioOldStyle, FALSE, FALSE, 0 );
683 radioOldStyle.show();
685 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
687 auto radioBobStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ));
688 hbox.pack_start( radioBobStyle, FALSE, FALSE, 0 );
689 radioBobStyle.show();
691 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
693 auto radioCornerStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Corner Style" ));
694 hbox.pack_start( radioCornerStyle, FALSE, FALSE, 0 );
695 radioCornerStyle.show();
697 // err, the q3r has an if or something so you need bob style checked before this
698 // is "ungreyed out" but you'll need to do that, as i suck :)
700 // djbob: er.... yeah um, im not at all sure how i'm gonna sort this
701 // djbob: think we need some button callback functions or smuffin
702 // FIXME: actually get around to doing what i suggested!!!!
704 auto checkUseDetail = ui::CheckButton( "Use Detail Brushes" );
705 hbox.pack_start( checkUseDetail, FALSE, FALSE, 0 );
706 checkUseDetail.show();
708 // --------------------------- //
710 hbox = ui::HBox( FALSE, 10 );
711 vbox.pack_start( hbox, FALSE, FALSE, 0 );
714 auto textMainTex = ui::Entry( 512 );
715 gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture );
716 hbox.pack_start( textMainTex, FALSE, FALSE, 0 );
719 w = ui::Label( "Main Texture" );
720 hbox.pack_start( w, FALSE, FALSE, 1 );
723 // -------------------------- //
725 hbox = ui::HBox( FALSE, 10 );
726 vbox.pack_start( hbox, FALSE, FALSE, 0 );
729 auto textRiserTex = ui::Entry( 512 );
730 hbox.pack_start( textRiserTex, FALSE, FALSE, 0 );
733 w = ui::Label( "Riser Texture" );
734 hbox.pack_start( w, FALSE, FALSE, 1 );
737 // -------------------------- //
738 w = ui::Widget::from(gtk_hseparator_new());
739 vbox.pack_start( w, FALSE, FALSE, 0 );
742 hbox = ui::HBox( FALSE, 10 );
743 vbox.pack_start( hbox, FALSE, FALSE, 0 );
746 w = ui::Button( "OK" );
747 hbox.pack_start( w, TRUE, TRUE, 0 );
748 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
749 gtk_widget_set_can_default( w, true );
750 gtk_widget_grab_default( w );
753 w = ui::Button( "Cancel" );
754 hbox.pack_start( w, TRUE, TRUE, 0 );
755 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
760 // +djbob: need our "little" modal loop mars :P
761 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
763 gtk_grab_add( window );
765 bool dialogError = TRUE;
766 while ( dialogError )
770 gtk_main_iteration();
774 if ( ret == eIDOK ) {
775 rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(checkUseDetail) ) ? true : false;
777 strcpy( rs->riserTexture, gtk_entry_get_text( textRiserTex ) );
778 strcpy( rs->mainTexture, gtk_entry_get_text( textMainTex ) );
780 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioNorth) ) ) {
781 rs->direction = MOVE_NORTH;
783 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioSouth) ) ) {
784 rs->direction = MOVE_SOUTH;
786 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioEast) ) ) {
787 rs->direction = MOVE_EAST;
789 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioWest) ) ) {
790 rs->direction = MOVE_WEST;
793 if ( !ValidateTextInt( gtk_entry_get_text( textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
797 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioOldStyle) ) ) {
798 rs->style = STYLE_ORIGINAL;
800 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioBobStyle) ) ) {
801 rs->style = STYLE_BOB;
803 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioCornerStyle) ) ) {
804 rs->style = STYLE_CORNER;
809 gtk_grab_remove( window );
815 // there we go, all done ... on my end at least, not bad for a night's work
818 EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
819 GSList *radioOrientation;
821 EMessageBoxReturn ret;
824 auto window = ui::Window( ui::window_type::TOP );
826 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
827 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
829 gtk_window_set_title( window, "Door Builder" );
831 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
833 g_object_set_data( G_OBJECT( window ), "loop", &loop );
834 g_object_set_data( G_OBJECT( window ), "ret", &ret );
836 gtk_widget_realize( window );
839 auto listMainTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
840 auto listTrimTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
841 LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
842 LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
844 auto vbox = ui::VBox( FALSE, 10 );
848 // -------------------------- //
850 auto hbox = ui::HBox( FALSE, 10 );
851 vbox.pack_start( hbox, FALSE, FALSE, 0 );
854 auto textFrontBackTex = ui::Entry( 512 );
855 gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture );
856 hbox.pack_start( textFrontBackTex, FALSE, FALSE, 0 );
857 textFrontBackTex.show();
859 ui::Widget w = ui::Label( "Door Front/Back Texture" );
860 hbox.pack_start( w, FALSE, FALSE, 0 );
863 // ------------------------ //
865 hbox = ui::HBox( FALSE, 10 );
866 vbox.pack_start( hbox, FALSE, FALSE, 0 );
869 auto textTrimTex = ui::Entry( 512 );
870 hbox.pack_start( textTrimTex, FALSE, FALSE, 0 );
873 w = ui::Label( "Door Trim Texture" );
874 hbox.pack_start( w, FALSE, FALSE, 0 );
877 // ----------------------- //
879 hbox = ui::HBox( FALSE, 10 );
880 vbox.pack_start( hbox, FALSE, FALSE, 0 );
883 // sp: horizontally ????
884 // djbob: yes mars, u can spell :]
885 auto checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" );
886 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE );
887 hbox.pack_start( checkScaleMainH, FALSE, FALSE, 0 );
888 checkScaleMainH.show();
890 auto checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" );
891 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE );
892 hbox.pack_start( checkScaleTrimH, FALSE, FALSE, 0 );
893 checkScaleTrimH.show();
895 // ---------------------- //
897 hbox = ui::HBox( FALSE, 10 );
898 vbox.pack_start( hbox, FALSE, FALSE, 0 );
901 auto checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" );
902 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE );
903 hbox.pack_start( checkScaleMainV, FALSE, FALSE, 0 );
904 checkScaleMainV.show();
906 auto checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" );
907 hbox.pack_start( checkScaleTrimV, FALSE, FALSE, 0 );
908 checkScaleTrimV.show();
910 // --------------------- //
912 hbox = ui::HBox( FALSE, 10 );
913 vbox.pack_start( hbox, FALSE, FALSE, 0 );
916 // djbob: lists added
918 auto comboMain = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listMainTextures));
919 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
920 hbox.pack_start( comboMain, FALSE, FALSE, 0 );
923 tw1.one = textFrontBackTex;
926 auto buttonSetMain = ui::Button( "Set As Main Texture" );
927 buttonSetMain.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 );
928 hbox.pack_start( buttonSetMain, FALSE, FALSE, 0 );
929 buttonSetMain.show();
931 // ------------------- //
933 hbox = ui::HBox( FALSE, 10 );
934 vbox.pack_start( hbox, FALSE, FALSE, 0 );
937 auto comboTrim = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listTrimTextures));
938 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
939 hbox.pack_start( comboTrim, FALSE, FALSE, 0 );
942 tw2.one = textTrimTex;
945 auto buttonSetTrim = ui::Button( "Set As Trim Texture" );
946 buttonSetTrim.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 );
947 hbox.pack_start( buttonSetTrim, FALSE, FALSE, 0 );
948 buttonSetTrim.show();
950 // ------------------ //
952 hbox = ui::HBox( FALSE, 10 );
953 vbox.pack_start( hbox, FALSE, FALSE, 0 );
956 w = ui::Label( "Orientation" );
957 hbox.pack_start( w, FALSE, FALSE, 0 );
960 // argh more radio buttons!
961 auto radioNS = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North - South" ));
962 hbox.pack_start( radioNS, FALSE, FALSE, 0 );
965 radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
967 auto radioEW = ui::Widget::from(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
968 hbox.pack_start( radioEW, FALSE, FALSE, 0 );
971 // ----------------- //
973 w = ui::Widget::from(gtk_hseparator_new());
974 vbox.pack_start( w, FALSE, FALSE, 0 );
977 // ----------------- //
979 hbox = ui::HBox( FALSE, 10 );
980 vbox.pack_start( hbox, FALSE, FALSE, 0 );
983 w = ui::Button( "OK" );
984 hbox.pack_start( w, TRUE, TRUE, 0 );
985 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
986 gtk_widget_set_can_default( w, true );
987 gtk_widget_grab_default( w );
990 w = ui::Button( "Cancel" );
991 hbox.pack_start( w, TRUE, TRUE, 0 );
992 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
996 // ----------------- //
999 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1001 gtk_grab_add( window );
1004 gtk_main_iteration();
1006 strcpy( rs->mainTexture, gtk_entry_get_text( GTK_ENTRY( textFrontBackTex ) ) );
1007 strcpy( rs->trimTexture, gtk_entry_get_text( GTK_ENTRY( textTrimTex ) ) );
1009 rs->bScaleMainH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainH ) ) ? true : false;
1010 rs->bScaleMainV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainV ) ) ? true : false;
1011 rs->bScaleTrimH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ) ) ? true : false;
1012 rs->bScaleTrimV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimV ) ) ? true : false;
1014 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioNS ) ) ) {
1015 rs->nOrientation = DIRECTION_NS;
1017 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioEW ) ) ) {
1018 rs->nOrientation = DIRECTION_EW;
1021 gtk_grab_remove( window );
1028 EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
1029 ui::Widget w{ui::null};
1031 EMessageBoxReturn ret;
1034 auto window = ui::Window( ui::window_type::TOP );
1036 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1037 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1039 gtk_window_set_title( window, "Texture Reset" );
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 );
1049 auto vbox = ui::VBox( FALSE, 10 );
1055 auto hbox = ui::HBox( FALSE, 10 );
1056 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1061 auto text1 = ui::Entry( 256 );
1062 gtk_entry_set_text( text1, "25" );
1063 hbox.pack_start( text1, FALSE, FALSE, 2 );
1066 w = ui::Label( "Number Of Points" );
1067 hbox.pack_start( w, FALSE, FALSE, 2 );
1068 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1073 hbox = ui::HBox( FALSE, 10 );
1074 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1079 auto text2 = ui::Entry( 256 );
1080 gtk_entry_set_text( text2, "3" );
1081 hbox.pack_start( text2, FALSE, FALSE, 2 );
1084 w = ui::Label( "Multipler" );
1085 hbox.pack_start( w, FALSE, FALSE, 2 );
1086 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1091 w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" );
1092 vbox.pack_start( w, FALSE, FALSE, 0 );
1093 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1096 hbox = ui::HBox( FALSE, 10 );
1097 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1102 auto text3 = ui::Entry( 256 );
1103 gtk_entry_set_text( text3, "-800" );
1104 hbox.pack_start( text3, FALSE, FALSE, 2 );
1107 w = ui::Label( "Gravity" );
1108 hbox.pack_start( w, FALSE, FALSE, 2 );
1109 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1114 w = ui::Widget::from(gtk_hseparator_new());
1115 vbox.pack_start( w, FALSE, FALSE, 0 );
1118 auto check1 = ui::CheckButton( "No Dynamic Update" );
1119 vbox.pack_start( check1, FALSE, FALSE, 0 );
1122 auto check2 = ui::CheckButton( "Show Bounding Lines" );
1123 vbox.pack_start( check2, FALSE, FALSE, 0 );
1129 // ----------------- //
1131 w = ui::Widget::from(gtk_hseparator_new());
1132 vbox.pack_start( w, FALSE, FALSE, 0 );
1135 // ----------------- //
1137 hbox = ui::HBox( FALSE, 10 );
1138 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1141 w = ui::Button( "Enable" );
1142 hbox.pack_start( w, TRUE, TRUE, 0 );
1143 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1146 gtk_widget_set_can_default( w, true );
1147 gtk_widget_grab_default( w );
1149 w = ui::Button( "Disable" );
1150 hbox.pack_start( w, TRUE, TRUE, 0 );
1151 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
1154 w = ui::Button( "Cancel" );
1155 hbox.pack_start( w, TRUE, TRUE, 0 );
1156 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1161 // ----------------- //
1163 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1165 gtk_grab_add( window );
1167 bool dialogError = TRUE;
1168 while ( dialogError )
1172 gtk_main_iteration();
1174 dialogError = FALSE;
1176 if ( ret == eIDYES ) {
1177 if ( !ValidateTextIntRange( gtk_entry_get_text( GTK_ENTRY( text1 ) ), 1, 200, "Number Of Points", &rs->nPoints ) ) {
1181 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text2 ) ), 1.0f, 10.0f, "Multiplier", &rs->fMultiplier ) ) {
1185 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text3 ) ), -10000.0f, -1.0f, "Gravity", &rs->fGravity ) ) {
1189 rs->bNoUpdate = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check1 ) ) ? true : false;
1190 rs->bShowExtra = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check2 ) ) ? true : false;
1194 gtk_grab_remove( window );
1200 EMessageBoxReturn DoCTFColourChangeBox(){
1201 ui::Widget w{ui::null};
1202 EMessageBoxReturn ret;
1205 auto window = ui::Window( ui::window_type::TOP );
1207 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1208 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1210 gtk_window_set_title( window, "CTF Colour Changer" );
1211 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1213 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1214 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1216 gtk_widget_realize( window );
1220 auto vbox = ui::VBox( FALSE, 10 );
1226 auto hbox = ui::HBox( FALSE, 10 );
1227 vbox.pack_start( hbox, TRUE, TRUE, 0 );
1230 // ---- hbox ---- ok/cancel buttons
1232 w = ui::Button( "Red->Blue" );
1233 hbox.pack_start( w, TRUE, TRUE, 0 );
1234 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1236 gtk_widget_set_can_default( w, true );
1237 gtk_widget_grab_default( w );
1240 w = ui::Button( "Blue->Red" );
1241 hbox.pack_start( w, TRUE, TRUE, 0 );
1242 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1245 w = ui::Button( "Cancel" );
1246 hbox.pack_start( w, TRUE, TRUE, 0 );
1247 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1255 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1257 gtk_grab_add( window );
1260 gtk_main_iteration();
1262 gtk_grab_remove( window );
1268 EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
1271 ui::Widget w{ui::null};
1273 EMessageBoxReturn ret;
1276 auto window = ui::Window( ui::window_type::TOP );
1278 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1279 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1281 gtk_window_set_title( window, "Texture Reset" );
1282 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1284 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1285 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1287 gtk_widget_realize( window );
1289 auto vbox = ui::VBox( FALSE, 10 );
1295 auto hbox = ui::HBox( FALSE, 10 );
1296 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1301 texSelected = "Currently Selected Texture: ";
1302 texSelected += GetCurrentTexture();
1304 w = ui::Label( texSelected );
1305 hbox.pack_start( w, FALSE, FALSE, 2 );
1306 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1311 auto frame = ui::Frame( "Reset Texture Names" );
1313 vbox.pack_start( frame, FALSE, TRUE, 0 );
1315 auto table = ui::Table( 2, 3, TRUE );
1318 gtk_table_set_row_spacings(table, 5);
1319 gtk_table_set_col_spacings(table, 5);
1320 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1324 dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
1325 dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1326 dlgTexReset.cbTexChange.show();
1327 table.attach(dlgTexReset.cbTexChange, {0, 1, 0, 1}, {GTK_FILL, 0});
1329 w = ui::Label( "Old Name: " );
1330 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1333 dlgTexReset.editTexOld = ui::Entry( 256 );
1334 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
1335 table.attach(dlgTexReset.editTexOld, {2, 3, 0, 1}, {GTK_FILL, 0});
1336 dlgTexReset.editTexOld.show();
1338 w = ui::Label( "New Name: " );
1339 table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
1342 dlgTexReset.editTexNew = ui::Entry( 256 );
1343 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
1344 table.attach(dlgTexReset.editTexNew, {2, 3, 1, 2}, {GTK_FILL, 0});
1345 dlgTexReset.editTexNew.show();
1349 frame = ui::Frame( "Reset Scales" );
1351 vbox.pack_start( frame, FALSE, TRUE, 0 );
1353 table = ui::Table( 2, 3, TRUE );
1356 gtk_table_set_row_spacings(table, 5);
1357 gtk_table_set_col_spacings(table, 5);
1358 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1362 dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
1363 dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1364 dlgTexReset.cbScaleHor.show();
1365 table.attach(dlgTexReset.cbScaleHor, {0, 1, 0, 1}, {GTK_FILL, 0});
1367 w = ui::Label( "New Horizontal Scale: " );
1368 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1371 dlgTexReset.editScaleHor = ui::Entry( 256 );
1372 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
1373 table.attach(dlgTexReset.editScaleHor, {2, 3, 0, 1}, {GTK_FILL, 0});
1374 dlgTexReset.editScaleHor.show();
1377 dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
1378 dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1379 dlgTexReset.cbScaleVert.show();
1380 table.attach(dlgTexReset.cbScaleVert, {0, 1, 1, 2}, {GTK_FILL, 0});
1382 w = ui::Label( "New Vertical Scale: " );
1383 table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
1386 dlgTexReset.editScaleVert = ui::Entry( 256 );
1387 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
1388 table.attach(dlgTexReset.editScaleVert, {2, 3, 1, 2}, {GTK_FILL, 0});
1389 dlgTexReset.editScaleVert.show();
1393 frame = ui::Frame( "Reset Shift" );
1395 vbox.pack_start( frame, FALSE, TRUE, 0 );
1397 table = ui::Table( 2, 3, TRUE );
1400 gtk_table_set_row_spacings(table, 5);
1401 gtk_table_set_col_spacings(table, 5);
1402 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1406 dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
1407 dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1408 dlgTexReset.cbShiftHor.show();
1409 table.attach(dlgTexReset.cbShiftHor, {0, 1, 0, 1}, {GTK_FILL, 0});
1411 w = ui::Label( "New Horizontal Shift: " );
1412 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1415 dlgTexReset.editShiftHor = ui::Entry( 256 );
1416 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
1417 table.attach(dlgTexReset.editShiftHor, {2, 3, 0, 1}, {GTK_FILL, 0});
1418 dlgTexReset.editShiftHor.show();
1421 dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
1422 dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1423 dlgTexReset.cbShiftVert.show();
1424 table.attach(dlgTexReset.cbShiftVert, {0, 1, 1, 2}, {GTK_FILL, 0});
1426 w = ui::Label( "New Vertical Shift: " );
1427 table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
1430 dlgTexReset.editShiftVert = ui::Entry( 256 );
1431 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
1432 table.attach(dlgTexReset.editShiftVert, {2, 3, 1, 2}, {GTK_FILL, 0});
1433 dlgTexReset.editShiftVert.show();
1437 frame = ui::Frame( "Reset Rotation" );
1439 vbox.pack_start( frame, FALSE, TRUE, 0 );
1441 table = ui::Table( 1, 3, TRUE );
1444 gtk_table_set_row_spacings(table, 5);
1445 gtk_table_set_col_spacings(table, 5);
1446 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1450 dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
1451 dlgTexReset.cbRotation.show();
1452 table.attach(dlgTexReset.cbRotation, {0, 1, 0, 1}, {GTK_FILL, 0});
1454 w = ui::Label( "New Rotation Value: " );
1455 table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
1458 dlgTexReset.editRotation = ui::Entry( 256 );
1459 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
1460 table.attach(dlgTexReset.editRotation, {2, 3, 0, 1}, {GTK_FILL, 0});
1461 dlgTexReset.editRotation.show();
1465 hbox = ui::HBox( FALSE, 10 );
1466 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1471 w = ui::Button( "Use Selected Brushes" );
1472 hbox.pack_start( w, TRUE, TRUE, 0 );
1473 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1475 gtk_widget_set_can_default( w, true );
1476 gtk_widget_grab_default( w );
1479 w = ui::Button( "Use All Brushes" );
1480 hbox.pack_start( w, TRUE, TRUE, 0 );
1481 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1484 w = ui::Button( "Cancel" );
1485 hbox.pack_start( w, TRUE, TRUE, 0 );
1486 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1494 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1496 gtk_grab_add( window );
1498 Update_TextureReseter();
1500 bool dialogError = TRUE;
1501 while ( dialogError )
1505 gtk_main_iteration();
1507 dialogError = FALSE;
1509 if ( ret != eIDCANCEL ) {
1510 rs->bResetRotation = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
1511 if ( rs->bResetRotation ) {
1512 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editRotation ) ), "Rotation", &rs->rotation ) ) {
1517 rs->bResetScale[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
1518 if ( rs->bResetScale[0] ) {
1519 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleHor ) ), "Horizontal Scale", &rs->fScale[0] ) ) {
1524 rs->bResetScale[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
1525 if ( rs->bResetScale[1] ) {
1526 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleVert ) ), "Vertical Scale", &rs->fScale[1] ) ) {
1531 rs->bResetShift[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
1532 if ( rs->bResetShift[0] ) {
1533 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftHor ) ), "Horizontal Shift", &rs->fShift[0] ) ) {
1538 rs->bResetShift[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
1539 if ( rs->bResetShift[1] ) {
1540 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftVert ) ), "Vertical Shift", &rs->fShift[1] ) ) {
1545 rs->bResetTextureName = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
1546 if ( rs->bResetTextureName ) {
1547 strcpy( rs->textureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexOld ) ) );
1548 strcpy( rs->newTextureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexNew ) ) );
1553 gtk_grab_remove( window );
1559 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
1562 ui::Widget w{ui::null};
1564 ui::Widget radiusX{ui::null}, radiusY{ui::null};
1565 ui::Widget angleStart{ui::null}, angleEnd{ui::null};
1566 ui::Widget heightStart{ui::null}, heightEnd{ui::null};
1567 ui::Widget numPoints{ui::null};
1569 EMessageBoxReturn ret;
1572 auto window = ui::Window( ui::window_type::TOP );
1574 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1575 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1577 gtk_window_set_title( window, "Train Thing" );
1578 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1580 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1581 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1583 gtk_widget_realize( window );
1585 auto vbox = ui::VBox( FALSE, 10 );
1591 auto hbox = ui::HBox( FALSE, 10 );
1592 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1597 auto frame = ui::Frame( "Radii" );
1599 vbox.pack_start( frame, FALSE, TRUE, 0 );
1601 auto table = ui::Table( 2, 3, TRUE );
1604 gtk_table_set_row_spacings(table, 5);
1605 gtk_table_set_col_spacings(table, 5);
1606 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1610 w = ui::Label( "X: " );
1611 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1614 radiusX = ui::Entry( 256 );
1615 gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
1616 table.attach(radiusX, {1, 2, 0, 1}, {GTK_FILL, 0});
1621 w = ui::Label( "Y: " );
1622 table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
1625 radiusY = ui::Entry( 256 );
1626 gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
1627 table.attach(radiusY, {1, 2, 1, 2}, {GTK_FILL, 0});
1632 frame = ui::Frame( "Angles" );
1634 vbox.pack_start( frame, FALSE, TRUE, 0 );
1636 table = ui::Table( 2, 3, TRUE );
1639 gtk_table_set_row_spacings((table), 5);
1640 gtk_table_set_col_spacings((table), 5);
1641 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1645 w = ui::Label( "Start: " );
1646 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1649 angleStart = ui::Entry( 256 );
1650 gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
1651 table.attach(angleStart, {1, 2, 0, 1}, {GTK_FILL, 0});
1656 w = ui::Label( "End: " );
1657 table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
1660 angleEnd = ui::Entry( 256 );
1661 gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
1662 table.attach(angleEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
1666 frame = ui::Frame( "Height" );
1668 vbox.pack_start( frame, FALSE, TRUE, 0 );
1670 table = ui::Table( 2, 3, TRUE );
1673 gtk_table_set_row_spacings(table, 5);
1674 gtk_table_set_col_spacings(table, 5);
1675 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1679 w = ui::Label( "Start: " );
1680 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1683 heightStart = ui::Entry( 256 );
1684 gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
1685 table.attach(heightStart, {1, 2, 0, 1}, {GTK_FILL, 0});
1690 w = ui::Label( "End: " );
1691 table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
1694 heightEnd = ui::Entry( 256 );
1695 gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
1696 table.attach(heightEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
1701 frame = ui::Frame( "Points" );
1703 vbox.pack_start( frame, FALSE, TRUE, 0 );
1705 table = ui::Table( 2, 3, TRUE );
1708 gtk_table_set_row_spacings(table, 5);
1709 gtk_table_set_col_spacings(table, 5);
1710 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1714 w = ui::Label( "Number: " );
1715 table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
1718 numPoints = ui::Entry( 256 );
1719 gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
1720 table.attach(numPoints, {1, 2, 0, 1}, {GTK_FILL, 0});
1724 hbox = ui::HBox( FALSE, 10 );
1725 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1730 w = ui::Button( "Ok" );
1731 hbox.pack_start( w, TRUE, TRUE, 0 );
1732 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1734 gtk_widget_set_can_default( w, true );
1735 gtk_widget_grab_default( w );
1738 w = ui::Button( "Cancel" );
1739 hbox.pack_start( w, TRUE, TRUE, 0 );
1740 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1748 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1750 gtk_grab_add( window );
1752 bool dialogError = TRUE;
1753 while ( dialogError )
1757 gtk_main_iteration();
1759 dialogError = FALSE;
1761 if ( ret != eIDCANCEL ) {
1762 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusX ) ), "Radius (X)", &rs->fRadiusX ) ) {
1766 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusY ) ), "Radius (Y)", &rs->fRadiusY ) ) {
1770 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleStart ) ), "Angle (Start)", &rs->fStartAngle ) ) {
1774 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleEnd ) ), "Angle (End)", &rs->fEndAngle ) ) {
1778 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightStart ) ), "Height (Start)", &rs->fStartHeight ) ) {
1782 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightEnd ) ), "Height (End)", &rs->fEndHeight ) ) {
1786 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( numPoints ) ), "Num Points", &rs->iNumPoints ) ) {
1792 gtk_grab_remove( window );
1798 // add a simple input for the MakeChain thing..
1799 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
1800 ui::Widget w{ui::null};
1801 ui::Entry textlinkNum{ui::null}, textlinkName{ui::null};
1802 EMessageBoxReturn ret;
1805 const char *text = "Please set a value in the boxes below and press 'OK' to make a chain";
1807 auto window = ui::Window( ui::window_type::TOP );
1809 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1810 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1812 gtk_window_set_title( window, "Make Chain" );
1814 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1816 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1817 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1819 gtk_widget_realize( window );
1822 auto vbox = ui::VBox( FALSE, 10 );
1826 auto hbox = ui::HBox( FALSE, 10 );
1830 // dunno if you want this text or not ...
1831 w = ui::Label( text );
1832 hbox.pack_start( w, FALSE, FALSE, 0 );
1835 w = ui::Widget::from(gtk_hseparator_new());
1836 vbox.pack_start( w, FALSE, FALSE, 0 );
1839 // ------------------------- //
1842 hbox = ui::HBox( FALSE, 10 );
1843 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1846 textlinkNum = ui::Entry( 256 );
1847 hbox.pack_start( textlinkNum, FALSE, FALSE, 1 );
1850 w = ui::Label( "Number of elements in chain" );
1851 hbox.pack_start( w, FALSE, FALSE, 1 );
1854 // -------------------------- //
1856 hbox = ui::HBox( FALSE, 10 );
1857 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1860 textlinkName = ui::Entry( 256 );
1861 hbox.pack_start( textlinkName, FALSE, FALSE, 0 );
1862 textlinkName.show();
1864 w = ui::Label( "Basename for chain's targetnames." );
1865 hbox.pack_start( w, FALSE, FALSE, 1 );
1869 w = ui::Button( "OK" );
1870 hbox.pack_start( w, TRUE, TRUE, 0 );
1871 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1872 gtk_widget_set_can_default( w, true );
1873 gtk_widget_grab_default( w );
1876 w = ui::Button( "Cancel" );
1877 hbox.pack_start( w, TRUE, TRUE, 0 );
1878 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1883 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1885 gtk_grab_add( window );
1887 bool dialogError = TRUE;
1888 while ( dialogError )
1892 gtk_main_iteration();
1894 dialogError = FALSE;
1896 if ( ret == eIDOK ) {
1897 strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) );
1898 if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) {
1904 gtk_grab_remove( window );