diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index be795cdb..1faee4b8 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2445,6 +2445,9 @@ void SurfaceInspector_registerShortcuts(){ command_connect_accelerator( "FitTextureHeight" ); command_connect_accelerator( "FitTextureWidthOnly" ); command_connect_accelerator( "FitTextureHeightOnly" ); + command_connect_accelerator( "TextureProjectAxial" ); + command_connect_accelerator( "TextureProjectOrtho" ); + command_connect_accelerator( "TextureProjectCam" ); } void TexBro_registerShortcuts(){ diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index 43192f73..80dfdb1e 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -457,15 +457,26 @@ enum EProjectTexture eProjectCam = 2, }; -void SurfaceInspector_ProjectTexture( EProjectTexture type ){ - UndoableCommand undo( "textureProject" ); +void SurfaceInspector_ProjectTexture( GtkWidget* widget, EProjectTexture type ){ + if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_QUAKE ) + globalWarningStream() << "function doesn't work for *brushes*, having Axial Projection type\n"; //works for patches texdef_t texdef; - texdef.shift[0] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hshiftIncrement.m_spin ) ); - texdef.shift[1] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vshiftIncrement.m_spin ) ); - texdef.scale[0] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); - texdef.scale[1] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); - texdef.rotate = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_rotateIncrement.m_spin ) ); + if( widget ){ //gui buttons + getSurfaceInspector().exportData(); + texdef.shift[0] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hshiftIncrement.m_spin ) ); + texdef.shift[1] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vshiftIncrement.m_spin ) ); + texdef.scale[0] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_hscaleIncrement.m_spin ) ); + texdef.scale[1] = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_vscaleIncrement.m_spin ) ); + texdef.rotate = static_cast( gtk_spin_button_get_value_as_float( getSurfaceInspector().m_rotateIncrement.m_spin ) ); + } + else{ //bind + texdef.scale[0] = texdef.scale[1] = Texdef_getDefaultTextureScale(); + } + + StringOutputStream str( 32 ); + str << "textureProject" << ( type == eProjectAxial? "Axial" : type == eProjectOrtho? "Ortho" : "Cam" ); + UndoableCommand undo( str.c_str() ); Vector3 direction; @@ -485,6 +496,16 @@ void SurfaceInspector_ProjectTexture( EProjectTexture type ){ Select_ProjectTexture( texdef, &direction ); } +void SurfaceInspector_ProjectTexture_eProjectAxial(){ + SurfaceInspector_ProjectTexture( 0, eProjectAxial ); +} +void SurfaceInspector_ProjectTexture_eProjectOrtho(){ + SurfaceInspector_ProjectTexture( 0, eProjectOrtho ); +} +void SurfaceInspector_ProjectTexture_eProjectCam(){ + SurfaceInspector_ProjectTexture( 0, eProjectCam ); +} + void SurfaceInspector_ResetTexture(){ UndoableCommand undo( "textureReset/Cap" ); TextureProjection projection; @@ -533,11 +554,7 @@ static void OnBtnReset( GtkWidget *widget, gpointer data ){ } static void OnBtnProject( GtkWidget *widget, EProjectTexture type ){ - if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_QUAKE ) { - globalWarningStream() << "function doesn't work for *brushes*, having Axial Projection type\n"; //works for patches - } - getSurfaceInspector().exportData(); - SurfaceInspector_ProjectTexture( type ); + SurfaceInspector_ProjectTexture( widget, type ); } @@ -1823,6 +1840,9 @@ void SurfaceInspector_registerCommands(){ GlobalCommands_insert( "FitTextureHeight", FreeCaller() ); GlobalCommands_insert( "FitTextureWidthOnly", FreeCaller() ); GlobalCommands_insert( "FitTextureHeightOnly", FreeCaller() ); + GlobalCommands_insert( "TextureProjectAxial", FreeCaller() ); + GlobalCommands_insert( "TextureProjectOrtho", FreeCaller() ); + GlobalCommands_insert( "TextureProjectCam", FreeCaller() ); GlobalCommands_insert( "SurfaceInspector", FreeCaller(), Accelerator( 'S' ) ); // GlobalCommands_insert( "FaceCopyTexture", FreeCaller() );