Don't try to edit stock shaders.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent a9a1d17c4f
commit 2e4b6bb6ae

@ -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 );
}
}

@ -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;
}
}

@ -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();

Loading…
Cancel
Save