diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp index eeb0cf4be..b57d87454 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp @@ -21,7 +21,9 @@ namespace MaterialEditor { - const char *stockShaders[ 10 ] = + const int NUM_STOCK_SHADERS = 10; + + const char *stockShaders[ NUM_STOCK_SHADERS ] = { "Normal", "Bump", @@ -103,9 +105,8 @@ namespace MaterialEditor subMatCB->addItem( QString::number( i ) ); passCB->setEnabled( true ); - shaderCB->setEnabled( true ); passButton->setEnabled( true ); - shaderButton->setEnabled( true ); + shaderCB->setEnabled( true ); subMatCB->setCurrentIndex( 0 ); @@ -231,8 +232,9 @@ namespace MaterialEditor { if( shaderCB->currentIndex() == 0 ) return; + if( !shaderEditorWidget->load( shaderCB->currentText() ) ) + return; - shaderEditorWidget->load( shaderCB->currentText() ); int result = shaderEditorWidget->exec(); } @@ -269,6 +271,11 @@ namespace MaterialEditor else shaderCB->setCurrentIndex( 0 ); + if( i > NUM_STOCK_SHADERS ) + shaderButton->setEnabled( true ); + else + shaderButton->setEnabled( false ); + Q_EMIT passChanged( text ); } @@ -283,10 +290,10 @@ namespace MaterialEditor CRenderPassProxy pass = m.getPass( p.toUtf8().data() ); pass.setShaderRef( text.toUtf8().data() ); - if( text.isEmpty() ) - shaderButton->setEnabled( false ); - else + if( shaderCB->currentIndex() > NUM_STOCK_SHADERS ) shaderButton->setEnabled( true ); + else + shaderButton->setEnabled( false ); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp index cdfb9ec59..fdee63fbd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp @@ -73,16 +73,17 @@ namespace MaterialEditor setResult( QDialog::Rejected ); } - void ShaderEditorWidget::load( const QString &name ) + bool ShaderEditorWidget::load( const QString &name ) { SShaderInfo info; - nl3dIface->getShaderInfo( name.toUtf8().data(), info ); + if( !nl3dIface->getShaderInfo( name.toUtf8().data(), info ) ) + return false; nameEdit->setText( info.name.c_str() ); descriptionEdit->setPlainText( info.description.c_str() ); vsEdit->setPlainText( info.vp.c_str() ); fsEdit->setPlainText( info.fp.c_str() ); - + return true; } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h index 3179babc3..7017c9212 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h @@ -36,7 +36,7 @@ namespace MaterialEditor void setNel3DInterface( CNel3DInterface *iface ){ nl3dIface = iface; } void reset(); - void load( const QString &name ); + bool load( const QString &name ); private Q_SLOTS: void onOKClicked();