diff --git a/libs/picomodel/pm_obj.c b/libs/picomodel/pm_obj.c index 0f22df3a..baa9d97d 100644 --- a/libs/picomodel/pm_obj.c +++ b/libs/picomodel/pm_obj.c @@ -49,7 +49,6 @@ * - '_obj_load' code crashes in a weird way after * '_obj_mtl_load' for a few .mtl files * - process 'mtllib' rather than using .mtl - * - handle 'usemtl' statements */ /* uncomment when debugging this module */ /* #define DEBUG_PM_OBJ */ @@ -859,6 +858,22 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){ /* increase vertex count */ curVertex += max; } + + } + else if ( !_pico_stricmp( p->token, "usemtl" ) ) { + char *materialName; + materialName = _pico_parse( p, 0 ); + if( materialName || strlen( materialName ) ) { + picoShader_t *shader; + shader = PicoFindShader( model, materialName, 0 ); + if( !shader ) { + shader = PicoNewShader( model ); + PicoSetShaderName( shader, materialName ); + } + if( shader && curSurface ) { + PicoSetSurfaceShader( curSurface, shader ); + } + } } /* skip unparsed rest of line and continue */ _pico_parse_skip_rest( p ); diff --git a/plugins/surface/surfacedialog.cpp b/plugins/surface/surfacedialog.cpp index 0fd4ebe0..b59843c8 100644 --- a/plugins/surface/surfacedialog.cpp +++ b/plugins/surface/surfacedialog.cpp @@ -627,21 +627,17 @@ GtkWidget* create_SurfaceInspector( void ){ GtkWidget *label; - GtkWidget *viewport9; - GtkWidget *viewport2; - GtkWidget *viewport4; - GtkWidget *viewport7; - GtkWidget *viewport5; + GtkWidget *viewport; - GtkWidget *table1; + GtkWidget *table1, *table3; GtkWidget *table4; GtkWidget *table5; - GtkWidget *vbox7; + GtkWidget *content_area; - GtkWidget *hbox1, *hbox2; + GtkWidget *hbox1, *hbox2, *hbox3; - GtkSizeGroup *button_group; + GtkSizeGroup *size_group; SurfaceInspector = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_container_set_border_width( GTK_CONTAINER( SurfaceInspector ), 4 ); @@ -649,20 +645,22 @@ GtkWidget* create_SurfaceInspector( void ){ SetWinPos_from_Prefs( SurfaceInspector ); - vbox7 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_container_add( GTK_CONTAINER( SurfaceInspector ), vbox7 ); - gtk_widget_show( vbox7 ); + content_area = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); + gtk_container_add( GTK_CONTAINER( SurfaceInspector ), content_area ); + gtk_widget_show( content_area ); - viewport9 = gtk_frame_new( NULL ); - gtk_box_pack_start( GTK_BOX( vbox7 ), viewport9, FALSE, FALSE, 0 ); - gtk_container_set_border_width( GTK_CONTAINER( viewport9 ), 2 ); - gtk_frame_set_shadow_type( GTK_FRAME( viewport9 ), GTK_SHADOW_ETCHED_IN ); - gtk_widget_show( viewport9 ); + viewport = gtk_frame_new( NULL ); + gtk_frame_set_shadow_type( GTK_FRAME( viewport ), GTK_SHADOW_ETCHED_IN ); + gtk_box_pack_start( GTK_BOX( content_area ), viewport, FALSE, FALSE, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( viewport ), 2 ); + gtk_widget_set_hexpand( viewport, TRUE ); + gtk_widget_set_vexpand( viewport, FALSE ); + gtk_widget_show( viewport ); hbox1 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_widget_show( hbox1 ); - gtk_container_add( GTK_CONTAINER( viewport9 ), hbox1 ); + gtk_container_add( GTK_CONTAINER( viewport ), hbox1 ); gtk_container_set_border_width( GTK_CONTAINER( hbox1 ), 4 ); + gtk_widget_show( hbox1 ); label = gtk_label_new( _( "Texture: " ) ); gtk_box_pack_start( GTK_BOX( hbox1 ), label, FALSE, FALSE, 0 ); @@ -677,18 +675,21 @@ GtkWidget* create_SurfaceInspector( void ){ gtk_entry_set_max_length( GTK_ENTRY( texture_combo_entry ), 128 ); gtk_widget_show( texture_combo_entry ); - viewport2 = gtk_frame_new( NULL ); - gtk_box_pack_start( GTK_BOX( vbox7 ), viewport2, TRUE, TRUE, 0 ); - gtk_container_set_border_width( GTK_CONTAINER( viewport2 ), 2 ); - gtk_frame_set_shadow_type( GTK_FRAME( viewport2 ), GTK_SHADOW_ETCHED_IN ); - gtk_widget_show( viewport2 ); + viewport = gtk_frame_new( NULL ); + gtk_frame_set_shadow_type( GTK_FRAME( viewport ), GTK_SHADOW_ETCHED_IN ); + gtk_box_pack_start( GTK_BOX( content_area ), viewport, FALSE, TRUE, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( viewport ), 2 ); + gtk_widget_set_hexpand( viewport, TRUE ); + gtk_widget_set_vexpand( viewport, TRUE ); + gtk_widget_show( viewport ); table1 = gtk_grid_new(); gtk_widget_set_hexpand( table1, TRUE ); gtk_widget_set_vexpand( table1, TRUE ); gtk_grid_set_column_spacing( GTK_GRID( table1 ), 5 ); - gtk_container_add( GTK_CONTAINER( viewport2 ), table1 ); + gtk_container_add( GTK_CONTAINER( viewport ), table1 ); gtk_container_set_border_width( GTK_CONTAINER( table1 ), 5 ); + gtk_widget_set_hexpand( GTK_WIDGET( table1 ), TRUE ); gtk_widget_show( table1 ); label = gtk_label_new( _( "Value" ) ); @@ -734,50 +735,50 @@ GtkWidget* create_SurfaceInspector( void ){ // Value Spins hshift_value_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); hshift_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hshift_value_spinbutton_adj ), 1, 2 ); - gtk_widget_set_hexpand( hshift_value_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), hshift_value_spinbutton, 1, 1, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hshift_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hshift_value_spinbutton ), TRUE ); + gtk_widget_set_hexpand( hshift_value_spinbutton, TRUE ); gtk_widget_set_sensitive( GTK_WIDGET( hshift_value_spinbutton ), TRUE ); gtk_widget_show( hshift_value_spinbutton ); g_object_set( hshift_value_spinbutton, "xalign", 1.0, NULL ); vshift_value_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); vshift_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vshift_value_spinbutton_adj ), 1, 2 ); - gtk_widget_set_hexpand( vshift_value_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), vshift_value_spinbutton, 1, 2, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vshift_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( vshift_value_spinbutton ), TRUE ); + gtk_widget_set_hexpand( vshift_value_spinbutton, TRUE ); gtk_widget_set_sensitive( GTK_WIDGET( vshift_value_spinbutton ), TRUE ); gtk_widget_show( vshift_value_spinbutton ); g_object_set( vshift_value_spinbutton, "xalign", 1.0, NULL ); hscale_value_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); hscale_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hscale_value_spinbutton_adj ), 1, 4 ); - gtk_widget_set_hexpand( hscale_value_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), hscale_value_spinbutton, 1, 3, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hscale_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hscale_value_spinbutton ), TRUE ); + gtk_widget_set_hexpand( hscale_value_spinbutton, TRUE ); gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), TRUE ); gtk_widget_show( hscale_value_spinbutton ); g_object_set( hscale_value_spinbutton, "xalign", 1.0, NULL ); vscale_value_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); vscale_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vscale_value_spinbutton_adj ), 1, 4 ); - gtk_widget_set_hexpand( vscale_value_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), vscale_value_spinbutton, 1, 4, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vscale_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( vscale_value_spinbutton ), TRUE ); + gtk_widget_set_hexpand( vscale_value_spinbutton, TRUE ); gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), TRUE ); gtk_widget_show( vscale_value_spinbutton ); g_object_set( vscale_value_spinbutton, "xalign", 1.0, NULL ); rotate_value_spinbutton_adj = gtk_adjustment_new( 0.0, -360.0, 360.0, 1.0, 10.0, 0.0 ); rotate_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( rotate_value_spinbutton_adj ), 1, 4 ); - gtk_widget_set_hexpand( rotate_value_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), rotate_value_spinbutton, 1, 5, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( rotate_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( rotate_value_spinbutton ), TRUE ); + gtk_widget_set_hexpand( rotate_value_spinbutton, TRUE ); gtk_widget_set_sensitive( GTK_WIDGET( rotate_value_spinbutton ), TRUE ); gtk_widget_show( rotate_value_spinbutton ); g_object_set( rotate_value_spinbutton, "xalign", 1.0, NULL ); @@ -785,125 +786,166 @@ GtkWidget* create_SurfaceInspector( void ){ // Step Spins hshift_step_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); hshift_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hshift_step_spinbutton_adj ), 1, 2 ); - gtk_widget_set_hexpand( hshift_step_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), hshift_step_spinbutton, 2, 1, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hshift_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_widget_set_hexpand( hshift_step_spinbutton, TRUE ); gtk_widget_show( hshift_step_spinbutton ); g_object_set( hshift_step_spinbutton, "xalign", 1.0, NULL ); vshift_step_spinbutton_adj = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); vshift_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vshift_step_spinbutton_adj ), 1, 2 ); - gtk_widget_set_hexpand( vshift_step_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), vshift_step_spinbutton, 2, 2, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vshift_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_widget_set_hexpand( vshift_step_spinbutton, TRUE ); gtk_widget_show( vshift_step_spinbutton ); g_object_set( vshift_step_spinbutton, "xalign", 1.0, NULL ); hscale_step_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); hscale_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( hscale_step_spinbutton_adj ), 1, 4 ); - gtk_widget_set_hexpand( hscale_step_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), hscale_step_spinbutton, 2, 3, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hscale_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_widget_set_hexpand( hscale_step_spinbutton, TRUE ); gtk_widget_show( hscale_step_spinbutton ); g_object_set( hscale_step_spinbutton, "xalign", 1.0, NULL ); vscale_step_spinbutton_adj = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); vscale_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( vscale_step_spinbutton_adj ), 1, 4 ); - gtk_widget_set_hexpand( vscale_step_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), vscale_step_spinbutton, 2, 4, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vscale_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_widget_set_hexpand( vscale_step_spinbutton, TRUE ); gtk_widget_show( vscale_step_spinbutton ); g_object_set( vscale_step_spinbutton, "xalign", 1.0, NULL ); rotate_step_spinbutton_adj = gtk_adjustment_new( 0.0, -360.0, 360.0, 1.0, 10.0, 0.0 ); rotate_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( rotate_step_spinbutton_adj ), 1, 4 ); - gtk_widget_set_hexpand( rotate_step_spinbutton, TRUE ); gtk_grid_attach( GTK_GRID( table1 ), rotate_step_spinbutton, 2, 5, 1, 1 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( rotate_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_widget_set_hexpand( rotate_step_spinbutton, TRUE ); gtk_widget_show( rotate_step_spinbutton ); g_object_set( rotate_step_spinbutton, "xalign", 1.0, NULL ); - viewport7 = gtk_frame_new( NULL ); - gtk_box_pack_start( GTK_BOX( vbox7 ), viewport7, TRUE, TRUE, 0 ); - gtk_container_set_border_width( GTK_CONTAINER( viewport7 ), 2 ); - gtk_frame_set_shadow_type( GTK_FRAME( viewport7 ), GTK_SHADOW_ETCHED_IN ); - gtk_widget_show( viewport7 ); + viewport = gtk_frame_new( NULL ); + gtk_frame_set_shadow_type( GTK_FRAME( viewport ), GTK_SHADOW_ETCHED_IN ); + gtk_box_pack_start( GTK_BOX( content_area ), viewport, FALSE, TRUE, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( viewport ), 2 ); + gtk_widget_set_hexpand( viewport, TRUE ); + gtk_widget_set_vexpand( viewport, FALSE ); + gtk_widget_show( viewport ); hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_container_add( GTK_CONTAINER( viewport7 ), hbox2 ); + gtk_container_add( GTK_CONTAINER( viewport ), hbox2 ); gtk_container_set_border_width( GTK_CONTAINER( hbox2 ), 4 ); + gtk_widget_set_hexpand( hbox2, TRUE ); + gtk_widget_set_vexpand( hbox2, FALSE ); gtk_widget_show( hbox2 ); - viewport4 = gtk_frame_new( NULL ); //only need this for layout - gtk_container_add( GTK_CONTAINER( hbox2 ), viewport4 ); - gtk_container_set_border_width( GTK_CONTAINER( viewport4 ), 6 ); - gtk_frame_set_shadow_type( GTK_FRAME( viewport4 ), GTK_SHADOW_NONE ); - gtk_widget_show( viewport4 ); + viewport = gtk_frame_new( NULL ); //only need this for layout + gtk_frame_set_shadow_type( GTK_FRAME( viewport ), GTK_SHADOW_NONE ); + gtk_container_add( GTK_CONTAINER( hbox2 ), viewport ); + gtk_container_set_border_width( GTK_CONTAINER( viewport ), 6 ); + gtk_widget_set_hexpand( viewport, TRUE ); + gtk_widget_set_vexpand( viewport, FALSE ); + gtk_widget_show( viewport ); table4 = gtk_grid_new(); //only need this for layout - gtk_container_add( GTK_CONTAINER( viewport4 ), table4 ); - gtk_container_set_border_width( GTK_CONTAINER( table4 ), 5 ); + gtk_grid_set_row_homogeneous( GTK_GRID( table4 ), TRUE ); gtk_grid_set_column_spacing( GTK_GRID( table4 ), 2 ); + gtk_container_add( GTK_CONTAINER( viewport ), table4 ); + gtk_container_set_border_width( GTK_CONTAINER( table4 ), 5 ); + gtk_widget_set_hexpand( table4, TRUE ); gtk_widget_show( table4 ); label = gtk_label_new( "" ); //only need this for layout - gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_grid_attach( GTK_GRID( table4 ), label, 0, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); axial_button = gtk_button_new_with_mnemonic( _( "Axial" ) ); gtk_grid_attach( GTK_GRID( table4 ), axial_button, 0, 1, 1, 1 ); + gtk_widget_set_hexpand( axial_button, TRUE ); gtk_widget_show( axial_button ); - viewport5 = gtk_frame_new( NULL ); - gtk_box_pack_start( GTK_BOX( hbox2 ), viewport5, FALSE, FALSE, 0 ); - gtk_container_set_border_width( GTK_CONTAINER( viewport5 ), 6 ); - gtk_frame_set_shadow_type( GTK_FRAME( viewport5 ), GTK_SHADOW_ETCHED_OUT ); - gtk_widget_show( viewport5 ); + viewport = gtk_frame_new( NULL ); + gtk_frame_set_shadow_type( GTK_FRAME( viewport ), GTK_SHADOW_ETCHED_OUT ); + gtk_box_pack_start( GTK_BOX( hbox2 ), viewport, FALSE, TRUE, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( viewport ), 6 ); + gtk_widget_set_hexpand( viewport, TRUE ); + gtk_widget_set_vexpand( viewport, FALSE ); + gtk_widget_show( viewport ); - table5 = gtk_grid_new(); - gtk_container_add( GTK_CONTAINER( viewport5 ), table5 ); - gtk_container_set_border_width( GTK_CONTAINER( table5 ), 5 ); - gtk_grid_set_column_spacing( GTK_GRID( table5 ), 2 ); - gtk_widget_show( table5 ); + hbox3 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); + gtk_container_add( GTK_CONTAINER( viewport ), hbox3 ); + gtk_widget_set_hexpand( hbox3, TRUE ); + gtk_widget_set_vexpand( hbox3, FALSE ); + gtk_widget_show( hbox3 ); - label = gtk_label_new( _( "Height" ) ); + table3 = gtk_grid_new(); //only need this for layout + gtk_grid_set_row_homogeneous( GTK_GRID( table3 ), TRUE ); + gtk_grid_set_column_spacing( GTK_GRID( table3 ), 2 ); + gtk_container_add( GTK_CONTAINER( hbox3 ), table3 ); + gtk_container_set_border_width( GTK_CONTAINER( table3 ), 5 ); + gtk_widget_set_hexpand( table3, TRUE ); + gtk_widget_show( table3 ); + + label = gtk_label_new( "" ); //only need this for layout + gtk_grid_attach( GTK_GRID( table3 ), label, 0, 0, 1, 1 ); gtk_widget_set_halign( label, GTK_ALIGN_START ); - gtk_grid_attach( GTK_GRID( table5 ), label, 1, 0, 1, 1 ); - gtk_widget_show( label ); - - label = gtk_label_new( _( "Width" ) ); - gtk_widget_set_halign( label, GTK_ALIGN_START ); - gtk_grid_attach( GTK_GRID( table5 ), label, 2, 0, 1, 1 ); gtk_widget_show( label ); fit_button = gtk_button_new_with_mnemonic( _( "Fit" ) ); - gtk_grid_attach( GTK_GRID( table5 ), fit_button, 0, 1, 1, 1 ); + gtk_grid_attach( GTK_GRID( table3 ), fit_button, 0, 1, 2, 1 ); + gtk_widget_set_hexpand( fit_button, TRUE ); gtk_widget_show( fit_button ); + table5 = gtk_grid_new(); + gtk_grid_set_column_spacing( GTK_GRID( table5 ), 2 ); + gtk_grid_set_row_homogeneous( GTK_GRID( table5 ), TRUE ); + gtk_box_pack_start( GTK_BOX( hbox3 ), table5, FALSE, TRUE, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( table5 ), 5 ); + gtk_widget_set_hexpand( table5, TRUE ); + gtk_widget_show( table5 ); + + label = gtk_label_new( _( "Height" ) ); + gtk_grid_attach( GTK_GRID( table5 ), label, 1, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); + + label = gtk_label_new( _( "Width" ) ); + gtk_grid_attach( GTK_GRID( table5 ), label, 0, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); + fit_width_spinbutton_adj = gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ); fit_width_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( fit_width_spinbutton_adj ), 1, 0 ); - gtk_grid_attach( GTK_GRID( table5 ), fit_width_spinbutton, 1, 1, 1, 1 ); + gtk_grid_attach( GTK_GRID( table5 ), fit_width_spinbutton, 0, 1, 1, 1 ); gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( fit_width_spinbutton ), TRUE ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( fit_width_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_widget_set_hexpand( fit_width_spinbutton, TRUE ); gtk_widget_show( fit_width_spinbutton ); g_object_set( fit_width_spinbutton, "xalign", 1.0, NULL ); fit_height_spinbutton_adj = gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ); fit_height_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( fit_height_spinbutton_adj ), 1, 0 ); - gtk_grid_attach( GTK_GRID( table5 ), fit_height_spinbutton, 2, 1, 1, 1 ); + gtk_grid_attach( GTK_GRID( table5 ), fit_height_spinbutton, 1, 1, 1, 1 ); gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( fit_height_spinbutton ), TRUE ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( fit_height_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_widget_set_hexpand( fit_height_spinbutton, TRUE ); gtk_widget_show( fit_height_spinbutton ); g_object_set( fit_height_spinbutton, "xalign", 1.0, NULL ); - button_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); - gtk_size_group_add_widget( button_group, axial_button ); - gtk_size_group_add_widget( button_group, fit_button ); - g_object_unref( button_group ); + size_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); + gtk_size_group_add_widget( size_group, axial_button ); + gtk_size_group_add_widget( size_group, fit_button ); + g_object_unref( size_group ); + size_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); + gtk_size_group_add_widget( size_group, table3 ); + gtk_size_group_add_widget( size_group, table4 ); + g_object_unref( size_group ); + + // closing the window (upper right window manager click) g_signal_connect( (gpointer) SurfaceInspector, diff --git a/plugins/surface_idtech2/surfacedialog.cpp b/plugins/surface_idtech2/surfacedialog.cpp index 6ceaa5de..0207188f 100644 --- a/plugins/surface_idtech2/surfacedialog.cpp +++ b/plugins/surface_idtech2/surfacedialog.cpp @@ -543,16 +543,16 @@ GtkWidget* create_SurfaceInspector( void ){ GtkWidget *label; GtkAdjustment *adjustment; - + GtkSizeGroup *size_group; GtkWidget *table1; GtkWidget *table2; GtkWidget *frame1; GtkWidget *frame2; - + GtkWidget *vbox1; GtkWidget *hbox1; - + SurfaceInspector = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_container_set_border_width( GTK_CONTAINER( SurfaceInspector ), 4 ); gtk_window_set_title( GTK_WINDOW( SurfaceInspector ), "Surface Inspector" ); @@ -560,234 +560,228 @@ GtkWidget* create_SurfaceInspector( void ){ SetWinPos_from_Prefs( SurfaceInspector ); vbox1 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); - gtk_widget_show( vbox1 ); gtk_container_add( GTK_CONTAINER( SurfaceInspector ), vbox1 ); + gtk_widget_show( vbox1 ); hbox1 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); - gtk_widget_show( hbox1 ); gtk_container_add( GTK_CONTAINER( vbox1 ), hbox1 ); gtk_container_set_border_width( GTK_CONTAINER( hbox1 ), 4 ); + gtk_widget_show( hbox1 ); label = gtk_label_new( "Texture: " ); - gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox1 ), label, FALSE, FALSE, 0 ); - gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); texture_combo = gtk_combo_box_text_new(); + //gtk_combo_disable_activate( GTK_COMBO_BOX( GTK_COMBO_BOX_TEXT( texture_combo ) ); + gtk_box_pack_start( GTK_BOX( hbox1 ), texture_combo, TRUE, TRUE, 0 ); + gtk_widget_show( texture_combo ); g_object_set_data( G_OBJECT( gtk_combo_box_get_popup_accessible( GTK_COMBO_BOX( GTK_COMBO_BOX_TEXT(texture_combo ) ) ) ), "KeepMeAround", texture_combo ); - //gtk_combo_disable_activate( GTK_COMBO_BOX( GTK_COMBO_BOX_TEXT( texture_combo ) ); - gtk_widget_show( texture_combo ); - gtk_box_pack_start( GTK_BOX( hbox1 ), texture_combo, TRUE, TRUE, 0 ); texture_combo_entry = gtk_bin_get_child( GTK_BIN( texture_combo ) ); - gtk_widget_show( texture_combo_entry ); gtk_entry_set_max_length( GTK_ENTRY( texture_combo_entry ), 1024 ); + gtk_widget_show( texture_combo_entry ); frame1 = gtk_frame_new( "Surface" ); - gtk_widget_show( frame1 ); gtk_container_add( GTK_CONTAINER( vbox1 ), frame1 ); + gtk_widget_show( frame1 ); - table1 = gtk_table_new( 7, 3, FALSE ); - gtk_widget_show( table1 ); - gtk_table_set_col_spacings( GTK_TABLE( table1 ), 5 ); - gtk_table_set_row_spacings( GTK_TABLE( table1 ), 5 ); + table1 = gtk_grid_new(); + gtk_grid_set_row_spacing( GTK_GRID( table1 ), 5 ); + gtk_grid_set_column_spacing( GTK_GRID( table1 ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table1 ), 5 ); gtk_container_add( GTK_CONTAINER( frame1 ), table1 ); - - label = gtk_label_new( "Step" ); - gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table1 ), label, 2, 3, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + gtk_widget_set_hexpand( GTK_WIDGET( table1 ), TRUE ); + gtk_widget_show( table1 ); label = gtk_label_new( "Value" ); + gtk_grid_attach( GTK_GRID( table1 ), label, 1, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); + + label = gtk_label_new( "Step" ); + gtk_grid_attach( GTK_GRID( table1 ), label, 2, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table1 ), label, 1, 2, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_misc_set_alignment( GTK_MISC( label ), 0.5, 1 ); label = gtk_label_new( "Horizontal shift: " ); + gtk_grid_attach( GTK_GRID( table1 ), label, 0, 1, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table1 ), label, 0, 1, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); label = gtk_label_new( "Vertical shift: " ); + gtk_grid_attach( GTK_GRID( table1 ), label, 0, 2, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table1 ), label, 0, 1, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); label = gtk_label_new( "Horizontal scale: " ); + gtk_grid_attach( GTK_GRID( table1 ), label, 0, 3, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table1 ), label, 0, 1, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); label = gtk_label_new( "Vertical scale: " ); + gtk_grid_attach( GTK_GRID( table1 ), label, 0, 4, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table1 ), label, 0, 1, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); label = gtk_label_new( "Rotate: " ); + gtk_grid_attach( GTK_GRID( table1 ), label, 0, 5, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table1 ), label, 0, 1, 5, 6, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); // Value Spins adjustment = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); hshift_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 2 ); - gtk_widget_show( hshift_value_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), hshift_value_spinbutton, 1, 2, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hshift_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hshift_value_spinbutton ), TRUE ); + gtk_grid_attach( GTK_GRID( table1 ), hshift_value_spinbutton, 1, 1, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( hshift_value_spinbutton ), TRUE ); + gtk_widget_show( hshift_value_spinbutton ); + g_object_set( hshift_value_spinbutton, "xalign", 1.0, NULL ); + adjustment = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); vshift_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 2 ); - gtk_widget_show( vshift_value_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), vshift_value_spinbutton, 1, 2, 2, 3, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vshift_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( vshift_value_spinbutton ), TRUE ); + gtk_grid_attach( GTK_GRID( table1 ), vshift_value_spinbutton, 1, 2, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( vshift_value_spinbutton ), TRUE ); + gtk_widget_show( vshift_value_spinbutton ); + g_object_set( vshift_value_spinbutton, "xalign", 1.0, NULL ); adjustment = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); hscale_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 4 ); - gtk_widget_show( hscale_value_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), hscale_value_spinbutton, 1, 2, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hscale_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( hscale_value_spinbutton ), TRUE ); + gtk_grid_attach( GTK_GRID( table1 ), hscale_value_spinbutton, 1, 3, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( hscale_value_spinbutton ), TRUE ); + gtk_widget_show( hscale_value_spinbutton ); + g_object_set( hscale_value_spinbutton, "xalign", 1.0, NULL ); adjustment = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); vscale_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 4 ); - gtk_widget_show( vscale_value_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), vscale_value_spinbutton, 1, 2, 4, 5, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vscale_value_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table1 ), vscale_value_spinbutton, 1, 4, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( vscale_value_spinbutton ), TRUE ); + gtk_widget_show( vscale_value_spinbutton ); + g_object_set( vscale_value_spinbutton, "xalign", 1.0, NULL ); adjustment = gtk_adjustment_new( 0.0, -360.0, 360.0, 1.0, 10.0, 0.0 ); rotate_value_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 2 ); - gtk_widget_show( rotate_value_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), rotate_value_spinbutton, 1, 2, 5, 6, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( rotate_value_spinbutton ), GTK_UPDATE_IF_VALID ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( rotate_value_spinbutton ), TRUE ); + gtk_grid_attach( GTK_GRID( table1 ), rotate_value_spinbutton, 1, 5, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( rotate_value_spinbutton ), TRUE ); + gtk_widget_show( rotate_value_spinbutton ); + g_object_set( rotate_value_spinbutton, "xalign", 1.0, NULL ); // Step Spins adjustment = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); hshift_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 2 ); - gtk_widget_show( hshift_step_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), hshift_step_spinbutton, 2, 3, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hshift_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table1 ), hshift_step_spinbutton, 2, 1, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( hshift_step_spinbutton ), TRUE ); + gtk_widget_show( hshift_step_spinbutton ); + g_object_set( hshift_step_spinbutton, "xalign", 1.0, NULL ); adjustment = gtk_adjustment_new( 0.0, -8192.0, 8192.0, 2.0, 8.0, 0.0 ); vshift_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 2 ); - gtk_widget_show( vshift_step_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), vshift_step_spinbutton, 2, 3, 2, 3, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vshift_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table1 ), vshift_step_spinbutton, 2, 2, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( vshift_step_spinbutton ), TRUE ); + gtk_widget_show( vshift_step_spinbutton ); + g_object_set( vshift_step_spinbutton, "xalign", 1.0, NULL ); adjustment = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); hscale_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 4 ); - gtk_widget_show( hscale_step_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), hscale_step_spinbutton, 2, 3, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( hscale_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table1 ), hscale_step_spinbutton, 2, 3, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( hscale_step_spinbutton ), TRUE ); + gtk_widget_show( hscale_step_spinbutton ); + g_object_set( hscale_step_spinbutton, "xalign", 1.0, NULL ); adjustment = gtk_adjustment_new( 0.0, -1024.0, 1024.0, 1.0, 4.0, 0.0 ); vscale_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 4 ); - gtk_widget_show( vscale_step_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), vscale_step_spinbutton, 2, 3, 4, 5, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( vscale_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table1 ), vscale_step_spinbutton, 2, 4, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( vscale_step_spinbutton ), TRUE ); + gtk_widget_show( vscale_step_spinbutton ); + g_object_set( vscale_step_spinbutton, "xalign", 1.0, NULL ); adjustment = gtk_adjustment_new( 0.0, -360.0, 360.0, 1.0, 10.0, 0.0 ); rotate_step_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 2 ); - gtk_widget_show( rotate_step_spinbutton ); - gtk_table_attach( GTK_TABLE( table1 ), rotate_step_spinbutton, 2, 3, 5, 6, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( rotate_step_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table1 ), rotate_step_spinbutton, 2, 5, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( rotate_step_spinbutton ), TRUE ); + gtk_widget_show( rotate_step_spinbutton ); + g_object_set( rotate_step_spinbutton, "xalign", 1.0, NULL ); match_grid_button = gtk_button_new_with_mnemonic( "Match Grid" ); + gtk_grid_attach( GTK_GRID( table1 ), match_grid_button, 2, 6, 1, 1 ); gtk_widget_show( match_grid_button ); - gtk_table_attach( GTK_TABLE( table1 ), match_grid_button, 2, 3, 6, 7, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); frame2 = gtk_frame_new( "Tools" ); - gtk_widget_show( frame2 ); gtk_container_add( GTK_CONTAINER( vbox1 ), frame2 ); + gtk_widget_show( frame2 ); - table2 = gtk_table_new( 2, 4, TRUE ); - gtk_widget_show( table2 ); - gtk_table_set_col_spacings( GTK_TABLE( table2), 5 ); - gtk_table_set_row_spacings( GTK_TABLE( table2 ), 0 ); - gtk_container_set_border_width( GTK_CONTAINER( table2 ), 5 ); + table2 = gtk_grid_new(); + gtk_grid_set_row_spacing( GTK_GRID( table2 ), 5 ); + gtk_grid_set_column_spacing( GTK_GRID( table2 ), 5 ); gtk_container_add( GTK_CONTAINER( frame2 ), table2 ); - - label = gtk_label_new( "Height" ); - gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table2 ), label, 3, 4, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - - label = gtk_label_new( "Width" ); - gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table2 ), label, 2, 3, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( table2 ), 5 ); + gtk_widget_set_hexpand( GTK_WIDGET( table2 ), TRUE ); + gtk_widget_show( table2 ); label = gtk_label_new( "Brush" ); + gtk_grid_attach( GTK_GRID( table2 ), label, 0, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_set_hexpand( GTK_WIDGET( label ), TRUE ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table2 ), label, 0, 2, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - adjustment = gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ); - fit_height_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 0 ); - gtk_widget_show( fit_height_spinbutton ); - gtk_table_attach( GTK_TABLE( table2 ), fit_height_spinbutton, 3, 4, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( fit_height_spinbutton ), TRUE ); - gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( fit_height_spinbutton ), GTK_UPDATE_IF_VALID ); + label = gtk_label_new( "Height" ); + gtk_grid_attach( GTK_GRID( table2 ), label, 2, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_set_hexpand( GTK_WIDGET( label ), TRUE ); + gtk_widget_show( label ); + + label = gtk_label_new( "Width" ); + gtk_grid_attach( GTK_GRID( table2 ), label, 3, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_set_hexpand( GTK_WIDGET( label ), TRUE ); + gtk_widget_show( label ); adjustment = gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ); fit_width_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 0 ); - gtk_widget_show( fit_width_spinbutton ); - gtk_table_attach( GTK_TABLE( table2 ), fit_width_spinbutton, 2, 3, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( fit_width_spinbutton ), TRUE ); gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( fit_width_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table2 ), fit_width_spinbutton, 2, 1, 1, 1 ); + gtk_widget_show( fit_width_spinbutton ); + g_object_set( fit_width_spinbutton, "xalign", 1.0, NULL ); + + adjustment = gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ); + fit_height_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT( adjustment ), 1, 0 ); + gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( fit_height_spinbutton ), TRUE ); + gtk_spin_button_set_update_policy( GTK_SPIN_BUTTON( fit_height_spinbutton ), GTK_UPDATE_IF_VALID ); + gtk_grid_attach( GTK_GRID( table2 ), fit_height_spinbutton, 3, 1, 1, 1 ); + gtk_widget_show( fit_height_spinbutton ); + g_object_set( fit_height_spinbutton, "xalign", 1.0, NULL ); fit_button = gtk_button_new_with_mnemonic( "Fit" ); + gtk_grid_attach( GTK_GRID( table2 ), fit_button, 0, 1, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( fit_button ), TRUE ); gtk_widget_show( fit_button ); - gtk_table_attach( GTK_TABLE( table2 ), fit_button, 1, 2, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); axial_button = gtk_button_new_with_mnemonic( "Axial" ); + gtk_grid_attach( GTK_GRID( table2 ), axial_button, 1, 1, 1, 1 ); + gtk_widget_set_hexpand( GTK_WIDGET( axial_button ), TRUE ); gtk_widget_show( axial_button ); - gtk_table_attach( GTK_TABLE( table2 ), axial_button, 0, 1, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); + + size_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); + gtk_size_group_add_widget( size_group, axial_button ); + gtk_size_group_add_widget( size_group, fit_button ); + g_object_unref( size_group ); // Add the SURF_ and CONTENTS_ flags frame create_SurfaceFlagsFrame( vbox1 ); diff --git a/plugins/surface_idtech2/surfaceflags.cpp b/plugins/surface_idtech2/surfaceflags.cpp index 1affb160..5c67a929 100644 --- a/plugins/surface_idtech2/surfaceflags.cpp +++ b/plugins/surface_idtech2/surfaceflags.cpp @@ -304,28 +304,30 @@ GtkWidget* create_SurfaceFlagsFrame( GtkWidget* surfacedialog_widget ){ char buffer[16]; frame1 = gtk_frame_new( _( "Flags" ) ); - gtk_widget_show( frame1 ); gtk_container_add( GTK_CONTAINER( surfacedialog_widget ), frame1 ); + gtk_widget_show( frame1 ); vbox1 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_widget_show( vbox1 ); gtk_container_add( GTK_CONTAINER( frame1 ), vbox1 ); + gtk_widget_show( vbox1 ); notebook1 = gtk_notebook_new(); - gtk_widget_show( notebook1 ); gtk_box_pack_start( GTK_BOX( vbox1 ), notebook1, TRUE, TRUE, 0 ); gtk_notebook_set_show_tabs( GTK_NOTEBOOK( notebook1 ), TRUE ); gtk_container_set_border_width( GTK_CONTAINER( notebook1 ), 5 ); + gtk_widget_show( notebook1 ); vbox2 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); - gtk_widget_show( vbox2 ); gtk_container_add( GTK_CONTAINER( notebook1 ), vbox2 ); + gtk_widget_show( vbox2 ); - table4 = gtk_table_new( 8, 4, TRUE ); - gtk_widget_show( table4 ); - gtk_table_set_col_spacings( GTK_TABLE( table4 ), 5 ); - gtk_table_set_row_spacings( GTK_TABLE( table4 ), 5 ); + table4 = gtk_grid_new(); + gtk_grid_set_column_spacing( GTK_GRID( table4 ), 5 ); + gtk_grid_set_row_spacing( GTK_GRID( table4 ), 5 ); gtk_box_pack_start( GTK_BOX( vbox2 ), table4, TRUE, TRUE, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( table4 ), 5 ); + gtk_widget_set_hexpand( table4, TRUE ); + gtk_widget_show( table4 ); y = -1; for ( i = 0; i < MAX_BUTTONS; i++ ) { @@ -338,27 +340,28 @@ GtkWidget* create_SurfaceFlagsFrame( GtkWidget* surfacedialog_widget ){ //Sys_Printf( "%s: %s\n", buffer, buttonLabel ); surface_buttons[i] = gtk_toggle_button_new_with_label( buttonLabel ); g_signal_connect( surface_buttons[i], "toggled", G_CALLBACK( on_surface_button_toggled ), GINT_TO_POINTER( 1 << i ) ); + gtk_grid_attach( GTK_GRID( table4 ), surface_buttons[i], x, y, 1, 1 ); + gtk_widget_set_hexpand( surface_buttons[i], TRUE ); gtk_widget_show( surface_buttons[i] ); - gtk_table_attach( GTK_TABLE( table4 ), surface_buttons[i], 0 + x, 1 + x, ( 0 + y ), ( 1 + y ), - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); } hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 0 ); + gtk_container_set_border_width( GTK_CONTAINER( hbox2 ), 4 ); + gtk_widget_show( hbox2 ); hbox3 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ); - gtk_widget_show( hbox3 ); gtk_box_pack_start( GTK_BOX( hbox2 ), hbox3, TRUE, TRUE, 0 ); + gtk_widget_show( hbox3 ); vbox4 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); + gtk_box_pack_start( GTK_BOX( hbox3 ), vbox4, TRUE, TRUE, 0 ); gtk_widget_show( vbox4 ); - gtk_box_pack_start( GTK_BOX( hbox3 ), vbox4, TRUE, TRUE, 0 ); - value_label = gtk_label_new( " Value: " ); - gtk_widget_show( value_label ); + value_label = gtk_label_new( "Value:" ); gtk_box_pack_start( GTK_BOX( hbox3 ), value_label, FALSE, FALSE, 0 ); + gtk_widget_set_halign( value_label, GTK_ALIGN_START ); + gtk_widget_show( value_label ); value_entry = gtk_entry_new(); g_signal_connect( value_entry, "changed", @@ -368,22 +371,25 @@ GtkWidget* create_SurfaceFlagsFrame( GtkWidget* surfacedialog_widget ){ G_CALLBACK( on_value_entry_insert_text ), NULL ); gtk_entry_set_max_length( (GtkEntry *)value_entry, 11 ); - gtk_widget_show( value_entry ); gtk_box_pack_start( GTK_BOX( hbox3 ), value_entry, TRUE, TRUE, 0 ); + gtk_widget_show( value_entry ); + g_object_set( value_entry, "xalign", 1.0, NULL ); vbox3 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); - gtk_widget_show( vbox3 ); gtk_box_pack_start( GTK_BOX( hbox3 ), vbox3, TRUE, TRUE, 0 ); + gtk_widget_show( vbox3 ); label5 = gtk_label_new( "Surface Flags" ); - gtk_widget_show( label5 ); gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ), gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ), 0 ), label5 ); + gtk_widget_show( label5 ); - table3 = gtk_table_new( 8, 4, TRUE ); - gtk_widget_show( table3 ); - gtk_table_set_col_spacings( GTK_TABLE( table3 ), 5 ); - gtk_table_set_row_spacings( GTK_TABLE( table3 ), 5 ); + table3 = gtk_grid_new(); + gtk_grid_set_column_spacing( GTK_GRID( table3 ), 5 ); + gtk_grid_set_row_spacing( GTK_GRID( table3 ), 5 ); gtk_container_add( GTK_CONTAINER( notebook1 ), table3 ); + gtk_container_set_border_width( GTK_CONTAINER( table3 ), 5 ); + gtk_widget_set_hexpand( table3, TRUE ); + gtk_widget_show( table3 ); y = -1; for ( i = 0; i < MAX_BUTTONS; i++ ) { @@ -395,14 +401,14 @@ GtkWidget* create_SurfaceFlagsFrame( GtkWidget* surfacedialog_widget ){ buttonLabel = g_FuncTable.m_pfnReadProjectKey( buffer ); content_buttons[i] = gtk_toggle_button_new_with_label( buttonLabel ); g_signal_connect( content_buttons[i], "toggled", G_CALLBACK( on_content_button_toggled ), GINT_TO_POINTER( 1 << i ) ); + gtk_grid_attach( GTK_GRID( table3 ), content_buttons[i], x, y, 1, 1 ); + gtk_widget_set_hexpand( content_buttons[i], TRUE ); gtk_widget_show( content_buttons[i] ); - gtk_table_attach( GTK_TABLE( table3 ), content_buttons[i], 0 + x, 1 + x, ( 0 + y ), ( 1 + y ), - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); } label6 = gtk_label_new( "Content Flags" ); gtk_widget_show( label6 ); + gtk_notebook_set_tab_label( GTK_NOTEBOOK( notebook1 ), gtk_notebook_get_nth_page( GTK_NOTEBOOK( notebook1 ), 1 ), label6 ); return frame1; diff --git a/plugins/vfspk3/vfspk3.cpp b/plugins/vfspk3/vfspk3.cpp index 6d479191..4fe6bab5 100644 --- a/plugins/vfspk3/vfspk3.cpp +++ b/plugins/vfspk3/vfspk3.cpp @@ -39,6 +39,7 @@ #endif #include +#include #include "vfspk3.h" #include "vfs.h" diff --git a/radiant/csg.cpp b/radiant/csg.cpp index fa8ef757..4977161a 100644 --- a/radiant/csg.cpp +++ b/radiant/csg.cpp @@ -62,18 +62,21 @@ void CSG_MakeHollowMode( int mode ){ split = *f; VectorScale( f->plane.normal, g_qeglobals.d_gridsize, move ); for ( i = 0 ; i < 3 ; i++ ) - VectorSubtract( split.planepts[i], move, split.planepts[i] ); - + if( mode == CSG_HOLLOW_MODE_TOUCH ) { + VectorAdd( f->planepts[i], move, f->planepts[i] ); + } else { + VectorSubtract( split.planepts[i], move, split.planepts[i] ); + } Brush_SplitBrushByFace( b, &split, &front, &back ); if ( back ) { Brush_Free( back ); } if ( front ) { - if( mode == CSG_HOLLOW_MODE_TOUCH ) { - Brush_Move( front, move, true ); - } Brush_AddToList( front, &selected_brushes ); } + if( mode == CSG_HOLLOW_MODE_TOUCH ) { + *f = split; + } } Brush_Free( b ); } diff --git a/radiant/drag.cpp b/radiant/drag.cpp index 3e3ae82e..37203239 100644 --- a/radiant/drag.cpp +++ b/radiant/drag.cpp @@ -367,7 +367,7 @@ void Drag_Begin( int x, int y, int buttons, // ctrl-shift LBUTTON = select single face if ( sf_camera && buttons == ( MK_LBUTTON | MK_CONTROL | MK_SHIFT ) && g_qeglobals.d_select_mode != sel_curvepoint ) { - if ( Sys_AltDown() ) { + if ( !Sys_AltDown() ) { brush_t *b; for ( b = selected_brushes.next ; b != &selected_brushes ; b = b->next ) { diff --git a/radiant/eclass_def.cpp b/radiant/eclass_def.cpp index ef9415c2..82926863 100644 --- a/radiant/eclass_def.cpp +++ b/radiant/eclass_def.cpp @@ -120,6 +120,8 @@ void setSpecialLoad( eclass_t *e, const char* pWhat, char*& p ){ } } +qboolean IsModelEntity( const char *name ); + eclass_t *Eclass_InitFromText( char *text ){ char *t; int len; @@ -260,7 +262,7 @@ eclass_t *Eclass_InitFromText( char *text ){ if ( strcmpi( e->name, "path" ) == 0 ) { e->nShowFlags |= ECLASS_PATH; } - if ( strcmpi( e->name, "misc_model" ) == 0 ) { + if ( IsModelEntity( e->name ) == qtrue ) { e->nShowFlags |= ECLASS_MISCMODEL; } diff --git a/radiant/filters.cpp b/radiant/filters.cpp index 1b909db8..7a59b0e4 100644 --- a/radiant/filters.cpp +++ b/radiant/filters.cpp @@ -141,6 +141,8 @@ bfilter_t *FilterAddBase( bfilter_t *pFilter ){ pFilter = FilterAddImpl( pFilter,3,0,"trigger",EXCLUDE_TRIGGERS,true ); pFilter = FilterAddImpl( pFilter,3,0,"misc_model",EXCLUDE_MODELS,true ); pFilter = FilterAddImpl( pFilter,3,0,"misc_gamemodel",EXCLUDE_MODELS,true ); + pFilter = FilterAddImpl( pFilter,3,0,"misc_model_static",EXCLUDE_MODELS,true ); + pFilter = FilterAddImpl( pFilter,3,0,"model_static",EXCLUDE_MODELS,true ); pFilter = FilterAddImpl( pFilter,4,ECLASS_LIGHT,NULL,EXCLUDE_LIGHTS,true ); pFilter = FilterAddImpl( pFilter,4,ECLASS_PATH,NULL,EXCLUDE_PATHS,true ); pFilter = FilterAddImpl( pFilter,1,0,"lightgrid",EXCLUDE_LIGHTGRID,true ); diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 1cfeea94..455bfaeb 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -2912,11 +2912,11 @@ int DoTextureLayout( float *fx, float *fy ){ gtk_widget_show( label ); x = gtk_entry_new(); - gtk_grid_attach( GTK_GRID( table ), label, 1, 0, 1, 1 ); + gtk_grid_attach( GTK_GRID( table ), x, 1, 0, 1, 1 ); gtk_widget_show( x ); y = gtk_entry_new(); - gtk_grid_attach( GTK_GRID( table ), label, 1, 1, 1, 1 ); + gtk_grid_attach( GTK_GRID( table ), y, 1, 1, 1, 1 ); gtk_widget_show( y ); @@ -3487,6 +3487,41 @@ int DoLightIntensityDlg( int *intensity ){ return ret; } +static void limitHistory( GtkWidget *combo, gint max_count ) +{ + GtkTreeModel *model; + gint length; + + if( max_count <= 0 ) + return; + + model = gtk_combo_box_get_model( GTK_COMBO_BOX( combo ) ); + if( !model ) + return; + + length = gtk_tree_model_iter_n_children( model, NULL ); + if( length > max_count ) + { + int i; + gint count = length - max_count; + + for( i = 0; i < count; i++ ) + { + gtk_combo_box_text_remove( GTK_COMBO_BOX_TEXT( combo ), 0 ); + } + } +} +static void AddToFindHistory( GtkWidget *combo, const gchar *strFind ) +{ + gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT( combo ), strFind, strFind ); + limitHistory( combo, 20 ); +} +static void AddToReplaceHistory( GtkWidget *combo, const gchar *strReplace ) +{ + gtk_combo_box_text_append( GTK_COMBO_BOX_TEXT( combo ), strReplace, strReplace ); + limitHistory( combo, 20 ); +} + static void OnReplace_clicked( GtkButton *button, gpointer data ) { gboolean bSelectedOnly, bForce; @@ -3511,6 +3546,9 @@ static void OnReplace_clicked( GtkButton *button, gpointer data ) strReplace = gtk_entry_get_text( GTK_ENTRY( entry ) ); FindReplaceTextures( strFind, strReplace, bSelectedOnly, bForce, FALSE ); + + AddToFindHistory( find_combo, strFind ); + AddToReplaceHistory( replace_combo, strReplace ); } static void OnFind_clicked( GtkButton *button, gpointer data ) { @@ -3533,13 +3571,72 @@ static void OnFind_clicked( GtkButton *button, gpointer data ) strReplace = gtk_entry_get_text( GTK_ENTRY( entry ) ); FindReplaceTextures( strFind, strReplace, bSelectedOnly, FALSE, TRUE ); + + AddToFindHistory( find_combo, strFind ); +} + +static void findpopup_selected( GtkWidget *widget, gpointer data ) +{ + const gchar *str; + GtkWidget *label; + + GtkWidget *texlabel = GTK_WIDGET( g_object_get_data( G_OBJECT( widget ), "texture-label" ) ); + if( texlabel ) + { + label = texlabel; + } else + { + label = gtk_bin_get_child( GTK_BIN( widget ) ); + } + str = gtk_label_get_text( GTK_LABEL( label ) ); + gtk_entry_set_text( GTK_ENTRY( data ), str ); +} + +static void findbutton_clicked( GtkWidget *widget, gpointer data ) +{ + GtkWidget *menu, *item; + menu = gtk_menu_new(); + + for ( int i = 0; i < QERApp_GetActiveShaderCount(); i++ ) + { + IShader *pShader = QERApp_ActiveShader_ForIndex( i ); + + if( strcmp( g_qeglobals.d_texturewin.texdef.GetName(), pShader->getName() ) == 0 ) + { + GtkWidget *label, *box; + + item = gtk_menu_item_new(); + + box = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 6 ); + gtk_container_add( GTK_CONTAINER( item ), box ); + gtk_widget_show( box ); + + label = gtk_label_new( pShader->getName() ); + gtk_container_add( GTK_CONTAINER( box ), label ); + gtk_widget_show( label ); + g_object_set_data( G_OBJECT( item ), "texture-label", label ); + + label = gtk_label_new( _( "!" ) ); + gtk_container_add( GTK_CONTAINER( box ), label ); + gtk_widget_show( label ); + + } else + { + item = gtk_menu_item_new_with_label( pShader->getName() ); + } + gtk_menu_shell_append( GTK_MENU_SHELL( menu ), item ); + gtk_widget_show( item ); + g_signal_connect( item, "activate", G_CALLBACK( findpopup_selected ), data ); + } + + gtk_menu_popup( GTK_MENU( menu ), NULL, widget, NULL, NULL, 1, GDK_CURRENT_TIME ); } void DoFindReplaceTexturesDialog() { GtkWidget *dialog, *content_area, *combo, *hbox; GtkWidget *vbox, *table, *label, *button, *find_button, *replace_button; - GtkWidget *find_combo, *replace_combo, *check; + GtkWidget *find_combo, *replace_combo, *check, *entry; GtkSizeGroup *button_group; GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; @@ -3570,23 +3667,34 @@ void DoFindReplaceTexturesDialog() gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - label = gtk_label_new( "Replace:" ); - gtk_grid_attach( GTK_GRID( table ), label, 0, 1, 1, 1 ); - gtk_widget_set_halign( label, GTK_ALIGN_START ); - gtk_widget_show( label ); - find_combo = combo = gtk_combo_box_text_new_with_entry(); gtk_grid_attach( GTK_GRID( table ), combo, 1, 0, 1, 1 ); gtk_widget_set_hexpand( combo, TRUE ); gtk_widget_show( combo ); g_object_set_data( G_OBJECT( dialog ), "find_combo", find_combo ); + button = gtk_button_new_with_label( "..." ); + gtk_grid_attach( GTK_GRID( table ), button, 2, 0, 1, 1 ); + gtk_widget_show( button ); + entry = gtk_bin_get_child( GTK_BIN( find_combo ) ); + g_signal_connect( button, "clicked", G_CALLBACK( findbutton_clicked ), entry ); + + label = gtk_label_new( "Replace:" ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 1, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); + replace_combo = combo = gtk_combo_box_text_new_with_entry(); gtk_grid_attach( GTK_GRID( table ), combo, 1, 1, 1, 1 ); gtk_widget_set_hexpand( combo, TRUE ); gtk_widget_show( combo ); g_object_set_data( G_OBJECT( dialog ), "replace_combo", replace_combo ); + button = gtk_button_new_with_label( "..." ); + gtk_grid_attach( GTK_GRID( table ), button, 2, 1, 1, 1 ); + gtk_widget_show( button ); + entry = gtk_bin_get_child( GTK_BIN( replace_combo ) ); + g_signal_connect( button, "clicked", G_CALLBACK( findbutton_clicked ), entry ); check = gtk_check_button_new_with_label( "Use selected brushes only" ); gtk_box_pack_start( GTK_BOX( vbox ), check, TRUE, TRUE, 0 ); diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index eecc2c1b..bf65888d 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -910,7 +910,7 @@ int WINAPI gtk_MessageBoxNew( void *parent, const char *message, // add message GtkWidget *dlg_msg = gtk_label_new( message ); gtk_box_pack_start( GTK_BOX( icon_text_hbox ), dlg_msg, FALSE, FALSE, MSGBOX_PAD_MINOR ); - gtk_label_set_justify( GTK_LABEL( dlg_msg ), GTK_JUSTIFY_LEFT ); + gtk_widget_set_halign( dlg_msg, GTK_ALIGN_START ); gtk_widget_show( dlg_msg ); // add buttons diff --git a/radiant/main.cpp b/radiant/main.cpp index 62f889bc..b3110c3a 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -421,6 +421,10 @@ int main( int argc, char* argv[] ) { const char *libgl; int i, j, k; +#if defined( _WIN32 ) && defined( _MSC_VER ) + //increase the max open files to its maximum for the C run-time of MSVC + _setmaxstdio( 2048 ); +#endif /* Rambetter on Sat Nov 13, 2010: @@ -981,14 +985,14 @@ void QE_ExpandBspString( char *bspaction, GPtrArray *out_array, char *mapname ){ // initialise the first step out = new char[BIG_PATH_MAX]; + *out = 0; g_ptr_array_add( out_array, out ); in = ValueForKey( g_qeglobals.d_project_entity, bspaction ); while ( *in ) { if ( in[0] == '!' ) { - Q_strncpyz( out, rsh, sizeof( out ) ); - out += strlen( rsh ); + strncat( out, rsh, BIG_PATH_MAX ); in++; continue; } @@ -998,36 +1002,39 @@ void QE_ExpandBspString( char *bspaction, GPtrArray *out_array, char *mapname ){ if ( g_PrefsDlg.m_bWatchBSP ) { // -connect global option (the only global option so far anyway) strcpy( tmp, " -connect 127.0.0.1:39000 " ); - Q_strncpyz( out, tmp, sizeof( out ) ); - out += strlen( tmp ); + strncat( out, tmp, BIG_PATH_MAX ); } in++; continue; } if ( in[0] == '$' ) { // $ expansion - Q_strncpyz( out, src, sizeof( out ) ); - out += strlen( src ); + strncat( out, src, BIG_PATH_MAX ); in++; continue; } if ( in[0] == '@' ) { - *out++ = '"'; + strncat( out, "\"", BIG_PATH_MAX ); in++; continue; } if ( in[0] == '&' ) { if ( in[1] == '&' ) { // start a new step - *out = 0; in = in + 2; out = new char[BIG_PATH_MAX]; + *out = 0; g_ptr_array_add( out_array, out ); } } - *out++ = *in++; + size_t len = strlen( out ); + if( ( len + 1 ) < BIG_PATH_MAX ) + { + out[len++] = *in; + out[len] = '\0'; + } + in++; } - *out = 0; } void FindReplace( CString& strContents, const char* pTag, const char* pValue ){ @@ -1149,7 +1156,7 @@ void RunBsp( char *command ){ if ( g_PrefsDlg.m_bWatchBSP ) { // grab the file name for engine running char *bspname = new char[1024]; - ExtractFileName( currentmap, bspname, sizeof( bspname ) ); + ExtractFileName( currentmap, bspname, 1024 ); StripExtension( bspname ); g_pParentWnd->GetWatchBSP()->DoMonitoringLoop( sys, bspname ); } else { diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index d50ceb99..a8be6728 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2717,18 +2717,24 @@ void MainFrame::Create(){ m_pTexWnd = new TexWnd(); { GtkWidget* frame = create_framed_texwnd( m_pTexWnd ); - gint pos = 0; - GtkWidget* texDirList = create_texdirlist_widget( &pos ); + if( g_PrefsDlg.m_bShowTexDirList ) + { + gint pos = 0; + GtkWidget* texDirList = create_texdirlist_widget( &pos ); - GtkWidget* texSplit = gtk_paned_new( GTK_ORIENTATION_HORIZONTAL ); + GtkWidget* texSplit = gtk_paned_new( GTK_ORIENTATION_HORIZONTAL ); - gtk_paned_pack2( GTK_PANED( vsplit2 ), texSplit, TRUE, FALSE ); - gtk_paned_add1( GTK_PANED( texSplit ), texDirList ); - gtk_paned_add2( GTK_PANED( texSplit ), frame ); + gtk_paned_pack2( GTK_PANED( vsplit2 ), texSplit, TRUE, FALSE ); + gtk_paned_add1( GTK_PANED( texSplit ), texDirList ); + gtk_paned_add2( GTK_PANED( texSplit ), frame ); - gtk_paned_set_position( GTK_PANED( texSplit ), pos ); + gtk_paned_set_position( GTK_PANED( texSplit ), pos ); - gtk_widget_show( texSplit ); + gtk_widget_show( texSplit ); + } else + { + gtk_paned_pack2( GTK_PANED( vsplit2 ), frame, TRUE, TRUE ); + } } // console @@ -2774,7 +2780,7 @@ void MainFrame::Create(){ else if ( CurrentStyle() == eFloating ) { { GtkWidget* wnd = create_floating( this ); - gtk_window_set_title( GTK_WINDOW( wnd ), "Camera" ); + gtk_window_set_title( GTK_WINDOW( wnd ), _( "Camera" ) ); #ifdef _WIN32 if ( g_PrefsDlg.m_bStartOnPrimMon ) { @@ -2800,7 +2806,7 @@ void MainFrame::Create(){ { GtkWidget* wnd = create_floating( this ); - gtk_window_set_title( GTK_WINDOW( wnd ), "XY View" ); + gtk_window_set_title( GTK_WINDOW( wnd ), _( "XY View" ) ); #ifdef _WIN32 if ( g_PrefsDlg.m_bStartOnPrimMon ) { @@ -2825,7 +2831,7 @@ void MainFrame::Create(){ else { GtkWidget* wnd = create_floating( this ); - gtk_window_set_title( GTK_WINDOW( wnd ), "XY View" ); + gtk_window_set_title( GTK_WINDOW( wnd ), _( "XY View" ) ); #ifdef _WIN32 if ( g_PrefsDlg.m_bStartOnPrimMon ) { @@ -2918,9 +2924,26 @@ void MainFrame::Create(){ GtkWidget* frame = create_framed_texwnd( m_pTexWnd ); m_pTexWnd->m_pParent = g_pGroupDlg->m_pWidget; + GtkWidget* w = gtk_label_new( _( "Textures" ) ); + gtk_widget_show( w ); + + if( g_PrefsDlg.m_bShowTexDirList ) + { + gint pos = 0; + GtkWidget* texDirList = create_texdirlist_widget( &pos ); + + GtkWidget* texSplit = gtk_paned_new( GTK_ORIENTATION_HORIZONTAL ); + + gtk_paned_add1( GTK_PANED( texSplit ), texDirList ); + gtk_paned_add2( GTK_PANED( texSplit ), frame ); + + gtk_paned_set_position( GTK_PANED( texSplit ), pos ); + + gtk_widget_show( texSplit ); + + gtk_notebook_insert_page( GTK_NOTEBOOK( g_pGroupDlg->m_pNotebook ), texSplit, w, 1 ); + } else { - GtkWidget* w = gtk_label_new( _( "Textures" ) ); - gtk_widget_show( w ); gtk_notebook_insert_page( GTK_NOTEBOOK( g_pGroupDlg->m_pNotebook ), frame, w, 1 ); } } @@ -2981,9 +3004,26 @@ void MainFrame::Create(){ m_pTexWnd = new TexWnd(); GtkWidget* frame = create_framed_texwnd( m_pTexWnd ); + GtkWidget* w = gtk_label_new( _( "Textures" ) ); + gtk_widget_show( w ); + + if( g_PrefsDlg.m_bShowTexDirList ) + { + gint pos = 0; + GtkWidget* texDirList = create_texdirlist_widget( &pos ); + + GtkWidget* texSplit = gtk_paned_new( GTK_ORIENTATION_HORIZONTAL ); + + gtk_paned_add1( GTK_PANED( texSplit ), texDirList ); + gtk_paned_add2( GTK_PANED( texSplit ), frame ); + + gtk_paned_set_position( GTK_PANED( texSplit ), pos ); + + gtk_widget_show( texSplit ); + + gtk_notebook_insert_page( GTK_NOTEBOOK( g_pGroupDlg->m_pNotebook ), texSplit, w, 1 ); + } else { - GtkWidget* w = gtk_label_new( _( "Textures" ) ); - gtk_widget_show( w ); gtk_notebook_insert_page( GTK_NOTEBOOK( g_pGroupDlg->m_pNotebook ), frame, w, 1 ); } } @@ -2996,18 +3036,21 @@ void MainFrame::Create(){ { gint max_position; - g_object_get( m_pSplits[0], "max-position", &max_position, NULL ); + //g_object_get( m_pSplits[0], "max-position", &max_position, NULL ); + max_position = gtk_widget_get_allocated_width( m_pSplits[0] ); int x = max_position / 2 - gutter; gtk_paned_set_position( GTK_PANED( m_pSplits[0] ), x ); } { gint max_position; - g_object_get( m_pSplits[0], "max-position", &max_position, NULL ); + //g_object_get( m_pSplits[0], "max-position", &max_position, NULL ); + max_position = gtk_widget_get_allocated_height( m_pSplits[0] ); int y = max_position / 2 - gutter; gtk_paned_set_position( GTK_PANED( m_pSplits[1] ), y ); gtk_paned_set_position( GTK_PANED( m_pSplits[2] ), y ); } + } if ( g_PrefsDlg.mWindowInfo.nState & GDK_WINDOW_STATE_MAXIMIZED ) { @@ -4681,6 +4724,7 @@ void MainFrame::OnPrefs() { bool bPluginToolbar = g_PrefsDlg.m_bPluginToolbar; bool bDetachableMenus = g_PrefsDlg.m_bDetachableMenus; bool bFloatingZ = g_PrefsDlg.m_bFloatingZ; + bool bShowTexDirList = g_PrefsDlg.m_bShowTexDirList; g_PrefsDlg.LoadPrefs(); @@ -4692,7 +4736,8 @@ void MainFrame::OnPrefs() { (g_PrefsDlg.m_bLatchedPluginToolbar != bPluginToolbar ) || (g_PrefsDlg.m_nLatchedShader != nShader ) || (g_PrefsDlg.m_nLatchedTextureQuality != nTextureQuality ) || - (g_PrefsDlg.m_bLatchedFloatingZ != bFloatingZ)) { + (g_PrefsDlg.m_bLatchedFloatingZ != bFloatingZ ) || + (g_PrefsDlg.m_bShowTexDirList != bShowTexDirList)) { gtk_MessageBoxNew(m_pWidget, "You must restart Radiant for the " "changes to take effect.", "Restart Radiant", MB_OK | MB_ICONINFORMATION); diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index 0225f73f..d5afd3a7 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -307,27 +307,29 @@ void PatchDialog::BuildDialog(){ vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); - gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); + gtk_widget_show( vbox ); hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); - gtk_widget_show( hbox ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 ); + gtk_widget_show( hbox ); frame = gtk_frame_new( _( "Details" ) ); - gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); + gtk_widget_show( frame ); vbox2 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); - gtk_widget_show( vbox2 ); gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); + gtk_widget_set_vexpand( vbox2, FALSE ); + gtk_widget_show( vbox2 ); table = gtk_grid_new(); - gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 ); + gtk_box_pack_start( GTK_BOX( vbox2 ), table, FALSE, TRUE, 0 ); gtk_grid_set_row_spacing( GTK_GRID( table ), 5 ); gtk_grid_set_column_spacing( GTK_GRID( table ), 5 ); + gtk_widget_set_hexpand( table, TRUE ); gtk_widget_show( table ); row_label = label = gtk_label_new( _( "Row:" ) ); @@ -382,26 +384,31 @@ void PatchDialog::BuildDialog(){ label = gtk_label_new( _( "X:" ) ); gtk_grid_attach( GTK_GRID( table ), label, 0, 0, 1, 1 ); gtk_widget_set_tooltip_text( label, _( "X-Axis" ) ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); label = gtk_label_new( _( "Y:" ) ); gtk_grid_attach( GTK_GRID( table ), label, 0, 1, 1, 1 ); gtk_widget_set_tooltip_text( label, _( "Y-Axis" ) ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); label = gtk_label_new( _( "Z:" ) ); gtk_grid_attach( GTK_GRID( table ), label, 0, 2, 1, 1 ); gtk_widget_set_tooltip_text( label, _( "Z-Axis" ) ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); label = gtk_label_new( _( "S:" ) ); gtk_grid_attach( GTK_GRID( table ), label, 0, 3, 1, 1 ); gtk_widget_set_tooltip_text( label, _( "S-coordinates correspond to the \"x\" coordinates on the texture itself" ) ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); label = gtk_label_new( _( "T:" ) ); gtk_grid_attach( GTK_GRID( table ), label, 0, 4, 1, 1 ); gtk_widget_set_tooltip_text( label, _( "T-coordinates correspond to the \"y\" coordinates on the texture itself. The measurements are in game units." ) ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); adj = gtk_adjustment_new( 0, -INT_MAX, INT_MAX, 1, 10, 0 ); @@ -455,29 +462,32 @@ void PatchDialog::BuildDialog(){ AddDialogData( spin, &m_fT, DLG_SPIN_FLOAT ); frame = gtk_frame_new( _( "Texturing" ) ); - gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); + gtk_widget_show( frame ); vbox2 = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); + gtk_widget_set_vexpand( vbox2, FALSE ); gtk_widget_show( vbox2 ); label = gtk_label_new( _( "Name:" ) ); - gtk_box_pack_start( GTK_BOX( vbox2 ), label, TRUE, TRUE, 0 ); + gtk_box_pack_start( GTK_BOX( vbox2 ), label, FALSE, TRUE, 0 ); gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); entry = gtk_entry_new(); gtk_editable_set_editable( GTK_EDITABLE( entry ), FALSE ); gtk_widget_show( entry ); - gtk_box_pack_start( GTK_BOX( vbox2 ), entry, TRUE, TRUE, 0 ); + gtk_box_pack_start( GTK_BOX( vbox2 ), entry, FALSE, TRUE, 0 ); + gtk_widget_set_hexpand( entry, TRUE ); AddDialogData( entry, &m_strName, DLG_ENTRY_TEXT ); table = gtk_grid_new(); - gtk_box_pack_start( GTK_BOX( vbox2 ), table, TRUE, TRUE, 0 ); + gtk_box_pack_start( GTK_BOX( vbox2 ), table, FALSE, TRUE, 0 ); gtk_grid_set_row_spacing( GTK_GRID( table ), 5 ); gtk_grid_set_column_spacing( GTK_GRID( table ), 5 ); + gtk_widget_set_hexpand( table, TRUE ); gtk_widget_show( table ); label = gtk_label_new( _( "Value" ) ); @@ -623,27 +633,28 @@ void PatchDialog::BuildDialog(){ g_object_set( spin, "xalign", 1.0, NULL ); hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); + gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, FALSE, FALSE, 0 ); + gtk_widget_set_hexpand( hbox2, TRUE ); gtk_widget_show( hbox2 ); - gtk_box_pack_start( GTK_BOX( vbox2 ), hbox2, TRUE, FALSE, 0 ); cap_button = button = gtk_button_new_with_label( _( "CAP" ) ); - gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox2 ), button, TRUE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchdetails ), NULL ); set_button = button = gtk_button_new_with_label( _( "Set..." ) ); - gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox2 ), button, TRUE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchreset ), NULL ); nat_button = button = gtk_button_new_with_label( _( "Natural" ) ); - gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox2 ), button, TRUE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchnatural ), NULL ); fit_button = button = gtk_button_new_with_label( _( "Fit" ) ); - gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox2 ), button, TRUE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchfit ), NULL ); size_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); @@ -654,20 +665,20 @@ void PatchDialog::BuildDialog(){ g_object_unref( size_group ); hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); + gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); + gtk_widget_set_hexpand( hbox, TRUE ); + gtk_widget_set_vexpand( hbox, FALSE ); gtk_widget_show( hbox ); - gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, FALSE, 0 ); button = gtk_button_new_with_label( _( "Done" ) ); - gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnDone ), NULL ); - gtk_widget_set_size_request( button, 60, -1 ); button = gtk_button_new_with_label( _( "Apply" ) ); - gtk_widget_show( button ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnApply ), NULL ); - gtk_widget_set_size_request( button, 60, -1 ); } // sync the dialog our internal data structures @@ -711,10 +722,11 @@ void PatchDialog::GetPatchInfo(){ m_bListenChanged = true; - gtk_widget_set_sensitive( GTK_WIDGET( m_pWidget ), TRUE ); + //should use gtk_dialog_get_content_area instead of gtk_bin_get_child but m_pWidget is not a gtkdialog yet + gtk_widget_set_sensitive( GTK_WIDGET( gtk_bin_get_child( GTK_BIN( m_pWidget ) ) ), TRUE ); } else{ - gtk_widget_set_sensitive( GTK_WIDGET( m_pWidget ), FALSE ); + gtk_widget_set_sensitive( GTK_WIDGET( gtk_bin_get_child( GTK_BIN( m_pWidget ) ) ), FALSE ); Sys_FPrintf( SYS_WRN, "WARNING: No patch selected.\n" ); } diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 916a4682..ca524cae 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -105,6 +105,9 @@ #define CHASEMOUSE_KEY "ChaseMouse" #define MOUSEWHEELZOOM_KEY "MousewheelZoom" #define ENTITYSHOW_KEY "EntityShow" +#define FIXEDTEXSIZE_KEY "UseFixedTextureSize" +#define FIXEDTEXSIZEWIDTH_KEY "FixedTextureSizeWidth" +#define FIXEDTEXSIZEHEIGHT_KEY "FixedTextureSizeHeight" #define TEXTURESCALE_KEY "TextureScale" #define TEXTURESCROLLBAR_KEY "TextureScrollbar" #define DISPLAYLISTS_KEY "UseDisplayLists" @@ -119,6 +122,7 @@ #define SHADERTEST_KEY "ShaderTest" #define GLLIGHTING_KEY "UseGLLighting" #define LOADSHADERS_KEY "LoadShaders" +#define SHOWTEXDIRLIST_KEY "ShowTextureDirectoryList" #define NOSTIPPLE_KEY "NoStipple" #define UNDOLEVELS_KEY "UndoLevels" #define VERTEXMODE_KEY "VertexSplit" @@ -634,6 +638,9 @@ PrefsDlg::PrefsDlg (){ m_bSelectCurves = TRUE; m_bSelectModels = TRUE; m_nEntityShowState = ENTITY_SKINNED_BOXED; + m_bFixedTextureSize = TRUE; + m_nFixedTextureSizeWidth = 64; + m_nFixedTextureSizeHeight = 64; m_nTextureScale = 2; m_bSwitchClip = FALSE; m_bSelectWholeEntities = TRUE; @@ -726,7 +733,7 @@ CGameDescription::CGameDescription( xmlDocPtr pDoc, const Str &GameFile ){ // on win32, game tools path can now be specified relative to the exe's cwd prop = (char*)xmlGetProp( pNode, (xmlChar*)TOOLS_ATTRIBUTE ); if ( prop == NULL ) { - Error( "Didn't find '"TOOLS_ATTRIBUTE "' node in the game description file '%s'\n", pDoc->URL ); + Error( "Didn't find '" TOOLS_ATTRIBUTE "' node in the game description file '%s'\n", pDoc->URL ); } { char full[PATH_MAX]; @@ -1580,6 +1587,7 @@ void PrefsDlg::BuildDialog(){ // Main Preferences dialog GtkWidget *dialog, *mainvbox, *hbox, *sc_win, *preflabel; GtkWidget *startup_label, *tcomp_label, *startup_combo, *tcomp_combo; + GtkWidget *ftw_label, *fth_label; // Widgets on notebook pages GtkWidget *check, *label, *scale, *hbox2, *combo, *table, *spin, *entry, *pixmap, @@ -1695,6 +1703,11 @@ void PrefsDlg::BuildDialog(){ gtk_tree_store_append( store, &tab, &group ); gtk_tree_store_set( store, &tab, 0, _( "Texture Settings" ), 1, (gpointer)PTAB_TEXTURE, -1 ); } + { + GtkTreeIter tab; + gtk_tree_store_append( store, &tab, &group ); + gtk_tree_store_set( store, &tab, 0, _( "Texture Directory List" ), 1, (gpointer)PTAB_TEXTURE_DIR, -1 ); + } } { @@ -1869,7 +1882,7 @@ void PrefsDlg::BuildDialog(){ gtk_widget_show( label ); // adjustment - adj = gtk_adjustment_new( 100, 50, 300, 1, 10, 10 ); + adj = gtk_adjustment_new( 100, 1, 300, 1, 10, 10 ); AddDialogData( G_OBJECT( adj ), &m_nMoveSpeed, DLG_ADJ_INT ); // scale @@ -2113,6 +2126,43 @@ void PrefsDlg::BuildDialog(){ AddDialogData( combo, &m_nLatchedShader, DLG_COMBO_BOX_INT ); g_list_free( combo_list ); + check = gtk_check_button_new_with_label( _( "Use Fixed Texture Size" ) ); + gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); + gtk_widget_show( check ); + AddDialogData( check, &m_bFixedTextureSize, DLG_CHECK_BOOL ); + + hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); + gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, FALSE, 0 ); + gtk_widget_show( hbox2 ); + + ftw_label = label = gtk_label_new( _( "Fixed Texture Wdith" ) ); + gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); + + spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 1024, 1, 10, 0 ) ), 1, 0 ); + gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE ); + g_object_set( spin, "xalign", 1.0, NULL ); + gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, FALSE, 0 ); + gtk_widget_show( spin ); + AddDialogData( spin, &m_nFixedTextureSizeWidth, DLG_SPIN_INT ); + + hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); + gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, FALSE, 0 ); + gtk_widget_show( hbox2 ); + + fth_label = label = gtk_label_new( _( "Fixed Texture Height" ) ); + gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); + + spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 1024, 1, 10, 0 ) ), 1, 0 ); + gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE ); + g_object_set( spin, "xalign", 1.0, NULL ); + gtk_box_pack_start( GTK_BOX( hbox2 ), spin, FALSE, FALSE, 0 ); + gtk_widget_show( spin ); + AddDialogData( spin, &m_nFixedTextureSizeHeight, DLG_SPIN_INT ); + size_group = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL ); gtk_size_group_add_widget( size_group, tcomp_label ); gtk_size_group_add_widget( size_group, startup_label ); @@ -2123,9 +2173,36 @@ void PrefsDlg::BuildDialog(){ gtk_size_group_add_widget( size_group, startup_combo ); g_object_unref( size_group ); + size_group = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL ); + gtk_size_group_add_widget( size_group, ftw_label ); + gtk_size_group_add_widget( size_group, fth_label ); + g_object_unref( size_group ); + // Add the page to the notebook gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), pageframe, preflabel ); + + /******** Texture dir list group *********/ + preflabel = gtk_label_new( _( "Texture directory list" ) ); + gtk_widget_show( preflabel ); + pageframe = gtk_frame_new( _( "Texture directory list" ) ); + gtk_container_set_border_width( GTK_CONTAINER( pageframe ), 5 ); + gtk_widget_show( pageframe ); + vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); + gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); + gtk_container_add( GTK_CONTAINER( pageframe ), vbox ); + gtk_widget_show( vbox ); + + check = gtk_check_button_new_with_label( _( "Show Texture Directory List" ) ); + gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); + gtk_widget_show( check ); + AddDialogData( check, &m_bShowTexDirList, DLG_CHECK_BOOL ); + + + // Add the page to the notebook + gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), pageframe, preflabel ); + + /******** Layout group *********/ preflabel = gtk_label_new( _( "Layout" ) ); gtk_widget_show( preflabel ); @@ -2988,6 +3065,13 @@ void PrefsDlg::LoadPrefs(){ mLocalPrefs.GetPref( LOADSHADERS_KEY, &m_nLatchedShader, 0 ); m_nShader = m_nLatchedShader; + + mLocalPrefs.GetPref( FIXEDTEXSIZE_KEY, &m_bFixedTextureSize, FALSE ); + mLocalPrefs.GetPref( FIXEDTEXSIZEWIDTH_KEY, &m_nFixedTextureSizeWidth, 64 ); + mLocalPrefs.GetPref( FIXEDTEXSIZEHEIGHT_KEY, &m_nFixedTextureSizeHeight, 64 ); + + mLocalPrefs.GetPref( SHOWTEXDIRLIST_KEY, &m_bShowTexDirList, TRUE ); + mLocalPrefs.GetPref( NOCLAMP_KEY, &m_bNoClamp, FALSE ); mLocalPrefs.GetPref( SNAP_KEY, &m_bSnap, TRUE ); mLocalPrefs.GetPref( USERINI_KEY, &m_strUserPath, "" ); @@ -3603,11 +3687,11 @@ void CGameInstall::Run() { // - TTimo fprintf( fg, "\n 0 ) { - fprintf( fg, " "EXECUTABLES_ATTRIBUTE "=\"%s\"\n", m_strExecutables.GetBuffer() ); + fprintf( fg, " " EXECUTABLES_ATTRIBUTE "=\"%s\"\n", m_strExecutables.GetBuffer() ); } switch ( m_availGames[ m_nComboSelect ] ) { @@ -3706,9 +3790,9 @@ void CGameInstall::Run() { } case GAME_ET: { #ifdef _WIN32 - fprintf( fg, " "ENGINE_ATTRIBUTE "=\"ET.exe\"\n"); + fprintf( fg, " " ENGINE_ATTRIBUTE "=\"ET.exe\"\n"); #elif __linux__ - fprintf( fg, " "ENGINE_ATTRIBUTE "=\"et\"\n" ); + fprintf( fg, " " ENGINE_ATTRIBUTE "=\"et\"\n" ); #endif fprintf( fg, " prefix=\".etwolf\"\n" ); fprintf( fg, " basegame=\"etmain\"\n" ); diff --git a/radiant/preferences.h b/radiant/preferences.h index 975c59ad..27558c18 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -509,7 +509,7 @@ enum {SHADER_NONE = 0, SHADER_COMMON, SHADER_ALL}; // Gef: updated preferences dialog /*! Preference notebook page numbers */ -enum {PTAB_FRONT = 0, PTAB_GAME_SETTINGS, PTAB_2D, PTAB_CAMERA, PTAB_TEXTURE, PTAB_LAYOUT, PTAB_MOUSE, +enum {PTAB_FRONT = 0, PTAB_GAME_SETTINGS, PTAB_2D, PTAB_CAMERA, PTAB_TEXTURE, PTAB_TEXTURE_DIR, PTAB_LAYOUT, PTAB_MOUSE, PTAB_EDITING, PTAB_STARTUP, PTAB_PATHS, PTAB_BRUSH, PTAB_MISC, PTAB_BSPMONITOR} pref_tabs; GtkWidget *notebook; @@ -645,6 +645,9 @@ int m_nCubicScale; bool m_bSelectCurves; bool m_bSelectModels; int m_nEntityShowState; +bool m_bFixedTextureSize; +int m_nFixedTextureSizeWidth; +int m_nFixedTextureSizeHeight; int m_nTextureScale; bool m_bNormalizeColors; bool m_bSwitchClip; @@ -723,6 +726,8 @@ int m_nLatchedTextureQuality; // texture compression format int m_nTextureCompressionFormat; +bool m_bShowTexDirList; + int m_nLightRadiuses; bool m_bQ3Map2Texturing; diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index b39a678a..3ec16bc9 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -503,6 +503,8 @@ void SurfaceDlg::InitDefaultIncrement( texdef_t *tex ){ void SurfaceDlg::BuildDialog() { GtkWidget *dlg, *vbox, *hbox2, *frame, *table, *label; GtkWidget *button, *entry, *spin; + GtkWidget *axial_button, *cap_button, *set_button, *nat_button, *fit_button; + GtkSizeGroup *button_group; dlg = m_pWidget; @@ -516,350 +518,278 @@ void SurfaceDlg::BuildDialog() { // replaced by only the vbox: vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 5 ); - gtk_widget_show( vbox ); gtk_container_add( GTK_CONTAINER( dlg ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); + gtk_widget_show( vbox ); hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); - gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); + gtk_widget_show( hbox2 ); label = gtk_label_new( _( "Texture" ) ); - gtk_widget_show( label ); gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); + gtk_widget_show( label ); entry = gtk_entry_new(); - g_signal_connect( entry, "key_press_event", G_CALLBACK( OnTextureKey ), NULL ); - gtk_widget_show( entry ); gtk_box_pack_start( GTK_BOX( hbox2 ), entry, TRUE, TRUE, 0 ); + gtk_widget_show( entry ); + g_signal_connect( entry, "key_press_event", G_CALLBACK( OnTextureKey ), NULL ); g_object_set_data( G_OBJECT( m_pWidget ), "texture", entry ); -// table = gtk_table_new (5, 4, FALSE); - table = gtk_table_new( 6, 4, FALSE ); - gtk_widget_show( table ); + table = gtk_grid_new(); + gtk_grid_set_row_spacing( GTK_GRID( table ), 5 ); + gtk_grid_set_column_spacing( GTK_GRID( table ), 5 ); gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 ); - gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); - gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); + gtk_widget_show( table ); label = gtk_label_new( _( "Horizontal shift" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 0 ); + gtk_grid_attach( GTK_GRID( table ), spin, 1, 0, 1, 1 ); + gtk_widget_show( spin ); g_object_set_data( G_OBJECT( dlg ), "hshift", spin ); g_signal_connect( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ), "value_changed", G_CALLBACK( OnUpdate ), NULL ); - gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 2, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); + gtk_grid_attach( GTK_GRID( table ), entry, 3, 0, 1, 1 ); + gtk_widget_show( entry ); g_object_set_data( G_OBJECT( dlg ), "hshift_inc", entry ); g_signal_connect( entry, "changed", G_CALLBACK( OnIncrementChanged ), NULL ); - gtk_widget_show( entry ); - gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 0, 1, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( entry, 50, -2 ); label = gtk_label_new( _( "Vertical shift" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 1, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 0 ); + gtk_grid_attach( GTK_GRID( table ), spin, 1, 1, 1, 1 ); + gtk_widget_show( spin ); g_object_set_data( G_OBJECT( dlg ), "vshift", spin ); g_signal_connect( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ), "value_changed", G_CALLBACK( OnUpdate ), NULL ); - gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 2, 1, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); + gtk_grid_attach( GTK_GRID( table ), entry, 3, 1, 1, 1 ); + gtk_widget_show( entry ); g_object_set_data( G_OBJECT( dlg ), "vshift_inc", entry ); g_signal_connect( entry, "changed", G_CALLBACK( OnIncrementChanged ), NULL ); - gtk_widget_show( entry ); - gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( entry, 50, -2 ); label = gtk_label_new( _( "Horizontal stretch" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 2, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 10, 0 ) ), 0, 0 ); + gtk_grid_attach( GTK_GRID( table ), spin, 1, 2, 1, 1 ); + gtk_widget_show( spin ); g_object_set_data( G_OBJECT( dlg ), "hscale", spin ); g_signal_connect( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ), "value_changed", G_CALLBACK( OnUpdate ), NULL ); - gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 2, 2, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 2, 3 ); entry = gtk_entry_new(); + gtk_grid_attach( GTK_GRID( table ), entry, 3, 2, 1, 1 ); + gtk_widget_show( entry ); g_object_set_data( G_OBJECT( dlg ), "hscale_inc", entry ); g_signal_connect( entry, "changed", G_CALLBACK( OnIncrementChanged ), NULL ); - gtk_widget_show( entry ); - gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 2, 3 ); - gtk_widget_set_size_request( entry, 50, -2 ); label = gtk_label_new( _( "Vertical stretch" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 3, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 10, 0 ) ), 0, 0 ); + gtk_grid_attach( GTK_GRID( table ), spin, 1, 3, 1, 1 ); + gtk_widget_show( spin ); g_object_set_data( G_OBJECT( dlg ), "vscale", spin ); g_signal_connect( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ), "value_changed", G_CALLBACK( OnUpdate ), NULL ); - gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( spin, 60, -2 ); label = gtk_label_new( _( "Step" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 2, 3, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); + gtk_grid_attach( GTK_GRID( table ), entry, 3, 3, 1, 1 ); + gtk_widget_show( entry ); g_object_set_data( G_OBJECT( dlg ), "vscale_inc", entry ); g_signal_connect( entry, "changed", G_CALLBACK( OnIncrementChanged ), NULL ); - gtk_widget_show( entry ); - gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 3, 4, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( entry, 50, -2 ); label = gtk_label_new( _( "Rotate" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 4, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -360, 360, 1, 10, 0 ) ), 1, 0 ); + gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE ); + gtk_grid_attach( GTK_GRID( table ), spin, 1, 4, 1, 1 ); + gtk_widget_show( spin ); g_object_set_data( G_OBJECT( dlg ), "rotate", spin ); g_signal_connect( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ), "value_changed", G_CALLBACK( OnUpdate ), NULL ); - gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( spin, 60, -2 ); - gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE ); label = gtk_label_new( _( "Step" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 2, 4, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); entry = gtk_entry_new(); + gtk_grid_attach( GTK_GRID( table ), entry, 3, 4, 1, 1 ); + gtk_widget_show( entry ); g_object_set_data( G_OBJECT( dlg ), "rotate_inc", entry ); g_signal_connect( entry, "changed", G_CALLBACK( OnIncrementChanged ), NULL ); - gtk_widget_show( entry ); - gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 4, 5, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( entry, 50, -2 ); // match grid button button = gtk_button_new_with_label( _( "Match Grid" ) ); + gtk_grid_attach( GTK_GRID( table ), button, 3, 5, 1, 1 ); gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnMatchGrid ), NULL ); frame = gtk_frame_new( _( "Texturing" ) ); - gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); + gtk_widget_show( frame ); - table = gtk_table_new( 4, 4, FALSE ); - gtk_widget_show( table ); + table = gtk_grid_new(); + gtk_grid_set_row_spacing( GTK_GRID( table ), 5 ); + gtk_grid_set_column_spacing( GTK_GRID( table ), 5 ); gtk_container_add( GTK_CONTAINER( frame ), table ); - gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); - gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); + gtk_widget_show( table ); label = gtk_label_new( "Brush" ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); label = gtk_label_new( "Patch" ); + gtk_grid_attach( GTK_GRID( table ), label, 0, 2, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); label = gtk_label_new( "Width" ); + gtk_grid_attach( GTK_GRID( table ), label, 2, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); label = gtk_label_new( _( "Height" ) ); + gtk_grid_attach( GTK_GRID( table ), label, 3, 0, 1, 1 ); + gtk_widget_set_halign( label, GTK_ALIGN_START ); gtk_widget_show( label ); - gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1, - (GtkAttachOptions) ( GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - button = gtk_button_new_with_label( _( "Axial" ) ); + axial_button = button = gtk_button_new_with_label( _( "Axial" ) ); + gtk_grid_attach( GTK_GRID( table ), button, 0, 1, 1, 1 ); gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnAxial ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); - button = gtk_button_new_with_label( _( "Fit" ) ); + fit_button = button = gtk_button_new_with_label( _( "Fit" ) ); + gtk_grid_attach( GTK_GRID( table ), button, 1, 1, 1, 1 ); gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnFaceFit ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); - button = gtk_button_new_with_label( _( "CAP" ) ); + button_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); + gtk_size_group_add_widget( button_group, axial_button ); + gtk_size_group_add_widget( button_group, fit_button ); + g_object_unref( button_group ); + + cap_button = button = gtk_button_new_with_label( _( "CAP" ) ); + gtk_grid_attach( GTK_GRID( table ), button, 0, 3, 1, 1 ); gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchdetails ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); - button = gtk_button_new_with_label( _( "Set..." ) ); + set_button = button = gtk_button_new_with_label( _( "Set..." ) ); + gtk_grid_attach( GTK_GRID( table ), button, 1, 3, 1, 1 ); gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchreset ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); - button = gtk_button_new_with_label( _( "Natural" ) ); + nat_button = button = gtk_button_new_with_label( _( "Natural" ) ); + gtk_grid_attach( GTK_GRID( table ), button, 2, 3, 1, 1 ); gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchnatural ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); - button = gtk_button_new_with_label( _( "Fit" ) ); + fit_button = button = gtk_button_new_with_label( _( "Fit" ) ); + gtk_grid_attach( GTK_GRID( table ), button, 3, 3, 1, 1 ); gtk_widget_show( button ); - gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); g_signal_connect( button, "clicked", G_CALLBACK( OnBtnPatchFit ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); + + button_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); + gtk_size_group_add_widget( button_group, cap_button ); + gtk_size_group_add_widget( button_group, set_button ); + gtk_size_group_add_widget( button_group, nat_button ); + gtk_size_group_add_widget( button_group, fit_button ); + g_object_unref( button_group ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ) ), 1, 0 ); + gtk_grid_attach( GTK_GRID( table ), spin, 2, 1, 1, 1 ); gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( spin, 60, -2 ); AddDialogData( spin, &m_nWidth, DLG_SPIN_INT ); spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ) ), 1, 0 ); + gtk_grid_attach( GTK_GRID( table ), spin, 3, 1, 1, 1 ); gtk_widget_show( spin ); - gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2, - (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), - (GtkAttachOptions) ( 0 ), 0, 0 ); - gtk_widget_set_size_request( spin, 60, -2 ); AddDialogData( spin, &m_nHeight, DLG_SPIN_INT ); hbox2 = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 ); - gtk_widget_show( hbox2 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 ); + gtk_widget_show( hbox2 ); button = gtk_button_new_with_label( _( "Done" ) ); - gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnDone ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); button = gtk_button_new_with_label( _( "Apply" ) ); - gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnApply ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); button = gtk_button_new_with_label( _( "Cancel" ) ); - gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnCancel ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); // that's a bit of trashy stuff from Textool-v2 branch #ifdef _DEBUG // FIXME: testing only, scaling in BP mode button = gtk_button_new_with_label( _( "Test" ) ); - gtk_widget_show( button ); gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 ); + gtk_widget_show( button ); g_signal_connect( button, "clicked", G_CALLBACK( OnTest ), NULL ); - gtk_widget_set_size_request( button, 60, -2 ); #endif // Initialize diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index f8dc517b..03e63d87 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1224,6 +1224,44 @@ void Texture_ShowStartupShaders(){ ============================================================================ */ +void Texture_GetSize( qtexture_t *tex, int & nWidth, int & nHeight ){ + if( !tex ) + return; + + if( g_PrefsDlg.m_bFixedTextureSize && g_PrefsDlg.m_nFixedTextureSizeWidth > 0 && g_PrefsDlg.m_nFixedTextureSizeHeight > 0 ) + { + nWidth = g_PrefsDlg.m_nFixedTextureSizeWidth; + nHeight = g_PrefsDlg.m_nFixedTextureSizeHeight; + float ratioWidth = nHeight / nWidth; + float ratioHeight = nWidth / nHeight; + if( tex->width * ratioWidth > tex->height * ratioHeight ) + { + nHeight *= tex->height * 1.0f / tex->width * ratioWidth; + } else + if( tex->height * ratioHeight > tex->width * ratioWidth ) + { + nWidth *= tex->width * 1.0f / tex->height * ratioHeight; + } + } else { + nWidth = (int)( tex->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); + nHeight = (int)( tex->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); + } +} + +void Texture_GetPosSize( qtexture_t *tex, int & nWidth, int & nHeight ){ + if( !tex ) + return; + + if( g_PrefsDlg.m_bFixedTextureSize && g_PrefsDlg.m_nFixedTextureSizeWidth > 0 && g_PrefsDlg.m_nFixedTextureSizeHeight > 0 ) + { + nWidth = g_PrefsDlg.m_nFixedTextureSizeWidth; + nHeight = g_PrefsDlg.m_nFixedTextureSizeHeight; + } else { + nWidth = (int)( tex->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); + nHeight = (int)( tex->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); + } +} + void Texture_StartPos( void ){ //++timo TODO: check use of current_texture and current_row? current_x = 8; @@ -1290,8 +1328,9 @@ IShader* Texture_NextPos( int *x, int *y ){ continue; } - int nWidth = (int)( q->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); - int nHeight = (int)( q->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); + int nWidth; + int nHeight; + Texture_GetPosSize( q, nWidth, nHeight ); if ( current_x + nWidth > g_qeglobals.d_texturewin.width - 8 && current_row ) { // go to the next row unless the texture is the first on the row current_x = 8; current_y -= current_row + FONT_HEIGHT + 4; @@ -1442,8 +1481,9 @@ void SelectTexture( int mx, int my, bool bShift, bool bFitScale ){ if ( !q ) { break; } - int nWidth = (int)( q->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); - int nHeight = (int)( q->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); + int nWidth; + int nHeight; + Texture_GetPosSize( q, nWidth, nHeight ); if ( mx > x && mx - x < nWidth && my < y && y - my < nHeight + FONT_HEIGHT ) { if ( bShift ) { @@ -1613,8 +1653,7 @@ void Texture_Draw( int width, int height ){ break; } - nWidth = (int)( q->width * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); - nHeight = (int)( q->height * ( (float)g_PrefsDlg.m_nTextureScale / 100 ) ); + Texture_GetSize( q, nWidth, nHeight ); if ( y != last_y ) { last_y = y; diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 9620b45b..c7ad6d7f 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -359,6 +359,29 @@ void DrawPathLines( void ){ extern void AssignModel(); +static const char *model_classnames[] = +{ + "misc_model", + "misc_model_static", + "misc_model_breakable", + "misc_gamemodel", + "model_static", +}; + +static const size_t model_classnames_count = sizeof( model_classnames ) / sizeof( *model_classnames ); + +qboolean IsModelEntity( const char *name ) +{ + for ( size_t i = 0; i < model_classnames_count; i++ ) + { + if ( stricmp( name, model_classnames[i] ) == 0 ) + { + return qtrue; + } + } + return qfalse; +} + void CreateEntityFromName( const char* name, const vec3_t origin ){ entity_t *e; brush_t* b; @@ -434,7 +457,7 @@ void CreateEntityFromName( const char* name, const vec3_t origin ){ } Select_Brush( e->brushes.onext ); - if ( ( stricmp( name, "misc_model" ) == 0 ) || ( stricmp( name, "misc_gamemodel" ) == 0 ) || ( strcmpi( name, "model_static" ) == 0 ) ) { + if ( IsModelEntity( name ) == qtrue ) { SetInspectorMode( W_ENTITY ); AssignModel(); } @@ -1179,24 +1202,24 @@ void XYWnd::OnMouseMove( guint32 nFlags, int pointx, int pointy ){ update_xor_rectangle_xy( m_XORRectangle ); } -void XYWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ +void XYWnd::OnMouseWheel( bool bUp, int pointx, int pointy ) { if ( bUp ) { - if ( g_PrefsDlg.m_bMousewheelZoom == TRUE ) { - // improved zoom-in - // frame coverges to part of window where the cursor currently resides - float old_scale = m_fScale; - g_pParentWnd->OnViewZoomin(); - float scale_diff = 1.0 / old_scale - 1.0 / m_fScale; - int nDim1 = ( m_nViewType == YZ ) ? 1 : 0; - int nDim2 = ( m_nViewType == XY ) ? 1 : 2; - m_vOrigin[nDim1] += scale_diff * (pointx - 0.5 * m_nWidth); - m_vOrigin[nDim2] -= scale_diff * (pointy - 0.5 * m_nHeight); - } - else{ - g_pParentWnd->OnViewZoomin(); - } + if ( g_PrefsDlg.m_bMousewheelZoom == TRUE ) { + // improved zoom-in + // frame coverges to part of window where the cursor currently resides + float old_scale = m_fScale; + g_pParentWnd->OnViewZoomin(); + float scale_diff = 1.0 / old_scale - 1.0 / m_fScale; + int nDim1 = ( m_nViewType == YZ ) ? 1 : 0; + int nDim2 = ( m_nViewType == XY ) ? 1 : 2; + m_vOrigin[nDim1] += scale_diff * (pointx - 0.5 * m_nWidth); + m_vOrigin[nDim2] -= scale_diff * (pointy - 0.5 * m_nHeight); + } + else { + g_pParentWnd->OnViewZoomin(); + } } - else{ + else { g_pParentWnd->OnViewZoomout(); } @@ -1516,16 +1539,16 @@ void XYWnd::HandleDrop(){ menu_separator( menu ); nID++; // NOTE: temporary commented out until we put it back in for good (that is with actual features) /* - menu_in_menu = create_menu_in_menu_with_mnemonic (menu, "Group",); - create_menu_item_with_mnemonic (menu_in_menu, "Add to...", - G_CALLBACK (HandleCommand), ID_DROP_GROUP_ADDTO); - create_menu_item_with_mnemonic (menu_in_menu, "Remove", - G_CALLBACK (HandleCommand), ID_DROP_GROUP_REMOVE); - create_menu_item_with_mnemonic (menu_in_menu, "Name...", - G_CALLBACK (HandleCommand), ID_DROP_GROUP_NAME); - menu_separator (menu_in_menu); nID++; - create_menu_item_with_mnemonic (menu_in_menu, "New Group...", - G_CALLBACK (HandleCommand), ID_DROP_GROUP_NEWGROUP); + menu_in_menu = create_menu_in_menu_with_mnemonic (menu, "Group",); + create_menu_item_with_mnemonic (menu_in_menu, "Add to...", + G_CALLBACK (HandleCommand), ID_DROP_GROUP_ADDTO); + create_menu_item_with_mnemonic (menu_in_menu, "Remove", + G_CALLBACK (HandleCommand), ID_DROP_GROUP_REMOVE); + create_menu_item_with_mnemonic (menu_in_menu, "Name...", + G_CALLBACK (HandleCommand), ID_DROP_GROUP_NAME); + menu_separator (menu_in_menu); nID++; + create_menu_item_with_mnemonic (menu_in_menu, "New Group...", + G_CALLBACK (HandleCommand), ID_DROP_GROUP_NEWGROUP); */ create_menu_item_with_mnemonic( menu, "Ungroup Entity", G_CALLBACK( HandleCommand ), ID_SELECTION_UNGROUPENTITY ); @@ -2172,16 +2195,15 @@ void XYWnd::XY_DrawGrid(){ int step, stepx, stepy, colour; step = stepx = stepy = MAX( 64, (int)g_qeglobals.d_gridsize ); - /* - int stepSize = (int)(8 / m_fScale); - if (stepSize > step) - { - int i; - for (i = 1; i < stepSize; i <<= 1) - ; - step = i; - } - */ +/* + int stepSize = (int)(8 / m_fScale); + if (stepSize > step) + { + int i; + for (i = 1; i < stepSize; i <<= 1); + step = i; + } +*/ //Sys_Printf("scale: %f\n", m_fScale); //Sys_Printf("step before: %i\n", step); @@ -2309,8 +2331,9 @@ void XYWnd::XY_DrawGrid(){ // Pixels between left of label and // - left of grid view window (for horizontal grid line label) or // - drawn vertical grid line (for vertical grid line label). - const int pixelsLeftCushion = 2; // IMPORTANT! Must be at least 1 otherwise labels might not be drawn - // because the origin of the text might be off screen due to rounding. + // IMPORTANT! Must be at least 1 otherwise labels might not be drawn, + // because the origin of the text might be off screen due to rounding + const int pixelsLeftCushion = 2; // Pixels between baseline of horizontal grid line label and drawn horizontal grid line. const int pixelsButtomCushion = 2; @@ -2338,9 +2361,9 @@ void XYWnd::XY_DrawGrid(){ qglColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_VIEWNAME] ); } - // we do this part (the old way) only if show_axis is disabled + // We do this part (the old way) only if show_axis is disabled if ( !g_qeglobals.d_savedinfo.show_axis ) { - qglRasterPos2f( m_vOrigin[nDim1] - w + 35 / m_fScale, m_vOrigin[nDim2] + h - 20 / m_fScale ); + qglRasterPos2f( m_vOrigin[nDim1] - w + 35 / m_fScale, m_vOrigin[nDim2] + h - 30 / m_fScale ); char cView[20]; if ( m_nViewType == XY ) { @@ -2350,7 +2373,7 @@ void XYWnd::XY_DrawGrid(){ if ( m_nViewType == XZ ) { strcpy( cView, "XZ Front" ); } - else{ + else { strcpy( cView, "YZ Side" ); } @@ -2359,9 +2382,10 @@ void XYWnd::XY_DrawGrid(){ } if ( g_qeglobals.d_savedinfo.show_axis ) { - // draw two lines with corresponding axis colors to highlight current view - // horizontal line: nDim1 color + // Draw two lines with corresponding axis colors to highlight current view + // Horizontal line: nDim1 color qglLineWidth( 2 ); + qglBegin( GL_LINES ); qglColor3fv( g_qeglobals.d_savedinfo.AxisColors[nDim1] ); qglVertex2f( m_vOrigin[nDim1] - w + 40 / m_fScale, m_vOrigin[nDim2] + h - 45 / m_fScale ); @@ -2374,17 +2398,20 @@ void XYWnd::XY_DrawGrid(){ qglVertex2f( 0, 0 ); qglVertex2f( 0, 32 / m_fScale ); qglEnd(); + qglLineWidth( 1 ); - // now print axis symbols + + // Now print axis symbols qglColor3fv( g_qeglobals.d_savedinfo.AxisColors[nDim1] ); - qglRasterPos2f( m_vOrigin[nDim1] - w + 55 / m_fScale, m_vOrigin[nDim2] + h - 55 / m_fScale ); + qglRasterPos2f( m_vOrigin[nDim1] - w + 57 / m_fScale, m_vOrigin[nDim2] + h - 60 / m_fScale ); gtk_glwidget_print_char( g_AxisName[nDim1] ); - qglRasterPos2f( 28 / m_fScale, -10 / m_fScale ); + qglRasterPos2f( 25 / m_fScale, -15 / m_fScale ); gtk_glwidget_print_char( g_AxisName[nDim1] ); + qglColor3fv( g_qeglobals.d_savedinfo.AxisColors[nDim2] ); - qglRasterPos2f( m_vOrigin[nDim1] - w + 25 / m_fScale, m_vOrigin[nDim2] + h - 30 / m_fScale ); + qglRasterPos2f( m_vOrigin[nDim1] - w + 30 / m_fScale, m_vOrigin[nDim2] + h - 30 / m_fScale ); gtk_glwidget_print_char( g_AxisName[nDim2] ); - qglRasterPos2f( -10 / m_fScale, 28 / m_fScale ); + qglRasterPos2f( -10 / m_fScale, 20 / m_fScale ); gtk_glwidget_print_char( g_AxisName[nDim2] ); } @@ -2632,8 +2659,8 @@ void XYWnd::DrawZIcon( void ){ // can be greatly simplified but per usual i am in a hurry // which is not an excuse, just a fact void XYWnd::PaintSizeInfo( int nDim1, int nDim2, vec3_t vMinBounds, vec3_t vMaxBounds ){ - const char* g_pDimStrings[] = {"x:%.f", "y:%.f", "z:%.f"}; - const char* g_pOrgStrings[] = {"(x:%.f y:%.f)", "(x:%.f z:%.f)", "(y:%.f z:%.f)"}; + const char* g_pDimStrings[] = {"x: %.f", "y: %.f", "z: %.f"}; + const char* g_pOrgStrings[] = {"(x: %.f, y: %.f)", "(x: %.f, z: %.f)", "(y: %.f, z: %.f)"}; CString g_strDim; @@ -2668,7 +2695,7 @@ void XYWnd::PaintSizeInfo( int nDim1, int nDim2, vec3_t vMinBounds, vec3_t vMaxB qglEnd(); - qglRasterPos3f( Betwixt( vMinBounds[nDim1], vMaxBounds[nDim1] ), vMinBounds[nDim2] - 20.0 / m_fScale, 0.0f ); + qglRasterPos3f( Betwixt( vMinBounds[nDim1], vMaxBounds[nDim1] ), vMinBounds[nDim2] - 25.0 / m_fScale, 0.0f ); g_strDim.Format( g_pDimStrings[nDim1], vSize[nDim1] ); gtk_glwidget_print_string( (char *) g_strDim.GetBuffer() );