Skip to content

Commit

Permalink
#5910: Disallow manual editing of the classname entity key value
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Apr 3, 2022
1 parent 234b774 commit 2582605
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 17 additions & 4 deletions radiant/ui/einspector/EntityInspector.cpp
Expand Up @@ -671,7 +671,7 @@ std::string EntityInspector::getSelectedKey()

wxutil::TreeModel::Row row(item, *_keyValueTreeView->GetModel());

wxDataViewIconText iconAndName = static_cast<wxDataViewIconText>(row[_columns.name]);
auto iconAndName = static_cast<wxDataViewIconText>(row[_columns.name]);
return iconAndName.GetText().ToStdString();
}

Expand Down Expand Up @@ -732,9 +732,6 @@ void EntityInspector::updateGUIElements()
{
_editorFrame->Enable(entityCanBeUpdated);
_showHelpColumnCheckbox->Enable(true);
_keyEntry->Enable(entityCanBeUpdated);
_valEntry->Enable(entityCanBeUpdated);
_setButton->Enable(entityCanBeUpdated);
_booleanColumn->GetRenderer()->SetMode(entityCanBeUpdated ? wxDATAVIEW_CELL_ACTIVATABLE : wxDATAVIEW_CELL_INERT);

if (!entityCanBeUpdated)
Expand All @@ -751,6 +748,20 @@ void EntityInspector::updateGUIElements()
_showInheritedCheckbox->Enable(false);
_showHelpColumnCheckbox->Enable(false);
}

updateEntryBoxSensitivity();
}

void EntityInspector::updateEntryBoxSensitivity()
{
auto entityCanBeUpdated = canUpdateEntity() && !_entitySelection->empty();
auto selectedKey = getSelectedKey();

auto classNameSelected = getSelectedKey() == "classname";

_keyEntry->Enable(entityCanBeUpdated && !classNameSelected);
_valEntry->Enable(entityCanBeUpdated && !classNameSelected);
_setButton->Enable(entityCanBeUpdated && !classNameSelected);
}

void EntityInspector::updatePrimitiveNumber()
Expand Down Expand Up @@ -1483,6 +1494,8 @@ void EntityInspector::_onTreeViewSelectionChanged(wxDataViewEvent& ev)
// When multiple items are selected, clear the property editor
_currentPropertyEditor.reset();
}

updateEntryBoxSensitivity();
}

EntityInspector::PropertyParms EntityInspector::getPropertyParmsForKey(const std::string& key)
Expand Down
2 changes: 2 additions & 0 deletions radiant/ui/einspector/EntityInspector.h
Expand Up @@ -256,6 +256,8 @@ class EntityInspector final :
// Update tree view contents and property editor
void updateGUIElements();

void updateEntryBoxSensitivity();

// Release the current entity and rescan the selection
void refresh();

Expand Down

0 comments on commit 2582605

Please sign in to comment.