Skip to content

Commit

Permalink
#5813: Introduce EntityInspector::getPropertyTypeForKey
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 21, 2021
1 parent e11ba0f commit f6e7145
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions radiant/ui/einspector/EntityInspector.cpp
Expand Up @@ -223,7 +223,7 @@ void EntityInspector::onKeyChange(const std::string& key, const std::string& val
// Look up type for this key. First check the property parm map,
// then the entity class itself. If nothing is found, leave blank.
// Get the type for this key if it exists, and the options
auto parms = getPropertyParmsForKey(key);
auto keyType = getPropertyTypeForKey(key);

// Set the values for the row
wxutil::TreeModel::Row row(item, *_kvStore);
Expand All @@ -234,12 +234,12 @@ void EntityInspector::onKeyChange(const std::string& key, const std::string& val
applyMergeActionStyle(key, style);

wxIcon icon;
icon.CopyFromBitmap(parms.type.empty() ? _emptyIcon : _propertyEditorFactory->getBitmapFor(parms.type));
icon.CopyFromBitmap(keyType.empty() ? _emptyIcon : _propertyEditorFactory->getBitmapFor(keyType));

row[_columns.name] = wxVariant(wxDataViewIconText(key, icon));
row[_columns.value] = value;

if (parms.type == "bool")
if (keyType == "bool")
{
// Render a checkbox for boolean values (store an actual bool)
row[_columns.booleanValue] = value == "1";
Expand Down Expand Up @@ -1489,6 +1489,11 @@ EntityInspector::PropertyParms EntityInspector::getPropertyParmsForKey(const std
return {};
}

std::string EntityInspector::getPropertyTypeForKey(const std::string& key)
{
return getPropertyParmsForKey(key).type;
}

void EntityInspector::addClassAttribute(const EntityClassAttribute& a)
{
// Only add properties with values, we don't want the optional
Expand Down
1 change: 1 addition & 0 deletions radiant/ui/einspector/EntityInspector.h
Expand Up @@ -247,6 +247,7 @@ class EntityInspector final :

// Returns property type and option for the given entity key
PropertyParms getPropertyParmsForKey(const std::string& key);
std::string getPropertyTypeForKey(const std::string& key);

// Update tree view contents and property editor
void updateGUIElements();
Expand Down

0 comments on commit f6e7145

Please sign in to comment.