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( GtkWidget *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( GtkWidget *widget, gpointer data ){
101 TwinWidget* tw = (TwinWidget*)data;
103 GtkEntry* entry = GTK_ENTRY( tw->one );
104 auto* combo = GTK_BIN(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(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(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
336 vbox.pack_start( radio1, FALSE, FALSE, 2 );
339 auto radio2 = ui::Widget(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(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( (GtkEntry*)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( (GtkEntry*)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( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
550 if ( rs->bUseBorder ) {
551 if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)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(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(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(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(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(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(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(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(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(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( (GtkEntry*)textRiserTex ) );
778 strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)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( (GtkEntry*)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 ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
840 ui::ListStore listTrimTextures = ui::ListStore(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(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(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(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(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(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(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
968 hbox.pack_start( radioEW, FALSE, FALSE, 0 );
971 // ----------------- //
973 w = ui::Widget(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(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(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( GTK_TABLE( table ), 5 );
1319 gtk_table_set_col_spacings( GTK_TABLE( 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 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1,
1328 (GtkAttachOptions) ( GTK_FILL ),
1329 (GtkAttachOptions) ( 0 ), 0, 0 );
1331 w = ui::Label( "Old Name: " );
1332 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1333 (GtkAttachOptions) ( GTK_FILL ),
1334 (GtkAttachOptions) ( 0 ), 0, 0 );
1337 dlgTexReset.editTexOld = ui::Entry( 256 );
1338 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
1339 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1,
1340 (GtkAttachOptions) ( GTK_FILL ),
1341 (GtkAttachOptions) ( 0 ), 0, 0 );
1342 dlgTexReset.editTexOld.show();
1344 w = ui::Label( "New Name: " );
1345 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1346 (GtkAttachOptions) ( GTK_FILL ),
1347 (GtkAttachOptions) ( 0 ), 0, 0 );
1350 dlgTexReset.editTexNew = ui::Entry( 256 );
1351 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
1352 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2,
1353 (GtkAttachOptions) ( GTK_FILL ),
1354 (GtkAttachOptions) ( 0 ), 0, 0 );
1355 dlgTexReset.editTexNew.show();
1359 frame = ui::Frame( "Reset Scales" );
1361 vbox.pack_start( frame, FALSE, TRUE, 0 );
1363 table = ui::Table( 2, 3, TRUE );
1366 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1367 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1368 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1372 dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
1373 dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1374 dlgTexReset.cbScaleHor.show();
1375 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1,
1376 (GtkAttachOptions) ( GTK_FILL ),
1377 (GtkAttachOptions) ( 0 ), 0, 0 );
1379 w = ui::Label( "New Horizontal Scale: " );
1380 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1381 (GtkAttachOptions) ( GTK_FILL ),
1382 (GtkAttachOptions) ( 0 ), 0, 0 );
1385 dlgTexReset.editScaleHor = ui::Entry( 256 );
1386 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
1387 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1,
1388 (GtkAttachOptions) ( GTK_FILL ),
1389 (GtkAttachOptions) ( 0 ), 0, 0 );
1390 dlgTexReset.editScaleHor.show();
1393 dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
1394 dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1395 dlgTexReset.cbScaleVert.show();
1396 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2,
1397 (GtkAttachOptions) ( GTK_FILL ),
1398 (GtkAttachOptions) ( 0 ), 0, 0 );
1400 w = ui::Label( "New Vertical Scale: " );
1401 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1402 (GtkAttachOptions) ( GTK_FILL ),
1403 (GtkAttachOptions) ( 0 ), 0, 0 );
1406 dlgTexReset.editScaleVert = ui::Entry( 256 );
1407 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
1408 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2,
1409 (GtkAttachOptions) ( GTK_FILL ),
1410 (GtkAttachOptions) ( 0 ), 0, 0 );
1411 dlgTexReset.editScaleVert.show();
1415 frame = ui::Frame( "Reset Shift" );
1417 vbox.pack_start( frame, FALSE, TRUE, 0 );
1419 table = ui::Table( 2, 3, TRUE );
1422 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1423 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1424 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1428 dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
1429 dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1430 dlgTexReset.cbShiftHor.show();
1431 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1,
1432 (GtkAttachOptions) ( GTK_FILL ),
1433 (GtkAttachOptions) ( 0 ), 0, 0 );
1435 w = ui::Label( "New Horizontal Shift: " );
1436 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1437 (GtkAttachOptions) ( GTK_FILL ),
1438 (GtkAttachOptions) ( 0 ), 0, 0 );
1441 dlgTexReset.editShiftHor = ui::Entry( 256 );
1442 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
1443 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1,
1444 (GtkAttachOptions) ( GTK_FILL ),
1445 (GtkAttachOptions) ( 0 ), 0, 0 );
1446 dlgTexReset.editShiftHor.show();
1449 dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
1450 dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1451 dlgTexReset.cbShiftVert.show();
1452 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2,
1453 (GtkAttachOptions) ( GTK_FILL ),
1454 (GtkAttachOptions) ( 0 ), 0, 0 );
1456 w = ui::Label( "New Vertical Shift: " );
1457 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1458 (GtkAttachOptions) ( GTK_FILL ),
1459 (GtkAttachOptions) ( 0 ), 0, 0 );
1462 dlgTexReset.editShiftVert = ui::Entry( 256 );
1463 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
1464 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2,
1465 (GtkAttachOptions) ( GTK_FILL ),
1466 (GtkAttachOptions) ( 0 ), 0, 0 );
1467 dlgTexReset.editShiftVert.show();
1471 frame = ui::Frame( "Reset Rotation" );
1473 vbox.pack_start( frame, FALSE, TRUE, 0 );
1475 table = ui::Table( 1, 3, TRUE );
1478 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1479 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1480 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1484 dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
1485 dlgTexReset.cbRotation.show();
1486 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1,
1487 (GtkAttachOptions) ( GTK_FILL ),
1488 (GtkAttachOptions) ( 0 ), 0, 0 );
1490 w = ui::Label( "New Rotation Value: " );
1491 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1492 (GtkAttachOptions) ( GTK_FILL ),
1493 (GtkAttachOptions) ( 0 ), 0, 0 );
1496 dlgTexReset.editRotation = ui::Entry( 256 );
1497 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
1498 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1,
1499 (GtkAttachOptions) ( GTK_FILL ),
1500 (GtkAttachOptions) ( 0 ), 0, 0 );
1501 dlgTexReset.editRotation.show();
1505 hbox = ui::HBox( FALSE, 10 );
1506 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1511 w = ui::Button( "Use Selected Brushes" );
1512 hbox.pack_start( w, TRUE, TRUE, 0 );
1513 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1515 gtk_widget_set_can_default( w, true );
1516 gtk_widget_grab_default( w );
1519 w = ui::Button( "Use All Brushes" );
1520 hbox.pack_start( w, TRUE, TRUE, 0 );
1521 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1524 w = ui::Button( "Cancel" );
1525 hbox.pack_start( w, TRUE, TRUE, 0 );
1526 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1534 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1536 gtk_grab_add( window );
1538 Update_TextureReseter();
1540 bool dialogError = TRUE;
1541 while ( dialogError )
1545 gtk_main_iteration();
1547 dialogError = FALSE;
1549 if ( ret != eIDCANCEL ) {
1550 rs->bResetRotation = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
1551 if ( rs->bResetRotation ) {
1552 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editRotation ) ), "Rotation", &rs->rotation ) ) {
1557 rs->bResetScale[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
1558 if ( rs->bResetScale[0] ) {
1559 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleHor ) ), "Horizontal Scale", &rs->fScale[0] ) ) {
1564 rs->bResetScale[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
1565 if ( rs->bResetScale[1] ) {
1566 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleVert ) ), "Vertical Scale", &rs->fScale[1] ) ) {
1571 rs->bResetShift[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
1572 if ( rs->bResetShift[0] ) {
1573 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftHor ) ), "Horizontal Shift", &rs->fShift[0] ) ) {
1578 rs->bResetShift[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
1579 if ( rs->bResetShift[1] ) {
1580 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftVert ) ), "Vertical Shift", &rs->fShift[1] ) ) {
1585 rs->bResetTextureName = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
1586 if ( rs->bResetTextureName ) {
1587 strcpy( rs->textureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexOld ) ) );
1588 strcpy( rs->newTextureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexNew ) ) );
1593 gtk_grab_remove( window );
1599 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
1602 ui::Widget w{ui::null};
1604 ui::Widget radiusX{ui::null}, radiusY{ui::null};
1605 ui::Widget angleStart{ui::null}, angleEnd{ui::null};
1606 ui::Widget heightStart{ui::null}, heightEnd{ui::null};
1607 ui::Widget numPoints{ui::null};
1609 EMessageBoxReturn ret;
1612 auto window = ui::Window( ui::window_type::TOP );
1614 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1615 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1617 gtk_window_set_title( window, "Train Thing" );
1618 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1620 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1621 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1623 gtk_widget_realize( window );
1625 auto vbox = ui::VBox( FALSE, 10 );
1631 auto hbox = ui::HBox( FALSE, 10 );
1632 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1637 auto frame = ui::Frame( "Radii" );
1639 vbox.pack_start( frame, FALSE, TRUE, 0 );
1641 auto table = ui::Table( 2, 3, TRUE );
1644 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1645 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1646 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1650 w = ui::Label( "X: " );
1651 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1652 (GtkAttachOptions) ( GTK_FILL ),
1653 (GtkAttachOptions) ( 0 ), 0, 0 );
1656 radiusX = ui::Entry( 256 );
1657 gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
1658 gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1,
1659 (GtkAttachOptions) ( GTK_FILL ),
1660 (GtkAttachOptions) ( 0 ), 0, 0 );
1665 w = ui::Label( "Y: " );
1666 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1667 (GtkAttachOptions) ( GTK_FILL ),
1668 (GtkAttachOptions) ( 0 ), 0, 0 );
1671 radiusY = ui::Entry( 256 );
1672 gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
1673 gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2,
1674 (GtkAttachOptions) ( GTK_FILL ),
1675 (GtkAttachOptions) ( 0 ), 0, 0 );
1680 frame = ui::Frame( "Angles" );
1682 vbox.pack_start( frame, FALSE, TRUE, 0 );
1684 table = ui::Table( 2, 3, TRUE );
1687 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1688 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1689 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1693 w = ui::Label( "Start: " );
1694 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1695 (GtkAttachOptions) ( GTK_FILL ),
1696 (GtkAttachOptions) ( 0 ), 0, 0 );
1699 angleStart = ui::Entry( 256 );
1700 gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
1701 gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1,
1702 (GtkAttachOptions) ( GTK_FILL ),
1703 (GtkAttachOptions) ( 0 ), 0, 0 );
1708 w = ui::Label( "End: " );
1709 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1710 (GtkAttachOptions) ( GTK_FILL ),
1711 (GtkAttachOptions) ( 0 ), 0, 0 );
1714 angleEnd = ui::Entry( 256 );
1715 gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
1716 gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2,
1717 (GtkAttachOptions) ( GTK_FILL ),
1718 (GtkAttachOptions) ( 0 ), 0, 0 );
1722 frame = ui::Frame( "Height" );
1724 vbox.pack_start( frame, FALSE, TRUE, 0 );
1726 table = ui::Table( 2, 3, TRUE );
1729 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1730 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1731 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1735 w = ui::Label( "Start: " );
1736 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1737 (GtkAttachOptions) ( GTK_FILL ),
1738 (GtkAttachOptions) ( 0 ), 0, 0 );
1741 heightStart = ui::Entry( 256 );
1742 gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
1743 gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1,
1744 (GtkAttachOptions) ( GTK_FILL ),
1745 (GtkAttachOptions) ( 0 ), 0, 0 );
1750 w = ui::Label( "End: " );
1751 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1752 (GtkAttachOptions) ( GTK_FILL ),
1753 (GtkAttachOptions) ( 0 ), 0, 0 );
1756 heightEnd = ui::Entry( 256 );
1757 gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
1758 gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2,
1759 (GtkAttachOptions) ( GTK_FILL ),
1760 (GtkAttachOptions) ( 0 ), 0, 0 );
1765 frame = ui::Frame( "Points" );
1767 vbox.pack_start( frame, FALSE, TRUE, 0 );
1769 table = ui::Table( 2, 3, TRUE );
1772 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1773 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1774 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1778 w = ui::Label( "Number: " );
1779 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1780 (GtkAttachOptions) ( GTK_FILL ),
1781 (GtkAttachOptions) ( 0 ), 0, 0 );
1784 numPoints = ui::Entry( 256 );
1785 gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
1786 gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1,
1787 (GtkAttachOptions) ( GTK_FILL ),
1788 (GtkAttachOptions) ( 0 ), 0, 0 );
1792 hbox = ui::HBox( FALSE, 10 );
1793 vbox.pack_start( hbox, FALSE, FALSE, 2 );
1798 w = ui::Button( "Ok" );
1799 hbox.pack_start( w, TRUE, TRUE, 0 );
1800 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1802 gtk_widget_set_can_default( w, true );
1803 gtk_widget_grab_default( w );
1806 w = ui::Button( "Cancel" );
1807 hbox.pack_start( w, TRUE, TRUE, 0 );
1808 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1816 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1818 gtk_grab_add( window );
1820 bool dialogError = TRUE;
1821 while ( dialogError )
1825 gtk_main_iteration();
1827 dialogError = FALSE;
1829 if ( ret != eIDCANCEL ) {
1830 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusX ) ), "Radius (X)", &rs->fRadiusX ) ) {
1834 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusY ) ), "Radius (Y)", &rs->fRadiusY ) ) {
1838 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleStart ) ), "Angle (Start)", &rs->fStartAngle ) ) {
1842 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleEnd ) ), "Angle (End)", &rs->fEndAngle ) ) {
1846 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightStart ) ), "Height (Start)", &rs->fStartHeight ) ) {
1850 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightEnd ) ), "Height (End)", &rs->fEndHeight ) ) {
1854 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( numPoints ) ), "Num Points", &rs->iNumPoints ) ) {
1860 gtk_grab_remove( window );
1866 // add a simple input for the MakeChain thing..
1867 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
1868 ui::Widget w{ui::null};
1869 ui::Entry textlinkNum{ui::null}, textlinkName{ui::null};
1870 EMessageBoxReturn ret;
1873 const char *text = "Please set a value in the boxes below and press 'OK' to make a chain";
1875 auto window = ui::Window( ui::window_type::TOP );
1877 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1878 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1880 gtk_window_set_title( window, "Make Chain" );
1882 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1884 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1885 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1887 gtk_widget_realize( window );
1890 auto vbox = ui::VBox( FALSE, 10 );
1894 auto hbox = ui::HBox( FALSE, 10 );
1898 // dunno if you want this text or not ...
1899 w = ui::Label( text );
1900 hbox.pack_start( w, FALSE, FALSE, 0 );
1903 w = ui::Widget(gtk_hseparator_new());
1904 vbox.pack_start( w, FALSE, FALSE, 0 );
1907 // ------------------------- //
1910 hbox = ui::HBox( FALSE, 10 );
1911 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1914 textlinkNum = ui::Entry( 256 );
1915 hbox.pack_start( textlinkNum, FALSE, FALSE, 1 );
1918 w = ui::Label( "Number of elements in chain" );
1919 hbox.pack_start( w, FALSE, FALSE, 1 );
1922 // -------------------------- //
1924 hbox = ui::HBox( FALSE, 10 );
1925 vbox.pack_start( hbox, FALSE, FALSE, 0 );
1928 textlinkName = ui::Entry( 256 );
1929 hbox.pack_start( textlinkName, FALSE, FALSE, 0 );
1930 textlinkName.show();
1932 w = ui::Label( "Basename for chain's targetnames." );
1933 hbox.pack_start( w, FALSE, FALSE, 1 );
1937 w = ui::Button( "OK" );
1938 hbox.pack_start( w, TRUE, TRUE, 0 );
1939 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1940 gtk_widget_set_can_default( w, true );
1941 gtk_widget_grab_default( w );
1944 w = ui::Button( "Cancel" );
1945 hbox.pack_start( w, TRUE, TRUE, 0 );
1946 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1951 gtk_window_set_position( window, GTK_WIN_POS_CENTER );
1953 gtk_grab_add( window );
1955 bool dialogError = TRUE;
1956 while ( dialogError )
1960 gtk_main_iteration();
1962 dialogError = FALSE;
1964 if ( ret == eIDOK ) {
1965 strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) );
1966 if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) {
1972 gtk_grab_remove( window );