Skip to content

Commit

Permalink
#6021: Further simplifications in AIHeadChooserDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 29, 2022
1 parent 0861893 commit 2231bcc
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions plugins/dm.editing/AIHeadChooserDialog.cpp
Expand Up @@ -152,24 +152,16 @@ std::string AIHeadChooserDialog::getSelectedHead()

void AIHeadChooserDialog::handleSelectionChanged()
{
// Prepare to check for a selection
auto item = _headsView->GetSelection();
_selectedHead = _headsView->GetSelectedDeclName();

// Add button is enabled if there is a selection and it is not a folder.
if (item.IsOk())
{
// Make the OK button active
FindWindowById(wxID_OK, this)->Enable(true);
_description->Enable(true);

// Set the panel text with the usage information
wxutil::TreeModel::Row row(item, *_headsView->GetTreeModel());
_selectedHead = row[_columns.declName];
// Update sensitivity
FindWindowById(wxID_OK, this)->Enable(!_selectedHead.empty());
_description->Enable(!_selectedHead.empty());

if (!_selectedHead.empty())
{
// Lookup the IEntityClass instance
auto ecls = GlobalEntityClassManager().findClass(_selectedHead);

if (ecls)
if (auto ecls = GlobalEntityClassManager().findClass(_selectedHead); ecls)
{
_preview->setModel(ecls->getAttributeValue("model"));
_preview->setSkin(ecls->getAttributeValue("skin"));
Expand All @@ -180,11 +172,7 @@ void AIHeadChooserDialog::handleSelectionChanged()
}
else
{
_selectedHead = "";
_preview->setModel("");

FindWindowById(wxID_OK, this)->Enable(false);
_description->Enable(false);
}
}

Expand Down

0 comments on commit 2231bcc

Please sign in to comment.