From 155c2624b1414fc018e8b05a2673c7ecc98630a5 Mon Sep 17 00:00:00 2001 From: Garux Date: Sat, 15 May 2021 18:10:34 +0300 Subject: [PATCH] * .ent: support setting default model value of MiscModel type () --- plugins/entity/miscmodel.cpp | 7 +++++++ radiant/entity.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/entity/miscmodel.cpp b/plugins/entity/miscmodel.cpp index fb3cb984..99a15588 100644 --- a/plugins/entity/miscmodel.cpp +++ b/plugins/entity/miscmodel.cpp @@ -247,6 +247,13 @@ public: m_entity.instanceAttach( path_find_mapfile( path.begin(), path.end() ) ); m_entity.attach( m_keyObservers ); 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 ){ diff --git a/radiant/entity.cpp b/radiant/entity.cpp index 8e315f2d..e5da5ae2 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -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() ) ); if ( model != 0 ) { entity->setKeyValue( entityClass->miscmodel_key(), model );