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( GtkWidget *widget, gpointer data ){
84 EMessageBoxReturn *ret;
86 parent = gtk_widget_get_toplevel( widget );
87 loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
88 ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" );
91 *ret = (EMessageBoxReturn)gpointer_to_int( data );
94 static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
97 gtk_widget_hide( widget );
98 loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
104 static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){
105 TwinWidget* tw = (TwinWidget*)data;
107 GtkEntry* entry = GTK_ENTRY( tw->one );
108 auto* combo = GTK_BIN(tw->two);
110 const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
111 gtk_entry_set_text( entry, tex );
114 /*--------------------------------
115 Data validation Routines
116 ---------------------------------*/
118 bool ValidateTextFloat( const char* pData, const char* error_title, float* value ){
120 float testNum = (float)atof( pData );
122 if ( ( testNum == 0.0f ) && strcmp( pData, "0" ) ) {
123 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
133 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
137 bool ValidateTextFloatRange( const char* pData, float min, float max, const char* error_title, float* value ){
138 char error_buffer[256];
139 sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max );
142 float testNum = (float)atof( pData );
144 if ( ( testNum < min ) || ( testNum > max ) ) {
145 DoMessageBox( error_buffer, error_title, eMB_OK );
155 DoMessageBox( error_buffer, error_title, eMB_OK );
159 bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){
160 char error_buffer[256];
161 sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max );
164 int testNum = atoi( pData );
166 if ( ( testNum < min ) || ( testNum > max ) ) {
167 DoMessageBox( error_buffer, error_title, eMB_OK );
177 DoMessageBox( error_buffer, error_title, eMB_OK );
181 bool ValidateTextInt( const char* pData, const char* error_title, int* value ){
183 int testNum = atoi( pData );
185 if ( ( testNum == 0 ) && strcmp( pData, "0" ) ) {
186 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
196 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
200 /*--------------------------------
202 ---------------------------------*/
206 Major clean up of variable names etc required, excluding Mars's ones,
207 which are nicely done :)
211 EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){
212 ui::Widget w{ui::null};
213 EMessageBoxReturn ret;
216 auto window = ui::Window( ui::window_type::TOP );
217 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
218 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
219 gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
220 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
221 g_object_set_data( G_OBJECT( window ), "loop", &loop );
222 g_object_set_data( G_OBJECT( window ), "ret", &ret );
223 gtk_widget_realize( window );
225 auto vbox = ui::VBox( FALSE, 10 );
227 gtk_widget_show( vbox );
229 w = ui::Label( lpText );
230 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
231 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
232 gtk_widget_show( w );
234 w = ui::Widget(gtk_hseparator_new());
235 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
236 gtk_widget_show( w );
238 auto hbox = ui::HBox( FALSE, 10 );
239 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
240 gtk_widget_show( hbox );
242 if ( type == eMB_OK ) {
243 w = ui::Button( "Ok" );
244 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
245 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
246 gtk_widget_set_can_default(w, true);
247 gtk_widget_grab_default( w );
248 gtk_widget_show( w );
251 else if ( type == eMB_OKCANCEL ) {
252 w = ui::Button( "Ok" );
253 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
254 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
255 gtk_widget_set_can_default( w, true );
256 gtk_widget_grab_default( w );
257 gtk_widget_show( w );
259 w = ui::Button( "Cancel" );
260 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
261 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
262 gtk_widget_show( w );
265 else if ( type == eMB_YESNOCANCEL ) {
266 w = ui::Button( "Yes" );
267 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
268 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
269 gtk_widget_set_can_default( w, true );
270 gtk_widget_grab_default( w );
271 gtk_widget_show( w );
273 w = ui::Button( "No" );
274 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
275 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
276 gtk_widget_show( w );
278 w = ui::Button( "Cancel" );
279 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
280 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
281 gtk_widget_show( w );
284 else /* if (mode == MB_YESNO) */
286 w = ui::Button( "Yes" );
287 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
288 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
289 gtk_widget_set_can_default( w, true );
290 gtk_widget_grab_default( w );
291 gtk_widget_show( w );
293 w = ui::Button( "No" );
294 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
295 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
296 gtk_widget_show( w );
300 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
301 gtk_widget_show( window );
302 gtk_grab_add( window );
305 gtk_main_iteration();
307 gtk_grab_remove( window );
308 gtk_widget_destroy( window );
313 EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
315 GtkWidget *check1, *check2;
316 EMessageBoxReturn ret;
319 auto window = ui::Window( ui::window_type::TOP );
321 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
322 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
324 gtk_window_set_title( GTK_WINDOW( window ), "Intersect" );
325 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
327 g_object_set_data( G_OBJECT( window ), "loop", &loop );
328 g_object_set_data( G_OBJECT( window ), "ret", &ret );
330 gtk_widget_realize( window );
334 auto vbox = ui::VBox( FALSE, 10 );
336 gtk_widget_show( vbox );
341 auto radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" );
342 gtk_box_pack_start( GTK_BOX( vbox ), radio1, FALSE, FALSE, 2 );
343 gtk_widget_show( radio1 );
345 auto radio2 = gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" );
346 gtk_box_pack_start( GTK_BOX( vbox ), radio2, FALSE, FALSE, 2 );
347 gtk_widget_show( radio2 );
349 auto hsep = ui::Widget(gtk_hseparator_new());
350 gtk_box_pack_start( GTK_BOX( vbox ), hsep, FALSE, FALSE, 2 );
353 check1 = ui::CheckButton( "Include Detail Brushes" );
354 gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
355 gtk_widget_show( check1 );
357 check2 = ui::CheckButton( "Select Duplicate Brushes Only" );
358 gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
359 gtk_widget_show( check2 );
361 hbox = ui::HBox( FALSE, 10 );
362 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
363 gtk_widget_show( hbox );
365 // ---- hbox ---- ok/cancel buttons
367 auto w = ui::Button( "Ok" );
368 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
369 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
371 gtk_widget_set_can_default( w, true );
372 gtk_widget_grab_default( w );
373 gtk_widget_show( w );
375 w = ui::Button( "Cancel" );
376 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
377 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
378 gtk_widget_show( w );
385 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
386 gtk_widget_show( window );
387 gtk_grab_add( window );
390 gtk_main_iteration();
392 if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio1 ) ) {
393 rs->nBrushOptions = BRUSH_OPT_WHOLE_MAP;
395 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio2 ) ) {
396 rs->nBrushOptions = BRUSH_OPT_SELECTED;
399 rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
400 rs->bDuplicateOnly = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
402 gtk_grab_remove( window );
403 gtk_widget_destroy( window );
408 EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
409 GtkWidget *hbox, *vbox2, *hbox2;
411 GtkWidget *check1, *check2, *check3;
412 GtkWidget *text1, *text2;
414 EMessageBoxReturn ret;
417 auto window = ui::Window( ui::window_type::TOP );
419 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
420 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
422 gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" );
423 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
425 g_object_set_data( G_OBJECT( window ), "loop", &loop );
426 g_object_set_data( G_OBJECT( window ), "ret", &ret );
428 gtk_widget_realize( window );
432 auto vbox = ui::VBox( FALSE, 10 );
438 hbox = ui::HBox( FALSE, 10 );
439 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
440 gtk_widget_show( hbox );
445 vbox2 = ui::VBox( FALSE, 10 );
446 gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
447 gtk_widget_show( vbox2 );
451 hbox2 = ui::HBox( FALSE, 10 );
452 gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
453 gtk_widget_show( hbox2 );
457 text1 = ui::Entry( 256 );
458 gtk_entry_set_text( (GtkEntry*)text1, "3" );
459 gtk_box_pack_start( GTK_BOX( hbox2 ), text1, FALSE, FALSE, 2 );
460 gtk_widget_show( text1 );
462 auto l = ui::Label( "Number Of Sides" );
463 gtk_box_pack_start( GTK_BOX( hbox2 ), l, FALSE, FALSE, 2 );
464 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
465 gtk_widget_show( l );
469 hbox2 = ui::HBox( FALSE, 10 );
470 gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
471 gtk_widget_show( hbox2 );
475 text2 = ui::Entry( 256 );
476 gtk_entry_set_text( (GtkEntry*)text2, "8" );
477 gtk_box_pack_start( GTK_BOX( hbox2 ), text2, FALSE, FALSE, 2 );
478 gtk_widget_show( text2 );
480 l = ui::Label( "Border Width" );
481 gtk_box_pack_start( GTK_BOX( hbox2 ), l, FALSE, FALSE, 2 );
482 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
483 gtk_widget_show( l );
491 vbox2 = ui::VBox( FALSE, 10 );
492 gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
493 gtk_widget_show( vbox2 );
497 check1 = ui::CheckButton( "Use Border" );
498 gtk_box_pack_start( GTK_BOX( vbox2 ), check1, FALSE, FALSE, 0 );
499 gtk_widget_show( check1 );
502 check2 = ui::CheckButton( "Inverse Polygon" );
503 gtk_box_pack_start( GTK_BOX( vbox2 ), check2, FALSE, FALSE, 0 );
504 gtk_widget_show( check2 );
507 check3 = ui::CheckButton( "Align Top Edge" );
508 gtk_box_pack_start( GTK_BOX( vbox2 ), check3, FALSE, FALSE, 0 );
509 gtk_widget_show( check3 );
515 hbox = ui::HBox( FALSE, 10 );
516 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
517 gtk_widget_show( hbox );
521 auto w = ui::Button( "Ok" );
522 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
523 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
525 gtk_widget_set_can_default( w, true );
526 gtk_widget_grab_default( w );
527 gtk_widget_show( w );
529 w = ui::Button( "Cancel" );
530 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
531 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
532 gtk_widget_show( w );
539 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
540 gtk_widget_show( window );
541 gtk_grab_add( window );
543 bool dialogError = TRUE;
544 while ( dialogError )
548 gtk_main_iteration();
552 if ( ret == eIDOK ) {
553 rs->bUseBorder = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
554 rs->bInverse = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
555 rs->bAlignTop = gtk_toggle_button_get_active( (GtkToggleButton*)check3 ) ? true : false;
557 if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
561 if ( rs->bUseBorder ) {
562 if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
569 gtk_grab_remove( window );
570 gtk_widget_destroy( window );
576 // for stair builder stuck as close as i could to the MFC version
577 // obviously feel free to change it at will :)
578 EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
579 GtkWidget *textStairHeight, *textRiserTex, *textMainTex;
580 GtkWidget *radioNorth, *radioSouth, *radioEast, *radioWest; // i'm guessing we can't just abuse 'w' for these if we're getting a value
581 GtkWidget *radioOldStyle, *radioBobStyle, *radioCornerStyle;
582 GtkWidget *checkUseDetail;
583 GSList *radioDirection, *radioStyle;
584 EMessageBoxReturn ret;
587 const char *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
589 auto window = ui::Window( ui::window_type::TOP );
591 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
592 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
594 gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" );
596 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
598 g_object_set_data( G_OBJECT( window ), "loop", &loop );
599 g_object_set_data( G_OBJECT( window ), "ret", &ret );
601 gtk_widget_realize( window );
604 auto vbox = ui::VBox( FALSE, 10 );
606 gtk_widget_show( vbox );
608 auto hbox = ui::HBox( FALSE, 10 );
610 gtk_widget_show( hbox );
612 // dunno if you want this text or not ...
613 ui::Widget w = ui::Label( text );
614 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
615 gtk_widget_show( w );
617 w = ui::Widget(gtk_hseparator_new());
618 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
619 gtk_widget_show( w );
621 // ------------------------- // indenting == good way of keeping track of lines :)
624 hbox = ui::HBox( FALSE, 10 );
625 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
626 gtk_widget_show( hbox );
628 textStairHeight = ui::Entry( 256 );
629 gtk_box_pack_start( GTK_BOX( hbox ), textStairHeight, FALSE, FALSE, 1 );
630 gtk_widget_show( textStairHeight );
632 w = ui::Label( "Stair Height" );
633 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
634 gtk_widget_show( w );
636 // ------------------------- //
638 hbox = ui::HBox( FALSE, 10 );
639 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
640 gtk_widget_show( hbox );
642 w = ui::Label( "Direction:" );
643 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
644 gtk_widget_show( w );
646 // -------------------------- //
648 hbox = ui::HBox( FALSE, 10 );
649 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
650 gtk_widget_show( hbox );
652 // radio buttons confuse me ...
653 // but this _looks_ right
655 // djbob: actually it looks very nice :), slightly better than the way i did it
656 // edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
658 radioNorth = gtk_radio_button_new_with_label( NULL, "North" );
659 gtk_box_pack_start( GTK_BOX( hbox ), radioNorth, FALSE, FALSE, 3 );
660 gtk_widget_show( radioNorth );
662 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
664 radioSouth = gtk_radio_button_new_with_label( radioDirection, "South" );
665 gtk_box_pack_start( GTK_BOX( hbox ), radioSouth, FALSE, FALSE, 2 );
666 gtk_widget_show( radioSouth );
668 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
670 radioEast = gtk_radio_button_new_with_label( radioDirection, "East" );
671 gtk_box_pack_start( GTK_BOX( hbox ), radioEast, FALSE, FALSE, 1 );
672 gtk_widget_show( radioEast );
674 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
676 radioWest = gtk_radio_button_new_with_label( radioDirection, "West" );
677 gtk_box_pack_start( GTK_BOX( hbox ), radioWest, FALSE, FALSE, 0 );
678 gtk_widget_show( radioWest );
680 // --------------------------- //
682 hbox = ui::HBox( FALSE, 10 );
683 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
684 gtk_widget_show( hbox );
686 w = ui::Label( "Style:" );
687 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
688 gtk_widget_show( w );
690 // --------------------------- //
692 hbox = ui::HBox( FALSE, 10 );
693 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
694 gtk_widget_show( hbox );
696 radioOldStyle = gtk_radio_button_new_with_label( NULL, "Original" );
697 gtk_box_pack_start( GTK_BOX( hbox ), radioOldStyle, FALSE, FALSE, 0 );
698 gtk_widget_show( radioOldStyle );
700 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
702 radioBobStyle = gtk_radio_button_new_with_label( radioStyle, "Bob's Style" );
703 gtk_box_pack_start( GTK_BOX( hbox ), radioBobStyle, FALSE, FALSE, 0 );
704 gtk_widget_show( radioBobStyle );
706 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
708 radioCornerStyle = gtk_radio_button_new_with_label( radioStyle, "Corner Style" );
709 gtk_box_pack_start( GTK_BOX( hbox ), radioCornerStyle, FALSE, FALSE, 0 );
710 gtk_widget_show( radioCornerStyle );
712 // err, the q3r has an if or something so you need bob style checked before this
713 // is "ungreyed out" but you'll need to do that, as i suck :)
715 // djbob: er.... yeah um, im not at all sure how i'm gonna sort this
716 // djbob: think we need some button callback functions or smuffin
717 // FIXME: actually get around to doing what i suggested!!!!
719 checkUseDetail = ui::CheckButton( "Use Detail Brushes" );
720 gtk_box_pack_start( GTK_BOX( hbox ), checkUseDetail, FALSE, FALSE, 0 );
721 gtk_widget_show( checkUseDetail );
723 // --------------------------- //
725 hbox = ui::HBox( FALSE, 10 );
726 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
727 gtk_widget_show( hbox );
729 textMainTex = ui::Entry( 512 );
730 gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture );
731 gtk_box_pack_start( GTK_BOX( hbox ), textMainTex, FALSE, FALSE, 0 );
732 gtk_widget_show( textMainTex );
734 w = ui::Label( "Main Texture" );
735 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
736 gtk_widget_show( w );
738 // -------------------------- //
740 hbox = ui::HBox( FALSE, 10 );
741 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
742 gtk_widget_show( hbox );
744 textRiserTex = ui::Entry( 512 );
745 gtk_box_pack_start( GTK_BOX( hbox ), textRiserTex, FALSE, FALSE, 0 );
746 gtk_widget_show( textRiserTex );
748 w = ui::Label( "Riser Texture" );
749 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
750 gtk_widget_show( w );
752 // -------------------------- //
753 w = ui::Widget(gtk_hseparator_new());
754 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
755 gtk_widget_show( w );
757 hbox = ui::HBox( FALSE, 10 );
758 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
759 gtk_widget_show( hbox );
761 w = ui::Button( "OK" );
762 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
763 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
764 gtk_widget_set_can_default( w, true );
765 gtk_widget_grab_default( w );
766 gtk_widget_show( w );
768 w = ui::Button( "Cancel" );
769 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
770 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
771 gtk_widget_show( w );
775 // +djbob: need our "little" modal loop mars :P
776 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
777 gtk_widget_show( window );
778 gtk_grab_add( window );
780 bool dialogError = TRUE;
781 while ( dialogError )
785 gtk_main_iteration();
789 if ( ret == eIDOK ) {
790 rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)checkUseDetail ) ? true : false;
792 strcpy( rs->riserTexture, gtk_entry_get_text( (GtkEntry*)textRiserTex ) );
793 strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)textMainTex ) );
795 if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioNorth ) ) {
796 rs->direction = MOVE_NORTH;
798 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioSouth ) ) {
799 rs->direction = MOVE_SOUTH;
801 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioEast ) ) {
802 rs->direction = MOVE_EAST;
804 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioWest ) ) {
805 rs->direction = MOVE_WEST;
808 if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
812 if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioOldStyle ) ) {
813 rs->style = STYLE_ORIGINAL;
815 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioBobStyle ) ) {
816 rs->style = STYLE_BOB;
818 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioCornerStyle ) ) {
819 rs->style = STYLE_CORNER;
824 gtk_grab_remove( window );
825 gtk_widget_destroy( window );
830 // there we go, all done ... on my end at least, not bad for a night's work
833 EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
835 GtkWidget *checkScaleMainH, *checkScaleMainV, *checkScaleTrimH, *checkScaleTrimV;
836 GtkWidget *radioNS, *radioEW;
837 GSList *radioOrientation;
839 EMessageBoxReturn ret;
842 auto window = ui::Window( ui::window_type::TOP );
844 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
845 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
847 gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" );
849 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
851 g_object_set_data( G_OBJECT( window ), "loop", &loop );
852 g_object_set_data( G_OBJECT( window ), "ret", &ret );
854 gtk_widget_realize( window );
857 ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
858 ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
859 LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
860 LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
862 auto vbox = ui::VBox( FALSE, 10 );
864 gtk_widget_show( vbox );
866 // -------------------------- //
868 hbox = ui::HBox( FALSE, 10 );
869 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
870 gtk_widget_show( hbox );
872 auto textFrontBackTex = ui::Entry( 512 );
873 gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture );
874 gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 );
875 gtk_widget_show( textFrontBackTex );
877 ui::Widget w = ui::Label( "Door Front/Back Texture" );
878 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
879 gtk_widget_show( w );
881 // ------------------------ //
883 hbox = ui::HBox( FALSE, 10 );
884 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
885 gtk_widget_show( hbox );
887 auto textTrimTex = ui::Entry( 512 );
888 gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 );
889 gtk_widget_show( textTrimTex );
891 w = ui::Label( "Door Trim Texture" );
892 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
893 gtk_widget_show( w );
895 // ----------------------- //
897 hbox = ui::HBox( FALSE, 10 );
898 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
899 gtk_widget_show( hbox );
901 // sp: horizontally ????
902 // djbob: yes mars, u can spell :]
903 checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" );
904 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE );
905 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainH, FALSE, FALSE, 0 );
906 gtk_widget_show( checkScaleMainH );
908 checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" );
909 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE );
910 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimH, FALSE, FALSE, 0 );
911 gtk_widget_show( checkScaleTrimH );
913 // ---------------------- //
915 hbox = ui::HBox( FALSE, 10 );
916 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
917 gtk_widget_show( hbox );
919 checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" );
920 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE );
921 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainV, FALSE, FALSE, 0 );
922 gtk_widget_show( checkScaleMainV );
924 checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" );
925 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimV, FALSE, FALSE, 0 );
926 gtk_widget_show( checkScaleTrimV );
928 // --------------------- //
930 hbox = ui::HBox( FALSE, 10 );
931 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
932 gtk_widget_show( hbox );
934 // djbob: lists added
936 auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures))));
937 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
938 gtk_box_pack_start( GTK_BOX( hbox ), comboMain, FALSE, FALSE, 0 );
939 gtk_widget_show( comboMain );
941 tw1.one = textFrontBackTex;
944 auto buttonSetMain = ui::Button( "Set As Main Texture" );
945 buttonSetMain.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 );
946 gtk_box_pack_start( GTK_BOX( hbox ), buttonSetMain, FALSE, FALSE, 0 );
947 gtk_widget_show( buttonSetMain );
949 // ------------------- //
951 hbox = ui::HBox( FALSE, 10 );
952 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
953 gtk_widget_show( hbox );
955 auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures))));
956 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
957 gtk_box_pack_start( GTK_BOX( hbox ), comboTrim, FALSE, FALSE, 0 );
958 gtk_widget_show( comboTrim );
960 tw2.one = textTrimTex;
963 auto buttonSetTrim = ui::Button( "Set As Trim Texture" );
964 buttonSetTrim.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 );
965 gtk_box_pack_start( GTK_BOX( hbox ), buttonSetTrim, FALSE, FALSE, 0 );
966 gtk_widget_show( buttonSetTrim );
968 // ------------------ //
970 hbox = ui::HBox( FALSE, 10 );
971 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
972 gtk_widget_show( hbox );
974 w = ui::Label( "Orientation" );
975 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
976 gtk_widget_show( w );
978 // argh more radio buttons!
979 radioNS = gtk_radio_button_new_with_label( NULL, "North - South" );
980 gtk_box_pack_start( GTK_BOX( hbox ), radioNS, FALSE, FALSE, 0 );
981 gtk_widget_show( radioNS );
983 radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
985 radioEW = gtk_radio_button_new_with_label( radioOrientation, "East - West" );
986 gtk_box_pack_start( GTK_BOX( hbox ), radioEW, FALSE, FALSE, 0 );
987 gtk_widget_show( radioEW );
989 // ----------------- //
991 w = ui::Widget(gtk_hseparator_new());
992 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
993 gtk_widget_show( w );
995 // ----------------- //
997 hbox = ui::HBox( FALSE, 10 );
998 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
999 gtk_widget_show( hbox );
1001 w = ui::Button( "OK" );
1002 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1003 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1004 gtk_widget_set_can_default( w, true );
1005 gtk_widget_grab_default( w );
1006 gtk_widget_show( w );
1008 w = ui::Button( "Cancel" );
1009 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1010 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1011 gtk_widget_show( w );
1014 // ----------------- //
1017 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1018 gtk_widget_show( window );
1019 gtk_grab_add( window );
1022 gtk_main_iteration();
1024 strcpy( rs->mainTexture, gtk_entry_get_text( GTK_ENTRY( textFrontBackTex ) ) );
1025 strcpy( rs->trimTexture, gtk_entry_get_text( GTK_ENTRY( textTrimTex ) ) );
1027 rs->bScaleMainH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainH ) ) ? true : false;
1028 rs->bScaleMainV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainV ) ) ? true : false;
1029 rs->bScaleTrimH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ) ) ? true : false;
1030 rs->bScaleTrimV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimV ) ) ? true : false;
1032 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioNS ) ) ) {
1033 rs->nOrientation = DIRECTION_NS;
1035 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioEW ) ) ) {
1036 rs->nOrientation = DIRECTION_EW;
1039 gtk_grab_remove( window );
1040 gtk_widget_destroy( window );
1046 EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
1047 ui::Widget w{ui::null};
1049 EMessageBoxReturn ret;
1052 auto window = ui::Window( ui::window_type::TOP );
1054 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1055 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1057 gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1058 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1060 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1061 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1063 gtk_widget_realize( window );
1067 auto vbox = ui::VBox( FALSE, 10 );
1069 gtk_widget_show( vbox );
1073 auto hbox = ui::HBox( FALSE, 10 );
1074 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1075 gtk_widget_show( hbox );
1079 auto text1 = ui::Entry( 256 );
1080 gtk_entry_set_text( text1, "25" );
1081 gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 );
1082 gtk_widget_show( text1 );
1084 w = ui::Label( "Number Of Points" );
1085 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1086 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1087 gtk_widget_show( w );
1091 hbox = ui::HBox( FALSE, 10 );
1092 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1093 gtk_widget_show( hbox );
1097 auto text2 = ui::Entry( 256 );
1098 gtk_entry_set_text( text2, "3" );
1099 gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 );
1100 gtk_widget_show( text2 );
1102 w = ui::Label( "Multipler" );
1103 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1104 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1105 gtk_widget_show( w );
1109 w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" );
1110 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1111 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1112 gtk_widget_show( w );
1114 hbox = ui::HBox( FALSE, 10 );
1115 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1116 gtk_widget_show( hbox );
1120 auto text3 = ui::Entry( 256 );
1121 gtk_entry_set_text( text3, "-800" );
1122 gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 );
1123 gtk_widget_show( text3 );
1125 w = ui::Label( "Gravity" );
1126 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1127 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1128 gtk_widget_show( w );
1132 w = ui::Widget(gtk_hseparator_new());
1133 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1134 gtk_widget_show( w );
1136 auto check1 = ui::CheckButton( "No Dynamic Update" );
1137 gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
1138 gtk_widget_show( check1 );
1140 auto check2 = ui::CheckButton( "Show Bounding Lines" );
1141 gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
1142 gtk_widget_show( check2 );
1147 // ----------------- //
1149 w = ui::Widget(gtk_hseparator_new());
1150 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1151 gtk_widget_show( w );
1153 // ----------------- //
1155 hbox = ui::HBox( FALSE, 10 );
1156 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1157 gtk_widget_show( hbox );
1159 w = ui::Button( "Enable" );
1160 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1161 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1162 gtk_widget_show( w );
1164 gtk_widget_set_can_default( w, true );
1165 gtk_widget_grab_default( w );
1167 w = ui::Button( "Disable" );
1168 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1169 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
1170 gtk_widget_show( w );
1172 w = ui::Button( "Cancel" );
1173 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1174 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1175 gtk_widget_show( w );
1179 // ----------------- //
1181 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1182 gtk_widget_show( window );
1183 gtk_grab_add( window );
1185 bool dialogError = TRUE;
1186 while ( dialogError )
1190 gtk_main_iteration();
1192 dialogError = FALSE;
1194 if ( ret == eIDYES ) {
1195 if ( !ValidateTextIntRange( gtk_entry_get_text( GTK_ENTRY( text1 ) ), 1, 200, "Number Of Points", &rs->nPoints ) ) {
1199 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text2 ) ), 1.0f, 10.0f, "Multiplier", &rs->fMultiplier ) ) {
1203 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text3 ) ), -10000.0f, -1.0f, "Gravity", &rs->fGravity ) ) {
1207 rs->bNoUpdate = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check1 ) ) ? true : false;
1208 rs->bShowExtra = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check2 ) ) ? true : false;
1212 gtk_grab_remove( window );
1213 gtk_widget_destroy( window );
1218 EMessageBoxReturn DoCTFColourChangeBox(){
1219 ui::Widget w{ui::null};
1220 EMessageBoxReturn ret;
1223 auto window = ui::Window( ui::window_type::TOP );
1225 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1226 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1228 gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" );
1229 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1231 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1232 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1234 gtk_widget_realize( window );
1238 auto vbox = ui::VBox( FALSE, 10 );
1240 gtk_widget_show( vbox );
1244 auto hbox = ui::HBox( FALSE, 10 );
1245 gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
1246 gtk_widget_show( hbox );
1248 // ---- hbox ---- ok/cancel buttons
1250 w = ui::Button( "Red->Blue" );
1251 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1252 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1254 gtk_widget_set_can_default( w, true );
1255 gtk_widget_grab_default( w );
1256 gtk_widget_show( w );
1258 w = ui::Button( "Blue->Red" );
1259 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1260 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1261 gtk_widget_show( w );
1263 w = ui::Button( "Cancel" );
1264 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1265 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1266 gtk_widget_show( w );
1273 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1274 gtk_widget_show( window );
1275 gtk_grab_add( window );
1278 gtk_main_iteration();
1280 gtk_grab_remove( window );
1281 gtk_widget_destroy( window );
1286 EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
1289 ui::Widget w{ui::null};
1291 EMessageBoxReturn ret;
1294 auto window = ui::Window( ui::window_type::TOP );
1296 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1297 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1299 gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1300 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1302 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1303 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1305 gtk_widget_realize( window );
1307 auto vbox = ui::VBox( FALSE, 10 );
1313 auto hbox = ui::HBox( FALSE, 10 );
1314 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1315 gtk_widget_show( hbox );
1319 texSelected = "Currently Selected Texture: ";
1320 texSelected += GetCurrentTexture();
1322 w = ui::Label( texSelected );
1323 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1324 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1325 gtk_widget_show( w );
1329 auto frame = ui::Frame( "Reset Texture Names" );
1330 gtk_widget_show( frame );
1331 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1333 auto table = ui::Table( 2, 3, TRUE );
1336 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1337 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1338 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1342 dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
1343 dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1344 gtk_widget_show( dlgTexReset.cbTexChange );
1345 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1,
1346 (GtkAttachOptions) ( GTK_FILL ),
1347 (GtkAttachOptions) ( 0 ), 0, 0 );
1349 w = ui::Label( "Old Name: " );
1350 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1351 (GtkAttachOptions) ( GTK_FILL ),
1352 (GtkAttachOptions) ( 0 ), 0, 0 );
1353 gtk_widget_show( w );
1355 dlgTexReset.editTexOld = ui::Entry( 256 );
1356 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
1357 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1,
1358 (GtkAttachOptions) ( GTK_FILL ),
1359 (GtkAttachOptions) ( 0 ), 0, 0 );
1360 gtk_widget_show( dlgTexReset.editTexOld );
1362 w = ui::Label( "New Name: " );
1363 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1364 (GtkAttachOptions) ( GTK_FILL ),
1365 (GtkAttachOptions) ( 0 ), 0, 0 );
1366 gtk_widget_show( w );
1368 dlgTexReset.editTexNew = ui::Entry( 256 );
1369 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
1370 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2,
1371 (GtkAttachOptions) ( GTK_FILL ),
1372 (GtkAttachOptions) ( 0 ), 0, 0 );
1373 gtk_widget_show( dlgTexReset.editTexNew );
1377 frame = ui::Frame( "Reset Scales" );
1378 gtk_widget_show( frame );
1379 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1381 table = ui::Table( 2, 3, TRUE );
1384 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1385 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1386 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1390 dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
1391 dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1392 gtk_widget_show( dlgTexReset.cbScaleHor );
1393 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1,
1394 (GtkAttachOptions) ( GTK_FILL ),
1395 (GtkAttachOptions) ( 0 ), 0, 0 );
1397 w = ui::Label( "New Horizontal Scale: " );
1398 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1399 (GtkAttachOptions) ( GTK_FILL ),
1400 (GtkAttachOptions) ( 0 ), 0, 0 );
1401 gtk_widget_show( w );
1403 dlgTexReset.editScaleHor = ui::Entry( 256 );
1404 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
1405 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1,
1406 (GtkAttachOptions) ( GTK_FILL ),
1407 (GtkAttachOptions) ( 0 ), 0, 0 );
1408 gtk_widget_show( dlgTexReset.editScaleHor );
1411 dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
1412 dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1413 gtk_widget_show( dlgTexReset.cbScaleVert );
1414 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2,
1415 (GtkAttachOptions) ( GTK_FILL ),
1416 (GtkAttachOptions) ( 0 ), 0, 0 );
1418 w = ui::Label( "New Vertical Scale: " );
1419 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1420 (GtkAttachOptions) ( GTK_FILL ),
1421 (GtkAttachOptions) ( 0 ), 0, 0 );
1422 gtk_widget_show( w );
1424 dlgTexReset.editScaleVert = ui::Entry( 256 );
1425 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
1426 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2,
1427 (GtkAttachOptions) ( GTK_FILL ),
1428 (GtkAttachOptions) ( 0 ), 0, 0 );
1429 gtk_widget_show( dlgTexReset.editScaleVert );
1433 frame = ui::Frame( "Reset Shift" );
1434 gtk_widget_show( frame );
1435 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1437 table = ui::Table( 2, 3, TRUE );
1440 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1441 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1442 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1446 dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
1447 dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1448 gtk_widget_show( dlgTexReset.cbShiftHor );
1449 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1,
1450 (GtkAttachOptions) ( GTK_FILL ),
1451 (GtkAttachOptions) ( 0 ), 0, 0 );
1453 w = ui::Label( "New Horizontal Shift: " );
1454 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1455 (GtkAttachOptions) ( GTK_FILL ),
1456 (GtkAttachOptions) ( 0 ), 0, 0 );
1457 gtk_widget_show( w );
1459 dlgTexReset.editShiftHor = ui::Entry( 256 );
1460 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
1461 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1,
1462 (GtkAttachOptions) ( GTK_FILL ),
1463 (GtkAttachOptions) ( 0 ), 0, 0 );
1464 gtk_widget_show( dlgTexReset.editShiftHor );
1467 dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
1468 dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1469 gtk_widget_show( dlgTexReset.cbShiftVert );
1470 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2,
1471 (GtkAttachOptions) ( GTK_FILL ),
1472 (GtkAttachOptions) ( 0 ), 0, 0 );
1474 w = ui::Label( "New Vertical Shift: " );
1475 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1476 (GtkAttachOptions) ( GTK_FILL ),
1477 (GtkAttachOptions) ( 0 ), 0, 0 );
1478 gtk_widget_show( w );
1480 dlgTexReset.editShiftVert = ui::Entry( 256 );
1481 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
1482 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2,
1483 (GtkAttachOptions) ( GTK_FILL ),
1484 (GtkAttachOptions) ( 0 ), 0, 0 );
1485 gtk_widget_show( dlgTexReset.editShiftVert );
1489 frame = ui::Frame( "Reset Rotation" );
1490 gtk_widget_show( frame );
1491 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1493 table = ui::Table( 1, 3, TRUE );
1496 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1497 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1498 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1502 dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
1503 gtk_widget_show( dlgTexReset.cbRotation );
1504 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1,
1505 (GtkAttachOptions) ( GTK_FILL ),
1506 (GtkAttachOptions) ( 0 ), 0, 0 );
1508 w = ui::Label( "New Rotation Value: " );
1509 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1510 (GtkAttachOptions) ( GTK_FILL ),
1511 (GtkAttachOptions) ( 0 ), 0, 0 );
1512 gtk_widget_show( w );
1514 dlgTexReset.editRotation = ui::Entry( 256 );
1515 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
1516 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1,
1517 (GtkAttachOptions) ( GTK_FILL ),
1518 (GtkAttachOptions) ( 0 ), 0, 0 );
1519 gtk_widget_show( dlgTexReset.editRotation );
1523 hbox = ui::HBox( FALSE, 10 );
1524 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1525 gtk_widget_show( hbox );
1529 w = ui::Button( "Use Selected Brushes" );
1530 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1531 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1533 gtk_widget_set_can_default( w, true );
1534 gtk_widget_grab_default( w );
1535 gtk_widget_show( w );
1537 w = ui::Button( "Use All Brushes" );
1538 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1539 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1540 gtk_widget_show( w );
1542 w = ui::Button( "Cancel" );
1543 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1544 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1545 gtk_widget_show( w );
1552 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1553 gtk_widget_show( window );
1554 gtk_grab_add( window );
1556 Update_TextureReseter();
1558 bool dialogError = TRUE;
1559 while ( dialogError )
1563 gtk_main_iteration();
1565 dialogError = FALSE;
1567 if ( ret != eIDCANCEL ) {
1568 rs->bResetRotation = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
1569 if ( rs->bResetRotation ) {
1570 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editRotation ) ), "Rotation", &rs->rotation ) ) {
1575 rs->bResetScale[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
1576 if ( rs->bResetScale[0] ) {
1577 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleHor ) ), "Horizontal Scale", &rs->fScale[0] ) ) {
1582 rs->bResetScale[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
1583 if ( rs->bResetScale[1] ) {
1584 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleVert ) ), "Vertical Scale", &rs->fScale[1] ) ) {
1589 rs->bResetShift[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
1590 if ( rs->bResetShift[0] ) {
1591 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftHor ) ), "Horizontal Shift", &rs->fShift[0] ) ) {
1596 rs->bResetShift[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
1597 if ( rs->bResetShift[1] ) {
1598 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftVert ) ), "Vertical Shift", &rs->fShift[1] ) ) {
1603 rs->bResetTextureName = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
1604 if ( rs->bResetTextureName ) {
1605 strcpy( rs->textureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexOld ) ) );
1606 strcpy( rs->newTextureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexNew ) ) );
1611 gtk_grab_remove( window );
1612 gtk_widget_destroy( window );
1617 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
1620 ui::Widget w{ui::null};
1622 ui::Widget radiusX{ui::null}, radiusY{ui::null};
1623 ui::Widget angleStart{ui::null}, angleEnd{ui::null};
1624 ui::Widget heightStart{ui::null}, heightEnd{ui::null};
1625 ui::Widget numPoints{ui::null};
1627 EMessageBoxReturn ret;
1630 auto window = ui::Window( ui::window_type::TOP );
1632 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1633 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1635 gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" );
1636 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1638 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1639 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1641 gtk_widget_realize( window );
1643 auto vbox = ui::VBox( FALSE, 10 );
1649 auto hbox = ui::HBox( FALSE, 10 );
1650 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1651 gtk_widget_show( hbox );
1655 auto frame = ui::Frame( "Radii" );
1656 gtk_widget_show( frame );
1657 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1659 auto table = ui::Table( 2, 3, TRUE );
1662 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1663 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1664 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1668 w = ui::Label( "X: " );
1669 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1670 (GtkAttachOptions) ( GTK_FILL ),
1671 (GtkAttachOptions) ( 0 ), 0, 0 );
1672 gtk_widget_show( w );
1674 radiusX = ui::Entry( 256 );
1675 gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
1676 gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1,
1677 (GtkAttachOptions) ( GTK_FILL ),
1678 (GtkAttachOptions) ( 0 ), 0, 0 );
1679 gtk_widget_show( radiusX );
1683 w = ui::Label( "Y: " );
1684 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1685 (GtkAttachOptions) ( GTK_FILL ),
1686 (GtkAttachOptions) ( 0 ), 0, 0 );
1687 gtk_widget_show( w );
1689 radiusY = ui::Entry( 256 );
1690 gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
1691 gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2,
1692 (GtkAttachOptions) ( GTK_FILL ),
1693 (GtkAttachOptions) ( 0 ), 0, 0 );
1694 gtk_widget_show( radiusY );
1698 frame = ui::Frame( "Angles" );
1699 gtk_widget_show( frame );
1700 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1702 table = ui::Table( 2, 3, TRUE );
1705 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1706 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1707 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1711 w = ui::Label( "Start: " );
1712 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1713 (GtkAttachOptions) ( GTK_FILL ),
1714 (GtkAttachOptions) ( 0 ), 0, 0 );
1715 gtk_widget_show( w );
1717 angleStart = ui::Entry( 256 );
1718 gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
1719 gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1,
1720 (GtkAttachOptions) ( GTK_FILL ),
1721 (GtkAttachOptions) ( 0 ), 0, 0 );
1722 gtk_widget_show( angleStart );
1726 w = ui::Label( "End: " );
1727 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1728 (GtkAttachOptions) ( GTK_FILL ),
1729 (GtkAttachOptions) ( 0 ), 0, 0 );
1730 gtk_widget_show( w );
1732 angleEnd = ui::Entry( 256 );
1733 gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
1734 gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2,
1735 (GtkAttachOptions) ( GTK_FILL ),
1736 (GtkAttachOptions) ( 0 ), 0, 0 );
1737 gtk_widget_show( angleEnd );
1740 frame = ui::Frame( "Height" );
1741 gtk_widget_show( frame );
1742 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1744 table = ui::Table( 2, 3, TRUE );
1747 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1748 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1749 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1753 w = ui::Label( "Start: " );
1754 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1755 (GtkAttachOptions) ( GTK_FILL ),
1756 (GtkAttachOptions) ( 0 ), 0, 0 );
1757 gtk_widget_show( w );
1759 heightStart = ui::Entry( 256 );
1760 gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
1761 gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1,
1762 (GtkAttachOptions) ( GTK_FILL ),
1763 (GtkAttachOptions) ( 0 ), 0, 0 );
1764 gtk_widget_show( heightStart );
1768 w = ui::Label( "End: " );
1769 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1770 (GtkAttachOptions) ( GTK_FILL ),
1771 (GtkAttachOptions) ( 0 ), 0, 0 );
1772 gtk_widget_show( w );
1774 heightEnd = ui::Entry( 256 );
1775 gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
1776 gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2,
1777 (GtkAttachOptions) ( GTK_FILL ),
1778 (GtkAttachOptions) ( 0 ), 0, 0 );
1779 gtk_widget_show( heightEnd );
1783 frame = ui::Frame( "Points" );
1784 gtk_widget_show( frame );
1785 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1787 table = ui::Table( 2, 3, TRUE );
1790 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1791 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1792 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1796 w = ui::Label( "Number: " );
1797 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1798 (GtkAttachOptions) ( GTK_FILL ),
1799 (GtkAttachOptions) ( 0 ), 0, 0 );
1800 gtk_widget_show( w );
1802 numPoints = ui::Entry( 256 );
1803 gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
1804 gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1,
1805 (GtkAttachOptions) ( GTK_FILL ),
1806 (GtkAttachOptions) ( 0 ), 0, 0 );
1807 gtk_widget_show( numPoints );
1810 hbox = ui::HBox( FALSE, 10 );
1811 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1812 gtk_widget_show( hbox );
1816 w = ui::Button( "Ok" );
1817 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1818 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1820 gtk_widget_set_can_default( w, true );
1821 gtk_widget_grab_default( w );
1822 gtk_widget_show( w );
1824 w = ui::Button( "Cancel" );
1825 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1826 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1827 gtk_widget_show( w );
1834 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1835 gtk_widget_show( window );
1836 gtk_grab_add( window );
1838 bool dialogError = TRUE;
1839 while ( dialogError )
1843 gtk_main_iteration();
1845 dialogError = FALSE;
1847 if ( ret != eIDCANCEL ) {
1848 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusX ) ), "Radius (X)", &rs->fRadiusX ) ) {
1852 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusY ) ), "Radius (Y)", &rs->fRadiusY ) ) {
1856 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleStart ) ), "Angle (Start)", &rs->fStartAngle ) ) {
1860 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleEnd ) ), "Angle (End)", &rs->fEndAngle ) ) {
1864 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightStart ) ), "Height (Start)", &rs->fStartHeight ) ) {
1868 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightEnd ) ), "Height (End)", &rs->fEndHeight ) ) {
1872 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( numPoints ) ), "Num Points", &rs->iNumPoints ) ) {
1878 gtk_grab_remove( window );
1879 gtk_widget_destroy( window );
1884 // add a simple input for the MakeChain thing..
1885 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
1886 ui::Widget w{ui::null};
1887 ui::Entry textlinkNum{ui::null}, textlinkName{ui::null};
1888 EMessageBoxReturn ret;
1891 const char *text = "Please set a value in the boxes below and press 'OK' to make a chain";
1893 auto window = ui::Window( ui::window_type::TOP );
1895 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1896 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1898 gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" );
1900 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1902 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1903 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1905 gtk_widget_realize( window );
1908 auto vbox = ui::VBox( FALSE, 10 );
1912 auto hbox = ui::HBox( FALSE, 10 );
1916 // dunno if you want this text or not ...
1917 w = ui::Label( text );
1918 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1919 gtk_widget_show( w );
1921 w = ui::Widget(gtk_hseparator_new());
1922 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1923 gtk_widget_show( w );
1925 // ------------------------- //
1928 hbox = ui::HBox( FALSE, 10 );
1929 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1930 gtk_widget_show( hbox );
1932 textlinkNum = ui::Entry( 256 );
1933 gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 );
1934 gtk_widget_show( textlinkNum );
1936 w = ui::Label( "Number of elements in chain" );
1937 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1938 gtk_widget_show( w );
1940 // -------------------------- //
1942 hbox = ui::HBox( FALSE, 10 );
1943 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1944 gtk_widget_show( hbox );
1946 textlinkName = ui::Entry( 256 );
1947 gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 );
1948 gtk_widget_show( textlinkName );
1950 w = ui::Label( "Basename for chain's targetnames." );
1951 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1952 gtk_widget_show( w );
1955 w = ui::Button( "OK" );
1956 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1957 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1958 gtk_widget_set_can_default( w, true );
1959 gtk_widget_grab_default( w );
1960 gtk_widget_show( w );
1962 w = ui::Button( "Cancel" );
1963 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1964 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1965 gtk_widget_show( w );
1969 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1970 gtk_widget_show( window );
1971 gtk_grab_add( window );
1973 bool dialogError = TRUE;
1974 while ( dialogError )
1978 gtk_main_iteration();
1980 dialogError = FALSE;
1982 if ( ret == eIDOK ) {
1983 strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) );
1984 if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) {
1990 gtk_grab_remove( window );
1991 gtk_widget_destroy( window );