* .ent: support setting default model value of MiscModel type (<model key="model" name="Model File" value="ass/spider.mdc">)

This commit is contained in:
Garux 2021-05-15 18:10:34 +03:00
parent 4a53b753b8
commit 155c2624b1
2 changed files with 8 additions and 1 deletions

View File

@ -247,6 +247,13 @@ public:
m_entity.instanceAttach( path_find_mapfile( path.begin(), path.end() ) ); m_entity.instanceAttach( path_find_mapfile( path.begin(), path.end() ) );
m_entity.attach( m_keyObservers ); m_entity.attach( m_keyObservers );
m_entity.attach( m_remapKeysObserver ); m_entity.attach( m_remapKeysObserver );
{ // handle set default model key value
const EntityClass& eclass = m_entity.getEntityClass();
const char *key = eclass.miscmodel_key();
const char *model = EntityClass_valueForKey( eclass, key );
if( !string_empty( model ) && model == m_entity.getKeyValue( key ) ) // default found = no key set
m_model.modelChanged( model );
}
} }
} }
void instanceDetach( const scene::Path& path ){ void instanceDetach( const scene::Path& path ){

View File

@ -498,7 +498,7 @@ void Entity_createFromSelection( const char* name, const Vector3& origin ){
} }
} }
if ( isModel ) { if ( isModel && string_empty( EntityClass_valueForKey( *entityClass, entityClass->miscmodel_key() ) ) ) { // handle set default model key value : no dialog needed
const char* model = misc_model_dialog( GTK_WIDGET( MainFrame_getWindow() ) ); const char* model = misc_model_dialog( GTK_WIDGET( MainFrame_getWindow() ) );
if ( model != 0 ) { if ( model != 0 ) {
entity->setKeyValue( entityClass->miscmodel_key(), model ); entity->setKeyValue( entityClass->miscmodel_key(), model );