Merge pull request #115 from aws-lumberyard-dev/Atom/guthadam/ATOM-15267

[ATOM-15267] Material Editor: Create material dialog respects default standard PBR selection
This commit is contained in:
Guthrie Adams
2021-04-16 17:30:37 -05:00
committed by GitHub
2 changed files with 22 additions and 8 deletions
@@ -60,13 +60,17 @@ namespace MaterialEditor
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequestBus::Events::EnumerateAssets, nullptr, enumerateCB, nullptr);
//Update the material type file info whenever the combo box selection changes
QObject::connect(m_ui->m_materialTypeComboBox, static_cast<void(QComboBox::*)(const int)>(&QComboBox::currentIndexChanged), m_ui->m_materialTypeComboBox, [this](int index) {
QVariant data = m_ui->m_materialTypeComboBox->itemData(index);
m_materialTypeFileInfo = QFileInfo(data.toString());
});
QObject::connect(m_ui->m_materialTypeComboBox, static_cast<void (QComboBox::*)(const int)>(&QComboBox::currentIndexChanged), this, [this]() { UpdateMaterialTypeSelection(); });
QObject::connect(m_ui->m_materialTypeComboBox, &QComboBox::currentTextChanged, this, [this]() { UpdateMaterialTypeSelection(); });
//Select StandardPBR by default but we will later data drive this with editor settings
m_ui->m_materialTypeComboBox->setCurrentText("StandardPBR");
// Select StandardPBR by default but we will later data drive this with editor settings
const int index = m_ui->m_materialTypeComboBox->findText("StandardPBR");
if (index >= 0)
{
m_ui->m_materialTypeComboBox->setCurrentIndex(index);
}
UpdateMaterialTypeSelection();
}
void CreateMaterialDialog::InitMaterialFileSelection()
@@ -88,15 +92,24 @@ namespace MaterialEditor
m_materialFileInfo.absoluteFilePath(),
QString("Material (*.material)"));
//Reject empty or invalid filenames which indicate user cancellation
// Reject empty or invalid filenames which indicate user cancellation
if (!fileInfo.absoluteFilePath().isEmpty())
{
m_materialFileInfo = fileInfo;
m_ui->m_materialFilePicker->setText(m_materialFileInfo.fileName());
}
});
});
}
void CreateMaterialDialog::UpdateMaterialTypeSelection()
{
const int index = m_ui->m_materialTypeComboBox->currentIndex();
if (index >= 0)
{
const QVariant itemData = m_ui->m_materialTypeComboBox->itemData(index);
m_materialTypeFileInfo = QFileInfo(itemData.toString());
}
}
} // namespace MaterialEditor
#include <Window/CreateMaterialDialog/moc_CreateMaterialDialog.cpp>
@@ -36,5 +36,6 @@ namespace MaterialEditor
QScopedPointer<Ui::CreateMaterialDialog> m_ui;
void InitMaterialTypeSelection();
void InitMaterialFileSelection();
void UpdateMaterialTypeSelection();
};
} // namespace MaterialEditor