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( ui::Widget widget, GdkEvent* event, gpointer data ){
96 int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
101 static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){
102 TwinWidget* tw = (TwinWidget*)data;
104 GtkEntry* entry = GTK_ENTRY( tw->one );
105 auto* combo = GTK_BIN(tw->two);
107 const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
108 gtk_entry_set_text( entry, tex );
111 /*--------------------------------
112 Data validation Routines
113 ---------------------------------*/
115 bool ValidateTextFloat( const char* pData, const char* error_title, float* value ){
117 float testNum = (float)atof( pData );
119 if ( ( testNum == 0.0f ) && strcmp( pData, "0" ) ) {
120 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
130 DoMessageBox( "Please Enter A Floating Point Number", error_title, eMB_OK );
134 bool ValidateTextFloatRange( const char* pData, float min, float max, const char* error_title, float* value ){
135 char error_buffer[256];
136 sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max );
139 float testNum = (float)atof( pData );
141 if ( ( testNum < min ) || ( testNum > max ) ) {
142 DoMessageBox( error_buffer, error_title, eMB_OK );
152 DoMessageBox( error_buffer, error_title, eMB_OK );
156 bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){
157 char error_buffer[256];
158 sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max );
161 int testNum = atoi( pData );
163 if ( ( testNum < min ) || ( testNum > max ) ) {
164 DoMessageBox( error_buffer, error_title, eMB_OK );
174 DoMessageBox( error_buffer, error_title, eMB_OK );
178 bool ValidateTextInt( const char* pData, const char* error_title, int* value ){
180 int testNum = atoi( pData );
182 if ( ( testNum == 0 ) && strcmp( pData, "0" ) ) {
183 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
193 DoMessageBox( "Please Enter An Integer", error_title, eMB_OK );
197 /*--------------------------------
199 ---------------------------------*/
203 Major clean up of variable names etc required, excluding Mars's ones,
204 which are nicely done :)
208 EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){
209 ui::Widget w{ui::null};
210 EMessageBoxReturn ret;
213 auto window = ui::Window( ui::window_type::TOP );
214 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
215 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
216 gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
217 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
218 g_object_set_data( G_OBJECT( window ), "loop", &loop );
219 g_object_set_data( G_OBJECT( window ), "ret", &ret );
220 gtk_widget_realize( window );
222 auto vbox = ui::VBox( FALSE, 10 );
224 gtk_widget_show( vbox );
226 w = ui::Label( lpText );
227 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
228 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
229 gtk_widget_show( w );
231 w = ui::Widget(gtk_hseparator_new());
232 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
233 gtk_widget_show( w );
235 auto hbox = ui::HBox( FALSE, 10 );
236 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
237 gtk_widget_show( hbox );
239 if ( type == eMB_OK ) {
240 w = ui::Button( "Ok" );
241 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
242 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
243 gtk_widget_set_can_default(w, true);
244 gtk_widget_grab_default( w );
245 gtk_widget_show( w );
248 else if ( type == eMB_OKCANCEL ) {
249 w = ui::Button( "Ok" );
250 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
251 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
252 gtk_widget_set_can_default( w, true );
253 gtk_widget_grab_default( w );
254 gtk_widget_show( w );
256 w = ui::Button( "Cancel" );
257 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
258 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
259 gtk_widget_show( w );
262 else if ( type == eMB_YESNOCANCEL ) {
263 w = ui::Button( "Yes" );
264 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
265 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
266 gtk_widget_set_can_default( w, true );
267 gtk_widget_grab_default( w );
268 gtk_widget_show( w );
270 w = ui::Button( "No" );
271 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
272 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
273 gtk_widget_show( w );
275 w = ui::Button( "Cancel" );
276 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
277 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
278 gtk_widget_show( w );
281 else /* if (mode == MB_YESNO) */
283 w = ui::Button( "Yes" );
284 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
285 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
286 gtk_widget_set_can_default( w, true );
287 gtk_widget_grab_default( w );
288 gtk_widget_show( w );
290 w = ui::Button( "No" );
291 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
292 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
293 gtk_widget_show( w );
297 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
298 gtk_widget_show( window );
299 gtk_grab_add( window );
302 gtk_main_iteration();
304 gtk_grab_remove( window );
310 EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
312 GtkWidget *check1, *check2;
313 EMessageBoxReturn ret;
316 auto window = ui::Window( ui::window_type::TOP );
318 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
319 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
321 gtk_window_set_title( GTK_WINDOW( window ), "Intersect" );
322 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
324 g_object_set_data( G_OBJECT( window ), "loop", &loop );
325 g_object_set_data( G_OBJECT( window ), "ret", &ret );
327 gtk_widget_realize( window );
331 auto vbox = ui::VBox( FALSE, 10 );
333 gtk_widget_show( vbox );
338 auto radio1 = gtk_radio_button_new_with_label( NULL, "Use Whole Map" );
339 gtk_box_pack_start( GTK_BOX( vbox ), radio1, FALSE, FALSE, 2 );
340 gtk_widget_show( radio1 );
342 auto radio2 = gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" );
343 gtk_box_pack_start( GTK_BOX( vbox ), radio2, FALSE, FALSE, 2 );
344 gtk_widget_show( radio2 );
346 auto hsep = ui::Widget(gtk_hseparator_new());
347 gtk_box_pack_start( GTK_BOX( vbox ), hsep, FALSE, FALSE, 2 );
350 check1 = ui::CheckButton( "Include Detail Brushes" );
351 gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
352 gtk_widget_show( check1 );
354 check2 = ui::CheckButton( "Select Duplicate Brushes Only" );
355 gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
356 gtk_widget_show( check2 );
358 hbox = ui::HBox( FALSE, 10 );
359 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
360 gtk_widget_show( hbox );
362 // ---- hbox ---- ok/cancel buttons
364 auto w = ui::Button( "Ok" );
365 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
366 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
368 gtk_widget_set_can_default( w, true );
369 gtk_widget_grab_default( w );
370 gtk_widget_show( w );
372 w = ui::Button( "Cancel" );
373 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
374 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
375 gtk_widget_show( w );
382 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
383 gtk_widget_show( window );
384 gtk_grab_add( window );
387 gtk_main_iteration();
389 if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio1 ) ) {
390 rs->nBrushOptions = BRUSH_OPT_WHOLE_MAP;
392 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radio2 ) ) {
393 rs->nBrushOptions = BRUSH_OPT_SELECTED;
396 rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
397 rs->bDuplicateOnly = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
399 gtk_grab_remove( window );
405 EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
406 GtkWidget *hbox, *vbox2, *hbox2;
408 GtkWidget *check1, *check2, *check3;
409 GtkWidget *text1, *text2;
411 EMessageBoxReturn ret;
414 auto window = ui::Window( ui::window_type::TOP );
416 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
417 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
419 gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" );
420 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
422 g_object_set_data( G_OBJECT( window ), "loop", &loop );
423 g_object_set_data( G_OBJECT( window ), "ret", &ret );
425 gtk_widget_realize( window );
429 auto vbox = ui::VBox( FALSE, 10 );
435 hbox = ui::HBox( FALSE, 10 );
436 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
437 gtk_widget_show( hbox );
442 vbox2 = ui::VBox( FALSE, 10 );
443 gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
444 gtk_widget_show( vbox2 );
448 hbox2 = ui::HBox( FALSE, 10 );
449 gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
450 gtk_widget_show( hbox2 );
454 text1 = ui::Entry( 256 );
455 gtk_entry_set_text( (GtkEntry*)text1, "3" );
456 gtk_box_pack_start( GTK_BOX( hbox2 ), text1, FALSE, FALSE, 2 );
457 gtk_widget_show( text1 );
459 auto l = ui::Label( "Number Of Sides" );
460 gtk_box_pack_start( GTK_BOX( hbox2 ), l, FALSE, FALSE, 2 );
461 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
462 gtk_widget_show( l );
466 hbox2 = ui::HBox( FALSE, 10 );
467 gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 2 );
468 gtk_widget_show( hbox2 );
472 text2 = ui::Entry( 256 );
473 gtk_entry_set_text( (GtkEntry*)text2, "8" );
474 gtk_box_pack_start( GTK_BOX( hbox2 ), text2, FALSE, FALSE, 2 );
475 gtk_widget_show( text2 );
477 l = ui::Label( "Border Width" );
478 gtk_box_pack_start( GTK_BOX( hbox2 ), l, FALSE, FALSE, 2 );
479 gtk_label_set_justify( GTK_LABEL( l ), GTK_JUSTIFY_LEFT );
480 gtk_widget_show( l );
488 vbox2 = ui::VBox( FALSE, 10 );
489 gtk_box_pack_start( GTK_BOX( hbox ), vbox2, FALSE, FALSE, 2 );
490 gtk_widget_show( vbox2 );
494 check1 = ui::CheckButton( "Use Border" );
495 gtk_box_pack_start( GTK_BOX( vbox2 ), check1, FALSE, FALSE, 0 );
496 gtk_widget_show( check1 );
499 check2 = ui::CheckButton( "Inverse Polygon" );
500 gtk_box_pack_start( GTK_BOX( vbox2 ), check2, FALSE, FALSE, 0 );
501 gtk_widget_show( check2 );
504 check3 = ui::CheckButton( "Align Top Edge" );
505 gtk_box_pack_start( GTK_BOX( vbox2 ), check3, FALSE, FALSE, 0 );
506 gtk_widget_show( check3 );
512 hbox = ui::HBox( FALSE, 10 );
513 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
514 gtk_widget_show( hbox );
518 auto w = ui::Button( "Ok" );
519 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
520 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
522 gtk_widget_set_can_default( w, true );
523 gtk_widget_grab_default( w );
524 gtk_widget_show( w );
526 w = ui::Button( "Cancel" );
527 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
528 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
529 gtk_widget_show( w );
536 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
537 gtk_widget_show( window );
538 gtk_grab_add( window );
540 bool dialogError = TRUE;
541 while ( dialogError )
545 gtk_main_iteration();
549 if ( ret == eIDOK ) {
550 rs->bUseBorder = gtk_toggle_button_get_active( (GtkToggleButton*)check1 ) ? true : false;
551 rs->bInverse = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
552 rs->bAlignTop = gtk_toggle_button_get_active( (GtkToggleButton*)check3 ) ? true : false;
554 if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
558 if ( rs->bUseBorder ) {
559 if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
566 gtk_grab_remove( window );
573 // for stair builder stuck as close as i could to the MFC version
574 // obviously feel free to change it at will :)
575 EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
576 GtkWidget *textStairHeight, *textRiserTex, *textMainTex;
577 GtkWidget *radioNorth, *radioSouth, *radioEast, *radioWest; // i'm guessing we can't just abuse 'w' for these if we're getting a value
578 GtkWidget *radioOldStyle, *radioBobStyle, *radioCornerStyle;
579 GtkWidget *checkUseDetail;
580 GSList *radioDirection, *radioStyle;
581 EMessageBoxReturn ret;
584 const char *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
586 auto window = ui::Window( ui::window_type::TOP );
588 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
589 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
591 gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" );
593 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
595 g_object_set_data( G_OBJECT( window ), "loop", &loop );
596 g_object_set_data( G_OBJECT( window ), "ret", &ret );
598 gtk_widget_realize( window );
601 auto vbox = ui::VBox( FALSE, 10 );
603 gtk_widget_show( vbox );
605 auto hbox = ui::HBox( FALSE, 10 );
607 gtk_widget_show( hbox );
609 // dunno if you want this text or not ...
610 ui::Widget w = ui::Label( text );
611 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
612 gtk_widget_show( w );
614 w = ui::Widget(gtk_hseparator_new());
615 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
616 gtk_widget_show( w );
618 // ------------------------- // indenting == good way of keeping track of lines :)
621 hbox = ui::HBox( FALSE, 10 );
622 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
623 gtk_widget_show( hbox );
625 textStairHeight = ui::Entry( 256 );
626 gtk_box_pack_start( GTK_BOX( hbox ), textStairHeight, FALSE, FALSE, 1 );
627 gtk_widget_show( textStairHeight );
629 w = ui::Label( "Stair Height" );
630 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
631 gtk_widget_show( w );
633 // ------------------------- //
635 hbox = ui::HBox( FALSE, 10 );
636 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
637 gtk_widget_show( hbox );
639 w = ui::Label( "Direction:" );
640 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
641 gtk_widget_show( w );
643 // -------------------------- //
645 hbox = ui::HBox( FALSE, 10 );
646 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
647 gtk_widget_show( hbox );
649 // radio buttons confuse me ...
650 // but this _looks_ right
652 // djbob: actually it looks very nice :), slightly better than the way i did it
653 // edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
655 radioNorth = gtk_radio_button_new_with_label( NULL, "North" );
656 gtk_box_pack_start( GTK_BOX( hbox ), radioNorth, FALSE, FALSE, 3 );
657 gtk_widget_show( radioNorth );
659 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
661 radioSouth = gtk_radio_button_new_with_label( radioDirection, "South" );
662 gtk_box_pack_start( GTK_BOX( hbox ), radioSouth, FALSE, FALSE, 2 );
663 gtk_widget_show( radioSouth );
665 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
667 radioEast = gtk_radio_button_new_with_label( radioDirection, "East" );
668 gtk_box_pack_start( GTK_BOX( hbox ), radioEast, FALSE, FALSE, 1 );
669 gtk_widget_show( radioEast );
671 radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
673 radioWest = gtk_radio_button_new_with_label( radioDirection, "West" );
674 gtk_box_pack_start( GTK_BOX( hbox ), radioWest, FALSE, FALSE, 0 );
675 gtk_widget_show( radioWest );
677 // --------------------------- //
679 hbox = ui::HBox( FALSE, 10 );
680 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
681 gtk_widget_show( hbox );
683 w = ui::Label( "Style:" );
684 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 5 );
685 gtk_widget_show( w );
687 // --------------------------- //
689 hbox = ui::HBox( FALSE, 10 );
690 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
691 gtk_widget_show( hbox );
693 radioOldStyle = gtk_radio_button_new_with_label( NULL, "Original" );
694 gtk_box_pack_start( GTK_BOX( hbox ), radioOldStyle, FALSE, FALSE, 0 );
695 gtk_widget_show( radioOldStyle );
697 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
699 radioBobStyle = gtk_radio_button_new_with_label( radioStyle, "Bob's Style" );
700 gtk_box_pack_start( GTK_BOX( hbox ), radioBobStyle, FALSE, FALSE, 0 );
701 gtk_widget_show( radioBobStyle );
703 radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
705 radioCornerStyle = gtk_radio_button_new_with_label( radioStyle, "Corner Style" );
706 gtk_box_pack_start( GTK_BOX( hbox ), radioCornerStyle, FALSE, FALSE, 0 );
707 gtk_widget_show( radioCornerStyle );
709 // err, the q3r has an if or something so you need bob style checked before this
710 // is "ungreyed out" but you'll need to do that, as i suck :)
712 // djbob: er.... yeah um, im not at all sure how i'm gonna sort this
713 // djbob: think we need some button callback functions or smuffin
714 // FIXME: actually get around to doing what i suggested!!!!
716 checkUseDetail = ui::CheckButton( "Use Detail Brushes" );
717 gtk_box_pack_start( GTK_BOX( hbox ), checkUseDetail, FALSE, FALSE, 0 );
718 gtk_widget_show( checkUseDetail );
720 // --------------------------- //
722 hbox = ui::HBox( FALSE, 10 );
723 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
724 gtk_widget_show( hbox );
726 textMainTex = ui::Entry( 512 );
727 gtk_entry_set_text( GTK_ENTRY( textMainTex ), rs->mainTexture );
728 gtk_box_pack_start( GTK_BOX( hbox ), textMainTex, FALSE, FALSE, 0 );
729 gtk_widget_show( textMainTex );
731 w = ui::Label( "Main Texture" );
732 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
733 gtk_widget_show( w );
735 // -------------------------- //
737 hbox = ui::HBox( FALSE, 10 );
738 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
739 gtk_widget_show( hbox );
741 textRiserTex = ui::Entry( 512 );
742 gtk_box_pack_start( GTK_BOX( hbox ), textRiserTex, FALSE, FALSE, 0 );
743 gtk_widget_show( textRiserTex );
745 w = ui::Label( "Riser Texture" );
746 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
747 gtk_widget_show( w );
749 // -------------------------- //
750 w = ui::Widget(gtk_hseparator_new());
751 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
752 gtk_widget_show( w );
754 hbox = ui::HBox( FALSE, 10 );
755 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
756 gtk_widget_show( hbox );
758 w = ui::Button( "OK" );
759 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
760 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
761 gtk_widget_set_can_default( w, true );
762 gtk_widget_grab_default( w );
763 gtk_widget_show( w );
765 w = ui::Button( "Cancel" );
766 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
767 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
768 gtk_widget_show( w );
772 // +djbob: need our "little" modal loop mars :P
773 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
774 gtk_widget_show( window );
775 gtk_grab_add( window );
777 bool dialogError = TRUE;
778 while ( dialogError )
782 gtk_main_iteration();
786 if ( ret == eIDOK ) {
787 rs->bUseDetail = gtk_toggle_button_get_active( (GtkToggleButton*)checkUseDetail ) ? true : false;
789 strcpy( rs->riserTexture, gtk_entry_get_text( (GtkEntry*)textRiserTex ) );
790 strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)textMainTex ) );
792 if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioNorth ) ) {
793 rs->direction = MOVE_NORTH;
795 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioSouth ) ) {
796 rs->direction = MOVE_SOUTH;
798 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioEast ) ) {
799 rs->direction = MOVE_EAST;
801 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioWest ) ) {
802 rs->direction = MOVE_WEST;
805 if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
809 if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioOldStyle ) ) {
810 rs->style = STYLE_ORIGINAL;
812 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioBobStyle ) ) {
813 rs->style = STYLE_BOB;
815 else if ( gtk_toggle_button_get_active( (GtkToggleButton*)radioCornerStyle ) ) {
816 rs->style = STYLE_CORNER;
821 gtk_grab_remove( window );
827 // there we go, all done ... on my end at least, not bad for a night's work
830 EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
832 GtkWidget *checkScaleMainH, *checkScaleMainV, *checkScaleTrimH, *checkScaleTrimV;
833 GtkWidget *radioNS, *radioEW;
834 GSList *radioOrientation;
836 EMessageBoxReturn ret;
839 auto window = ui::Window( ui::window_type::TOP );
841 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
842 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
844 gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" );
846 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
848 g_object_set_data( G_OBJECT( window ), "loop", &loop );
849 g_object_set_data( G_OBJECT( window ), "ret", &ret );
851 gtk_widget_realize( window );
854 ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
855 ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
856 LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
857 LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
859 auto vbox = ui::VBox( FALSE, 10 );
861 gtk_widget_show( vbox );
863 // -------------------------- //
865 hbox = ui::HBox( FALSE, 10 );
866 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
867 gtk_widget_show( hbox );
869 auto textFrontBackTex = ui::Entry( 512 );
870 gtk_entry_set_text( GTK_ENTRY( textFrontBackTex ), rs->mainTexture );
871 gtk_box_pack_start( GTK_BOX( hbox ), textFrontBackTex, FALSE, FALSE, 0 );
872 gtk_widget_show( textFrontBackTex );
874 ui::Widget w = ui::Label( "Door Front/Back Texture" );
875 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
876 gtk_widget_show( w );
878 // ------------------------ //
880 hbox = ui::HBox( FALSE, 10 );
881 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
882 gtk_widget_show( hbox );
884 auto textTrimTex = ui::Entry( 512 );
885 gtk_box_pack_start( GTK_BOX( hbox ), textTrimTex, FALSE, FALSE, 0 );
886 gtk_widget_show( textTrimTex );
888 w = ui::Label( "Door Trim Texture" );
889 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
890 gtk_widget_show( w );
892 // ----------------------- //
894 hbox = ui::HBox( FALSE, 10 );
895 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
896 gtk_widget_show( hbox );
898 // sp: horizontally ????
899 // djbob: yes mars, u can spell :]
900 checkScaleMainH = ui::CheckButton( "Scale Main Texture Horizontally" );
901 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainH ), TRUE );
902 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainH, FALSE, FALSE, 0 );
903 gtk_widget_show( checkScaleMainH );
905 checkScaleTrimH = ui::CheckButton( "Scale Trim Texture Horizontally" );
906 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ), TRUE );
907 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimH, FALSE, FALSE, 0 );
908 gtk_widget_show( checkScaleTrimH );
910 // ---------------------- //
912 hbox = ui::HBox( FALSE, 10 );
913 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
914 gtk_widget_show( hbox );
916 checkScaleMainV = ui::CheckButton( "Scale Main Texture Vertically" );
917 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( checkScaleMainV ), TRUE );
918 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleMainV, FALSE, FALSE, 0 );
919 gtk_widget_show( checkScaleMainV );
921 checkScaleTrimV = ui::CheckButton( "Scale Trim Texture Vertically" );
922 gtk_box_pack_start( GTK_BOX( hbox ), checkScaleTrimV, FALSE, FALSE, 0 );
923 gtk_widget_show( checkScaleTrimV );
925 // --------------------- //
927 hbox = ui::HBox( FALSE, 10 );
928 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
929 gtk_widget_show( hbox );
931 // djbob: lists added
933 auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures))));
934 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
935 gtk_box_pack_start( GTK_BOX( hbox ), comboMain, FALSE, FALSE, 0 );
936 gtk_widget_show( comboMain );
938 tw1.one = textFrontBackTex;
941 auto buttonSetMain = ui::Button( "Set As Main Texture" );
942 buttonSetMain.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw1 );
943 gtk_box_pack_start( GTK_BOX( hbox ), buttonSetMain, FALSE, FALSE, 0 );
944 gtk_widget_show( buttonSetMain );
946 // ------------------- //
948 hbox = ui::HBox( FALSE, 10 );
949 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
950 gtk_widget_show( hbox );
952 auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures))));
953 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
954 gtk_box_pack_start( GTK_BOX( hbox ), comboTrim, FALSE, FALSE, 0 );
955 gtk_widget_show( comboTrim );
957 tw2.one = textTrimTex;
960 auto buttonSetTrim = ui::Button( "Set As Trim Texture" );
961 buttonSetTrim.connect( "clicked", G_CALLBACK( dialog_button_callback_settex ), &tw2 );
962 gtk_box_pack_start( GTK_BOX( hbox ), buttonSetTrim, FALSE, FALSE, 0 );
963 gtk_widget_show( buttonSetTrim );
965 // ------------------ //
967 hbox = ui::HBox( FALSE, 10 );
968 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
969 gtk_widget_show( hbox );
971 w = ui::Label( "Orientation" );
972 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
973 gtk_widget_show( w );
975 // argh more radio buttons!
976 radioNS = gtk_radio_button_new_with_label( NULL, "North - South" );
977 gtk_box_pack_start( GTK_BOX( hbox ), radioNS, FALSE, FALSE, 0 );
978 gtk_widget_show( radioNS );
980 radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
982 radioEW = gtk_radio_button_new_with_label( radioOrientation, "East - West" );
983 gtk_box_pack_start( GTK_BOX( hbox ), radioEW, FALSE, FALSE, 0 );
984 gtk_widget_show( radioEW );
986 // ----------------- //
988 w = ui::Widget(gtk_hseparator_new());
989 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
990 gtk_widget_show( w );
992 // ----------------- //
994 hbox = ui::HBox( FALSE, 10 );
995 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
996 gtk_widget_show( hbox );
998 w = ui::Button( "OK" );
999 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1000 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1001 gtk_widget_set_can_default( w, true );
1002 gtk_widget_grab_default( w );
1003 gtk_widget_show( w );
1005 w = ui::Button( "Cancel" );
1006 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1007 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1008 gtk_widget_show( w );
1011 // ----------------- //
1014 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1015 gtk_widget_show( window );
1016 gtk_grab_add( window );
1019 gtk_main_iteration();
1021 strcpy( rs->mainTexture, gtk_entry_get_text( GTK_ENTRY( textFrontBackTex ) ) );
1022 strcpy( rs->trimTexture, gtk_entry_get_text( GTK_ENTRY( textTrimTex ) ) );
1024 rs->bScaleMainH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainH ) ) ? true : false;
1025 rs->bScaleMainV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleMainV ) ) ? true : false;
1026 rs->bScaleTrimH = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimH ) ) ? true : false;
1027 rs->bScaleTrimV = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( checkScaleTrimV ) ) ? true : false;
1029 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioNS ) ) ) {
1030 rs->nOrientation = DIRECTION_NS;
1032 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( radioEW ) ) ) {
1033 rs->nOrientation = DIRECTION_EW;
1036 gtk_grab_remove( window );
1043 EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
1044 ui::Widget w{ui::null};
1046 EMessageBoxReturn ret;
1049 auto window = ui::Window( ui::window_type::TOP );
1051 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1052 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1054 gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1055 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1057 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1058 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1060 gtk_widget_realize( window );
1064 auto vbox = ui::VBox( FALSE, 10 );
1066 gtk_widget_show( vbox );
1070 auto hbox = ui::HBox( FALSE, 10 );
1071 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1072 gtk_widget_show( hbox );
1076 auto text1 = ui::Entry( 256 );
1077 gtk_entry_set_text( text1, "25" );
1078 gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 );
1079 gtk_widget_show( text1 );
1081 w = ui::Label( "Number Of Points" );
1082 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1083 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1084 gtk_widget_show( w );
1088 hbox = ui::HBox( FALSE, 10 );
1089 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1090 gtk_widget_show( hbox );
1094 auto text2 = ui::Entry( 256 );
1095 gtk_entry_set_text( text2, "3" );
1096 gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 );
1097 gtk_widget_show( text2 );
1099 w = ui::Label( "Multipler" );
1100 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1101 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1102 gtk_widget_show( w );
1106 w = ui::Label( "Path Distance = dist(start -> apex) * multiplier" );
1107 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1108 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1109 gtk_widget_show( w );
1111 hbox = ui::HBox( FALSE, 10 );
1112 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1113 gtk_widget_show( hbox );
1117 auto text3 = ui::Entry( 256 );
1118 gtk_entry_set_text( text3, "-800" );
1119 gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 );
1120 gtk_widget_show( text3 );
1122 w = ui::Label( "Gravity" );
1123 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1124 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1125 gtk_widget_show( w );
1129 w = ui::Widget(gtk_hseparator_new());
1130 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1131 gtk_widget_show( w );
1133 auto check1 = ui::CheckButton( "No Dynamic Update" );
1134 gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
1135 gtk_widget_show( check1 );
1137 auto check2 = ui::CheckButton( "Show Bounding Lines" );
1138 gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
1139 gtk_widget_show( check2 );
1144 // ----------------- //
1146 w = ui::Widget(gtk_hseparator_new());
1147 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1148 gtk_widget_show( w );
1150 // ----------------- //
1152 hbox = ui::HBox( FALSE, 10 );
1153 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1154 gtk_widget_show( hbox );
1156 w = ui::Button( "Enable" );
1157 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1158 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1159 gtk_widget_show( w );
1161 gtk_widget_set_can_default( w, true );
1162 gtk_widget_grab_default( w );
1164 w = ui::Button( "Disable" );
1165 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1166 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDNO ) );
1167 gtk_widget_show( w );
1169 w = ui::Button( "Cancel" );
1170 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1171 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1172 gtk_widget_show( w );
1176 // ----------------- //
1178 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1179 gtk_widget_show( window );
1180 gtk_grab_add( window );
1182 bool dialogError = TRUE;
1183 while ( dialogError )
1187 gtk_main_iteration();
1189 dialogError = FALSE;
1191 if ( ret == eIDYES ) {
1192 if ( !ValidateTextIntRange( gtk_entry_get_text( GTK_ENTRY( text1 ) ), 1, 200, "Number Of Points", &rs->nPoints ) ) {
1196 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text2 ) ), 1.0f, 10.0f, "Multiplier", &rs->fMultiplier ) ) {
1200 if ( !ValidateTextFloatRange( gtk_entry_get_text( GTK_ENTRY( text3 ) ), -10000.0f, -1.0f, "Gravity", &rs->fGravity ) ) {
1204 rs->bNoUpdate = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check1 ) ) ? true : false;
1205 rs->bShowExtra = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check2 ) ) ? true : false;
1209 gtk_grab_remove( window );
1215 EMessageBoxReturn DoCTFColourChangeBox(){
1216 ui::Widget w{ui::null};
1217 EMessageBoxReturn ret;
1220 auto window = ui::Window( ui::window_type::TOP );
1222 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1223 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1225 gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" );
1226 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1228 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1229 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1231 gtk_widget_realize( window );
1235 auto vbox = ui::VBox( FALSE, 10 );
1237 gtk_widget_show( vbox );
1241 auto hbox = ui::HBox( FALSE, 10 );
1242 gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
1243 gtk_widget_show( hbox );
1245 // ---- hbox ---- ok/cancel buttons
1247 w = ui::Button( "Red->Blue" );
1248 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1249 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1251 gtk_widget_set_can_default( w, true );
1252 gtk_widget_grab_default( w );
1253 gtk_widget_show( w );
1255 w = ui::Button( "Blue->Red" );
1256 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1257 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1258 gtk_widget_show( w );
1260 w = ui::Button( "Cancel" );
1261 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1262 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1263 gtk_widget_show( w );
1270 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1271 gtk_widget_show( window );
1272 gtk_grab_add( window );
1275 gtk_main_iteration();
1277 gtk_grab_remove( window );
1283 EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
1286 ui::Widget w{ui::null};
1288 EMessageBoxReturn ret;
1291 auto window = ui::Window( ui::window_type::TOP );
1293 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1294 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1296 gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
1297 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1299 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1300 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1302 gtk_widget_realize( window );
1304 auto vbox = ui::VBox( FALSE, 10 );
1310 auto hbox = ui::HBox( FALSE, 10 );
1311 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1312 gtk_widget_show( hbox );
1316 texSelected = "Currently Selected Texture: ";
1317 texSelected += GetCurrentTexture();
1319 w = ui::Label( texSelected );
1320 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 2 );
1321 gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
1322 gtk_widget_show( w );
1326 auto frame = ui::Frame( "Reset Texture Names" );
1327 gtk_widget_show( frame );
1328 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1330 auto table = ui::Table( 2, 3, TRUE );
1333 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1334 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1335 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1339 dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
1340 dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1341 gtk_widget_show( dlgTexReset.cbTexChange );
1342 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1,
1343 (GtkAttachOptions) ( GTK_FILL ),
1344 (GtkAttachOptions) ( 0 ), 0, 0 );
1346 w = ui::Label( "Old Name: " );
1347 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1348 (GtkAttachOptions) ( GTK_FILL ),
1349 (GtkAttachOptions) ( 0 ), 0, 0 );
1350 gtk_widget_show( w );
1352 dlgTexReset.editTexOld = ui::Entry( 256 );
1353 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
1354 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1,
1355 (GtkAttachOptions) ( GTK_FILL ),
1356 (GtkAttachOptions) ( 0 ), 0, 0 );
1357 gtk_widget_show( dlgTexReset.editTexOld );
1359 w = ui::Label( "New Name: " );
1360 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1361 (GtkAttachOptions) ( GTK_FILL ),
1362 (GtkAttachOptions) ( 0 ), 0, 0 );
1363 gtk_widget_show( w );
1365 dlgTexReset.editTexNew = ui::Entry( 256 );
1366 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
1367 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2,
1368 (GtkAttachOptions) ( GTK_FILL ),
1369 (GtkAttachOptions) ( 0 ), 0, 0 );
1370 gtk_widget_show( dlgTexReset.editTexNew );
1374 frame = ui::Frame( "Reset Scales" );
1375 gtk_widget_show( frame );
1376 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1378 table = ui::Table( 2, 3, TRUE );
1381 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1382 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1383 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1387 dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
1388 dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1389 gtk_widget_show( dlgTexReset.cbScaleHor );
1390 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1,
1391 (GtkAttachOptions) ( GTK_FILL ),
1392 (GtkAttachOptions) ( 0 ), 0, 0 );
1394 w = ui::Label( "New Horizontal Scale: " );
1395 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1396 (GtkAttachOptions) ( GTK_FILL ),
1397 (GtkAttachOptions) ( 0 ), 0, 0 );
1398 gtk_widget_show( w );
1400 dlgTexReset.editScaleHor = ui::Entry( 256 );
1401 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
1402 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1,
1403 (GtkAttachOptions) ( GTK_FILL ),
1404 (GtkAttachOptions) ( 0 ), 0, 0 );
1405 gtk_widget_show( dlgTexReset.editScaleHor );
1408 dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
1409 dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1410 gtk_widget_show( dlgTexReset.cbScaleVert );
1411 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2,
1412 (GtkAttachOptions) ( GTK_FILL ),
1413 (GtkAttachOptions) ( 0 ), 0, 0 );
1415 w = ui::Label( "New Vertical Scale: " );
1416 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1417 (GtkAttachOptions) ( GTK_FILL ),
1418 (GtkAttachOptions) ( 0 ), 0, 0 );
1419 gtk_widget_show( w );
1421 dlgTexReset.editScaleVert = ui::Entry( 256 );
1422 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
1423 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2,
1424 (GtkAttachOptions) ( GTK_FILL ),
1425 (GtkAttachOptions) ( 0 ), 0, 0 );
1426 gtk_widget_show( dlgTexReset.editScaleVert );
1430 frame = ui::Frame( "Reset Shift" );
1431 gtk_widget_show( frame );
1432 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1434 table = ui::Table( 2, 3, TRUE );
1437 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1438 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1439 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1443 dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
1444 dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1445 gtk_widget_show( dlgTexReset.cbShiftHor );
1446 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1,
1447 (GtkAttachOptions) ( GTK_FILL ),
1448 (GtkAttachOptions) ( 0 ), 0, 0 );
1450 w = ui::Label( "New Horizontal Shift: " );
1451 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1452 (GtkAttachOptions) ( GTK_FILL ),
1453 (GtkAttachOptions) ( 0 ), 0, 0 );
1454 gtk_widget_show( w );
1456 dlgTexReset.editShiftHor = ui::Entry( 256 );
1457 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
1458 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1,
1459 (GtkAttachOptions) ( GTK_FILL ),
1460 (GtkAttachOptions) ( 0 ), 0, 0 );
1461 gtk_widget_show( dlgTexReset.editShiftHor );
1464 dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
1465 dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
1466 gtk_widget_show( dlgTexReset.cbShiftVert );
1467 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2,
1468 (GtkAttachOptions) ( GTK_FILL ),
1469 (GtkAttachOptions) ( 0 ), 0, 0 );
1471 w = ui::Label( "New Vertical Shift: " );
1472 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
1473 (GtkAttachOptions) ( GTK_FILL ),
1474 (GtkAttachOptions) ( 0 ), 0, 0 );
1475 gtk_widget_show( w );
1477 dlgTexReset.editShiftVert = ui::Entry( 256 );
1478 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
1479 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2,
1480 (GtkAttachOptions) ( GTK_FILL ),
1481 (GtkAttachOptions) ( 0 ), 0, 0 );
1482 gtk_widget_show( dlgTexReset.editShiftVert );
1486 frame = ui::Frame( "Reset Rotation" );
1487 gtk_widget_show( frame );
1488 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1490 table = ui::Table( 1, 3, TRUE );
1493 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1494 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1495 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1499 dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
1500 gtk_widget_show( dlgTexReset.cbRotation );
1501 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1,
1502 (GtkAttachOptions) ( GTK_FILL ),
1503 (GtkAttachOptions) ( 0 ), 0, 0 );
1505 w = ui::Label( "New Rotation Value: " );
1506 gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
1507 (GtkAttachOptions) ( GTK_FILL ),
1508 (GtkAttachOptions) ( 0 ), 0, 0 );
1509 gtk_widget_show( w );
1511 dlgTexReset.editRotation = ui::Entry( 256 );
1512 gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
1513 gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1,
1514 (GtkAttachOptions) ( GTK_FILL ),
1515 (GtkAttachOptions) ( 0 ), 0, 0 );
1516 gtk_widget_show( dlgTexReset.editRotation );
1520 hbox = ui::HBox( FALSE, 10 );
1521 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1522 gtk_widget_show( hbox );
1526 w = ui::Button( "Use Selected Brushes" );
1527 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1528 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1530 gtk_widget_set_can_default( w, true );
1531 gtk_widget_grab_default( w );
1532 gtk_widget_show( w );
1534 w = ui::Button( "Use All Brushes" );
1535 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1536 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDYES ) );
1537 gtk_widget_show( w );
1539 w = ui::Button( "Cancel" );
1540 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1541 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1542 gtk_widget_show( w );
1549 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1550 gtk_widget_show( window );
1551 gtk_grab_add( window );
1553 Update_TextureReseter();
1555 bool dialogError = TRUE;
1556 while ( dialogError )
1560 gtk_main_iteration();
1562 dialogError = FALSE;
1564 if ( ret != eIDCANCEL ) {
1565 rs->bResetRotation = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbRotation ) );
1566 if ( rs->bResetRotation ) {
1567 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editRotation ) ), "Rotation", &rs->rotation ) ) {
1572 rs->bResetScale[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleHor ) );
1573 if ( rs->bResetScale[0] ) {
1574 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleHor ) ), "Horizontal Scale", &rs->fScale[0] ) ) {
1579 rs->bResetScale[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbScaleVert ) );
1580 if ( rs->bResetScale[1] ) {
1581 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editScaleVert ) ), "Vertical Scale", &rs->fScale[1] ) ) {
1586 rs->bResetShift[0] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftHor ) );
1587 if ( rs->bResetShift[0] ) {
1588 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftHor ) ), "Horizontal Shift", &rs->fShift[0] ) ) {
1593 rs->bResetShift[1] = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbShiftVert ) );
1594 if ( rs->bResetShift[1] ) {
1595 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editShiftVert ) ), "Vertical Shift", &rs->fShift[1] ) ) {
1600 rs->bResetTextureName = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( dlgTexReset.cbTexChange ) );
1601 if ( rs->bResetTextureName ) {
1602 strcpy( rs->textureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexOld ) ) );
1603 strcpy( rs->newTextureName, gtk_entry_get_text( GTK_ENTRY( dlgTexReset.editTexNew ) ) );
1608 gtk_grab_remove( window );
1614 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
1617 ui::Widget w{ui::null};
1619 ui::Widget radiusX{ui::null}, radiusY{ui::null};
1620 ui::Widget angleStart{ui::null}, angleEnd{ui::null};
1621 ui::Widget heightStart{ui::null}, heightEnd{ui::null};
1622 ui::Widget numPoints{ui::null};
1624 EMessageBoxReturn ret;
1627 auto window = ui::Window( ui::window_type::TOP );
1629 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1630 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1632 gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" );
1633 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1635 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1636 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1638 gtk_widget_realize( window );
1640 auto vbox = ui::VBox( FALSE, 10 );
1646 auto hbox = ui::HBox( FALSE, 10 );
1647 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1648 gtk_widget_show( hbox );
1652 auto frame = ui::Frame( "Radii" );
1653 gtk_widget_show( frame );
1654 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1656 auto table = ui::Table( 2, 3, TRUE );
1659 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1660 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1661 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1665 w = ui::Label( "X: " );
1666 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1667 (GtkAttachOptions) ( GTK_FILL ),
1668 (GtkAttachOptions) ( 0 ), 0, 0 );
1669 gtk_widget_show( w );
1671 radiusX = ui::Entry( 256 );
1672 gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
1673 gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1,
1674 (GtkAttachOptions) ( GTK_FILL ),
1675 (GtkAttachOptions) ( 0 ), 0, 0 );
1676 gtk_widget_show( radiusX );
1680 w = ui::Label( "Y: " );
1681 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1682 (GtkAttachOptions) ( GTK_FILL ),
1683 (GtkAttachOptions) ( 0 ), 0, 0 );
1684 gtk_widget_show( w );
1686 radiusY = ui::Entry( 256 );
1687 gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
1688 gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2,
1689 (GtkAttachOptions) ( GTK_FILL ),
1690 (GtkAttachOptions) ( 0 ), 0, 0 );
1691 gtk_widget_show( radiusY );
1695 frame = ui::Frame( "Angles" );
1696 gtk_widget_show( frame );
1697 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1699 table = ui::Table( 2, 3, TRUE );
1702 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1703 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1704 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1708 w = ui::Label( "Start: " );
1709 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1710 (GtkAttachOptions) ( GTK_FILL ),
1711 (GtkAttachOptions) ( 0 ), 0, 0 );
1712 gtk_widget_show( w );
1714 angleStart = ui::Entry( 256 );
1715 gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
1716 gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1,
1717 (GtkAttachOptions) ( GTK_FILL ),
1718 (GtkAttachOptions) ( 0 ), 0, 0 );
1719 gtk_widget_show( angleStart );
1723 w = ui::Label( "End: " );
1724 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1725 (GtkAttachOptions) ( GTK_FILL ),
1726 (GtkAttachOptions) ( 0 ), 0, 0 );
1727 gtk_widget_show( w );
1729 angleEnd = ui::Entry( 256 );
1730 gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
1731 gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2,
1732 (GtkAttachOptions) ( GTK_FILL ),
1733 (GtkAttachOptions) ( 0 ), 0, 0 );
1734 gtk_widget_show( angleEnd );
1737 frame = ui::Frame( "Height" );
1738 gtk_widget_show( frame );
1739 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1741 table = ui::Table( 2, 3, TRUE );
1744 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1745 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1746 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1750 w = ui::Label( "Start: " );
1751 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1752 (GtkAttachOptions) ( GTK_FILL ),
1753 (GtkAttachOptions) ( 0 ), 0, 0 );
1754 gtk_widget_show( w );
1756 heightStart = ui::Entry( 256 );
1757 gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
1758 gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1,
1759 (GtkAttachOptions) ( GTK_FILL ),
1760 (GtkAttachOptions) ( 0 ), 0, 0 );
1761 gtk_widget_show( heightStart );
1765 w = ui::Label( "End: " );
1766 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
1767 (GtkAttachOptions) ( GTK_FILL ),
1768 (GtkAttachOptions) ( 0 ), 0, 0 );
1769 gtk_widget_show( w );
1771 heightEnd = ui::Entry( 256 );
1772 gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
1773 gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2,
1774 (GtkAttachOptions) ( GTK_FILL ),
1775 (GtkAttachOptions) ( 0 ), 0, 0 );
1776 gtk_widget_show( heightEnd );
1780 frame = ui::Frame( "Points" );
1781 gtk_widget_show( frame );
1782 gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );
1784 table = ui::Table( 2, 3, TRUE );
1787 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1788 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1789 gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1793 w = ui::Label( "Number: " );
1794 gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
1795 (GtkAttachOptions) ( GTK_FILL ),
1796 (GtkAttachOptions) ( 0 ), 0, 0 );
1797 gtk_widget_show( w );
1799 numPoints = ui::Entry( 256 );
1800 gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
1801 gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1,
1802 (GtkAttachOptions) ( GTK_FILL ),
1803 (GtkAttachOptions) ( 0 ), 0, 0 );
1804 gtk_widget_show( numPoints );
1807 hbox = ui::HBox( FALSE, 10 );
1808 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
1809 gtk_widget_show( hbox );
1813 w = ui::Button( "Ok" );
1814 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1815 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1817 gtk_widget_set_can_default( w, true );
1818 gtk_widget_grab_default( w );
1819 gtk_widget_show( w );
1821 w = ui::Button( "Cancel" );
1822 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1823 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1824 gtk_widget_show( w );
1831 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1832 gtk_widget_show( window );
1833 gtk_grab_add( window );
1835 bool dialogError = TRUE;
1836 while ( dialogError )
1840 gtk_main_iteration();
1842 dialogError = FALSE;
1844 if ( ret != eIDCANCEL ) {
1845 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusX ) ), "Radius (X)", &rs->fRadiusX ) ) {
1849 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( radiusY ) ), "Radius (Y)", &rs->fRadiusY ) ) {
1853 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleStart ) ), "Angle (Start)", &rs->fStartAngle ) ) {
1857 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( angleEnd ) ), "Angle (End)", &rs->fEndAngle ) ) {
1861 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightStart ) ), "Height (Start)", &rs->fStartHeight ) ) {
1865 if ( !ValidateTextFloat( gtk_entry_get_text( GTK_ENTRY( heightEnd ) ), "Height (End)", &rs->fEndHeight ) ) {
1869 if ( !ValidateTextInt( gtk_entry_get_text( GTK_ENTRY( numPoints ) ), "Num Points", &rs->iNumPoints ) ) {
1875 gtk_grab_remove( window );
1881 // add a simple input for the MakeChain thing..
1882 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
1883 ui::Widget w{ui::null};
1884 ui::Entry textlinkNum{ui::null}, textlinkName{ui::null};
1885 EMessageBoxReturn ret;
1888 const char *text = "Please set a value in the boxes below and press 'OK' to make a chain";
1890 auto window = ui::Window( ui::window_type::TOP );
1892 window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
1893 window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
1895 gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" );
1897 gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
1899 g_object_set_data( G_OBJECT( window ), "loop", &loop );
1900 g_object_set_data( G_OBJECT( window ), "ret", &ret );
1902 gtk_widget_realize( window );
1905 auto vbox = ui::VBox( FALSE, 10 );
1909 auto hbox = ui::HBox( FALSE, 10 );
1913 // dunno if you want this text or not ...
1914 w = ui::Label( text );
1915 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1916 gtk_widget_show( w );
1918 w = ui::Widget(gtk_hseparator_new());
1919 gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
1920 gtk_widget_show( w );
1922 // ------------------------- //
1925 hbox = ui::HBox( FALSE, 10 );
1926 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1927 gtk_widget_show( hbox );
1929 textlinkNum = ui::Entry( 256 );
1930 gtk_box_pack_start( GTK_BOX( hbox ), textlinkNum, FALSE, FALSE, 1 );
1931 gtk_widget_show( textlinkNum );
1933 w = ui::Label( "Number of elements in chain" );
1934 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1935 gtk_widget_show( w );
1937 // -------------------------- //
1939 hbox = ui::HBox( FALSE, 10 );
1940 gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1941 gtk_widget_show( hbox );
1943 textlinkName = ui::Entry( 256 );
1944 gtk_box_pack_start( GTK_BOX( hbox ), textlinkName, FALSE, FALSE, 0 );
1945 gtk_widget_show( textlinkName );
1947 w = ui::Label( "Basename for chain's targetnames." );
1948 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 1 );
1949 gtk_widget_show( w );
1952 w = ui::Button( "OK" );
1953 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1954 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDOK ) );
1955 gtk_widget_set_can_default( w, true );
1956 gtk_widget_grab_default( w );
1957 gtk_widget_show( w );
1959 w = ui::Button( "Cancel" );
1960 gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1961 w.connect( "clicked", G_CALLBACK( dialog_button_callback ), GINT_TO_POINTER( eIDCANCEL ) );
1962 gtk_widget_show( w );
1966 gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
1967 gtk_widget_show( window );
1968 gtk_grab_add( window );
1970 bool dialogError = TRUE;
1971 while ( dialogError )
1975 gtk_main_iteration();
1977 dialogError = FALSE;
1979 if ( ret == eIDOK ) {
1980 strcpy( rs->linkName, gtk_entry_get_text( textlinkName ) );
1981 if ( !ValidateTextInt( gtk_entry_get_text( textlinkNum ), "Elements", &rs->linkNum ) ) {
1987 gtk_grab_remove( window );