Skip to content

Commit

Permalink
Entity Inspector: support unknown entities added during runtime: clea…
Browse files Browse the repository at this point in the history
…r entity comment, deselect entity class list
  • Loading branch information
Garux committed Aug 22, 2023
1 parent 158b724 commit ca3c035
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions radiant/entityinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,12 @@ void SetComment( EntityClass* eclass ){
}

g_current_comment = eclass;

if( eclass == nullptr ){
g_entityClassComment->clear();
return;
}

g_entityClassComment->setPlainText( eclass->comments() );

{ // Catch patterns like "\nstuff :" used to describe keys and spawnflags, and make them bold for readability.
Expand Down Expand Up @@ -872,10 +878,13 @@ void SpawnFlags_setEntityClass( EntityClass* eclass ){
}

void EntityClassList_selectEntityClass( EntityClass* eclass ){
auto list = g_entityClassList->findItems( eclass->name(), Qt::MatchFlag::MatchFixedString );
if( !list.isEmpty() ){
g_entityClassList->setCurrentItem( list.first() );
}
const auto list = g_entityClassList->findItems( eclass->name(), Qt::MatchFlag::MatchFixedString );
g_entityClassList->setCurrentItem( !list.isEmpty()
? list.first()
: nullptr );
// g_entityClassComment is only updated via g_entityClassList selection change
// using special nullprt case to also update it on selection of unknown entity added during runtime
// hence this->EntityClassList_selection_changed()->SetComment() must handle nullptr
}

void EntityInspector_appendAttribute( const EntityClassAttributePair& attributePair, EntityAttribute& attribute ){
Expand Down Expand Up @@ -1115,9 +1124,9 @@ void EntityInspector_clearAllKeyValues(){
// callbacks

static void EntityClassList_selection_changed( QTreeWidgetItem *current, QTreeWidgetItem *previous ){
if( current != nullptr ){
SetComment( current->data( 0, Qt::ItemDataRole::UserRole ).value<EntityClass*>() );
}
SetComment( current != nullptr
? current->data( 0, Qt::ItemDataRole::UserRole ).value<EntityClass*>()
: nullptr );
}

static void EntityProperties_selection_changed( QTreeWidgetItem *item, int column ){
Expand Down

0 comments on commit ca3c035

Please sign in to comment.