Atom Tools: Removing unnecessary modules, components, and dead code from SMC
Looking toward creating a bare bones template for a standalone application, simplifying and removing any boilerplate wherever possible. SMC followed patterns established by material editor, subdividing everything into multiple modules, which required manually adding static modules, implementing system components with little to no functionality, and a bunch of unnecessary files for such a simple application. This change deletes unnecessary boilerplate code, moving everything into a single module, making the application class responsible for reflecting classes and buses. Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
-201
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/Document/ShaderManagementConsoleDocumentRequestBus.h>
|
||||
#include <Atom/RPI.Reflect/Shader/ShaderAsset.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentRequestBus.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzQtComponents/Utilities/DesktopUtilities.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Search/Filter.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.h>
|
||||
#include <Window/ShaderManagementConsoleBrowserWidget.h>
|
||||
#include <Window/ui_ShaderManagementConsoleBrowserWidget.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QMessageBox>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
ShaderManagementConsoleBrowserWidget::ShaderManagementConsoleBrowserWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ShaderManagementConsoleBrowserWidget)
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->m_searchWidget->Setup(true, true);
|
||||
m_ui->m_searchWidget->SetFilterState("", AZ::RPI::ShaderAsset::Group, true);
|
||||
m_ui->m_searchWidget->setMinimumSize(QSize(150, 0));
|
||||
|
||||
// Get the asset browser model
|
||||
AssetBrowserModel* assetBrowserModel = nullptr;
|
||||
AssetBrowserComponentRequestBus::BroadcastResult(assetBrowserModel, &AssetBrowserComponentRequests::GetAssetBrowserModel);
|
||||
AZ_Assert(assetBrowserModel, "Failed to get file browser model");
|
||||
|
||||
// Hook up the data set to the tree view
|
||||
m_filterModel = aznew AssetBrowserFilterModel(this);
|
||||
m_filterModel->setSourceModel(assetBrowserModel);
|
||||
m_filterModel->SetFilter(CreateFilter());
|
||||
|
||||
m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel);
|
||||
m_ui->m_assetBrowserTreeViewWidget->SetShowSourceControlIcons(true);
|
||||
m_ui->m_assetBrowserTreeViewWidget->setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
|
||||
|
||||
// Maintains the tree expansion state between runs
|
||||
m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main");
|
||||
|
||||
connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel, &AssetBrowserFilterModel::filterUpdatedSlot);
|
||||
connect(m_filterModel, &AssetBrowserFilterModel::filterChanged, this, [this]()
|
||||
{
|
||||
const bool hasFilter = !m_ui->m_searchWidget->GetFilterString().isEmpty();
|
||||
constexpr bool selectFirstFilteredIndex = true;
|
||||
m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex);
|
||||
});
|
||||
connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::activated, this, &ShaderManagementConsoleBrowserWidget::OpenSelectedEntries);
|
||||
connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, [this]() {
|
||||
const auto& selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets();
|
||||
if (!selectedAssets.empty())
|
||||
{
|
||||
m_ui->m_previewerFrame->Display(selectedAssets.front());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->m_previewerFrame->Clear();
|
||||
}
|
||||
});
|
||||
|
||||
AssetBrowserModelNotificationBus::Handler::BusConnect();
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
ShaderManagementConsoleBrowserWidget::~ShaderManagementConsoleBrowserWidget()
|
||||
{
|
||||
// Maintains the tree expansion state between runs
|
||||
m_ui->m_assetBrowserTreeViewWidget->SaveState();
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusDisconnect();
|
||||
AssetBrowserModelNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
AzToolsFramework::AssetBrowser::FilterConstType ShaderManagementConsoleBrowserWidget::CreateFilter() const
|
||||
{
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
|
||||
QSharedPointer<EntryTypeFilter> sourceFilter(new EntryTypeFilter);
|
||||
sourceFilter->SetEntryType(AssetBrowserEntry::AssetEntryType::Source);
|
||||
|
||||
QSharedPointer<EntryTypeFilter> folderFilter(new EntryTypeFilter);
|
||||
folderFilter->SetEntryType(AssetBrowserEntry::AssetEntryType::Folder);
|
||||
|
||||
QSharedPointer<CompositeFilter> sourceOrFolderFilter(new CompositeFilter(CompositeFilter::LogicOperatorType::OR));
|
||||
sourceOrFolderFilter->AddFilter(sourceFilter);
|
||||
sourceOrFolderFilter->AddFilter(folderFilter);
|
||||
|
||||
QSharedPointer<CompositeFilter> finalFilter(new CompositeFilter(CompositeFilter::LogicOperatorType::AND));
|
||||
finalFilter->AddFilter(sourceOrFolderFilter);
|
||||
finalFilter->AddFilter(m_ui->m_searchWidget->GetFilter());
|
||||
|
||||
return finalFilter;
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleBrowserWidget::OpenSelectedEntries()
|
||||
{
|
||||
const AZStd::vector<AssetBrowserEntry*> entries = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets();
|
||||
|
||||
const int multiSelectPromptThreshold = 10;
|
||||
if (entries.size() >= multiSelectPromptThreshold)
|
||||
{
|
||||
if (QMessageBox::question(
|
||||
QApplication::activeWindow(),
|
||||
QString("Attemptng to open %1 files").arg(entries.size()),
|
||||
"Would you like to open anyway?",
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (const AssetBrowserEntry* entry : entries)
|
||||
{
|
||||
const SourceAssetBrowserEntry* sourceEntry = azrtti_cast<const SourceAssetBrowserEntry*>(entry);
|
||||
if (!sourceEntry)
|
||||
{
|
||||
const ProductAssetBrowserEntry* productEntry = azrtti_cast<const ProductAssetBrowserEntry*>(entry);
|
||||
if (productEntry)
|
||||
{
|
||||
sourceEntry = azrtti_cast<const SourceAssetBrowserEntry*>(productEntry->GetParent());
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceEntry)
|
||||
{
|
||||
if (AzFramework::StringFunc::Path::IsExtension(sourceEntry->GetFullPath().c_str(), AZ::RPI::ShaderVariantListSourceData::Extension))
|
||||
{
|
||||
AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, sourceEntry->GetFullPath());
|
||||
}
|
||||
else
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(sourceEntry->GetFullPath().c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleBrowserWidget::EntryAdded(const AssetBrowserEntry* entry)
|
||||
{
|
||||
if (m_pathToSelect.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const SourceAssetBrowserEntry* sourceEntry = azrtti_cast<const SourceAssetBrowserEntry*>(entry);
|
||||
if (!sourceEntry)
|
||||
{
|
||||
const ProductAssetBrowserEntry* productEntry = azrtti_cast<const ProductAssetBrowserEntry*>(entry);
|
||||
if (productEntry)
|
||||
{
|
||||
sourceEntry = azrtti_cast<const SourceAssetBrowserEntry*>(productEntry->GetParent());
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceEntry)
|
||||
{
|
||||
AZStd::string sourcePath = sourceEntry->GetFullPath();
|
||||
AzFramework::StringFunc::Path::Normalize(sourcePath);
|
||||
if (m_pathToSelect == sourcePath)
|
||||
{
|
||||
m_ui->m_assetBrowserTreeViewWidget->SelectFileAtPath(m_pathToSelect);
|
||||
m_pathToSelect.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleBrowserWidget::OnDocumentOpened(const AZ::Uuid& documentId)
|
||||
{
|
||||
AZStd::string absolutePath;
|
||||
AtomToolsFramework::AtomToolsDocumentRequestBus::EventResult(absolutePath, documentId, &AtomToolsFramework::AtomToolsDocumentRequestBus::Events::GetAbsolutePath);
|
||||
if (!absolutePath.empty())
|
||||
{
|
||||
m_pathToSelect = absolutePath;
|
||||
AzFramework::StringFunc::Path::Normalize(m_pathToSelect);
|
||||
m_ui->m_assetBrowserTreeViewWidget->SelectFileAtPath(m_pathToSelect);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ShaderManagementConsole
|
||||
|
||||
#include <Window/moc_ShaderManagementConsoleBrowserWidget.cpp>
|
||||
+12
-5
@@ -6,15 +6,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/Document/ShaderManagementConsoleDocumentRequestBus.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
#include <AzCore/Name/Name.h>
|
||||
#include <AzQtComponents/Components/WindowDecorationWrapper.h>
|
||||
#include <Document/ShaderManagementConsoleDocumentRequestBus.h>
|
||||
#include <Window/ShaderManagementConsoleWindow.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QHeaderView>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTableView>
|
||||
@@ -39,10 +41,6 @@ namespace ShaderManagementConsole
|
||||
|
||||
setObjectName("ShaderManagementConsoleWindow");
|
||||
|
||||
m_toolBar = new ShaderManagementConsoleToolBar(this);
|
||||
m_toolBar->setObjectName("ToolBar");
|
||||
addToolBar(m_toolBar);
|
||||
|
||||
m_assetBrowser->SetFilterState("", AZ::RPI::ShaderAsset::Group, true);
|
||||
m_assetBrowser->SetOpenHandler([](const AZStd::string& absolutePath) {
|
||||
if (AzFramework::StringFunc::Path::IsExtension(absolutePath.c_str(), AZ::RPI::ShaderVariantListSourceData::Extension))
|
||||
@@ -63,10 +61,19 @@ namespace ShaderManagementConsole
|
||||
m_actionNew->setEnabled(false);
|
||||
m_actionSaveAsChild->setVisible(false);
|
||||
m_actionSaveAsChild->setEnabled(false);
|
||||
m_actionSaveAll->setVisible(false);
|
||||
m_actionSaveAll->setEnabled(false);
|
||||
|
||||
OnDocumentOpened(AZ::Uuid::CreateNull());
|
||||
}
|
||||
|
||||
bool ShaderManagementConsoleWindow::GetOpenDocumentParams(AZStd::string& openPath)
|
||||
{
|
||||
openPath = QFileDialog::getOpenFileName(
|
||||
this, tr("Open Document"), AZ::Utils::GetProjectPath().c_str(), tr("Files (*.%1)").arg(AZ::RPI::ShaderVariantListSourceData::Extension)).toUtf8().constData();
|
||||
return !openPath.empty();
|
||||
}
|
||||
|
||||
QWidget* ShaderManagementConsoleWindow::CreateDocumentTabView(const AZ::Uuid& documentId)
|
||||
{
|
||||
AZStd::unordered_set<AZStd::string> optionNames;
|
||||
|
||||
+1
-3
@@ -14,7 +14,6 @@
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <Window/ToolBar/ShaderManagementConsoleToolBar.h>
|
||||
#include <QStandardItemModel>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#endif
|
||||
@@ -36,8 +35,7 @@ namespace ShaderManagementConsole
|
||||
~ShaderManagementConsoleWindow() = default;
|
||||
|
||||
protected:
|
||||
bool GetOpenDocumentParams(AZStd::string& openPath) override;
|
||||
QWidget* CreateDocumentTabView(const AZ::Uuid& documentId) override;
|
||||
|
||||
ShaderManagementConsoleToolBar* m_toolBar = {};
|
||||
};
|
||||
} // namespace ShaderManagementConsole
|
||||
|
||||
-206
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AssetDatabase/AssetDatabaseConnection.h>
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Edit/Common/JsonUtils.h>
|
||||
#include <Atom/RPI.Public/Material/Material.h>
|
||||
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/UI/UICore/QWidgetSavedState.h>
|
||||
#include <Window/ShaderManagementConsoleWindow.h>
|
||||
#include <Window/ShaderManagementConsoleWindowComponent.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
void ShaderManagementConsoleWindowComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serialize->Class<ShaderManagementConsoleWindowComponent, AZ::Component>()
|
||||
->Version(0);
|
||||
}
|
||||
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<ShaderManagementConsoleRequestBus>("ShaderManagementConsoleRequestBus")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Editor")
|
||||
->Attribute(AZ::Script::Attributes::Module, "shadermanagementconsole")
|
||||
->Event("GetSourceAssetInfo", &ShaderManagementConsoleRequestBus::Events::GetSourceAssetInfo)
|
||||
->Event("FindMaterialAssetsUsingShader", &ShaderManagementConsoleRequestBus::Events::FindMaterialAssetsUsingShader )
|
||||
->Event("GetMaterialInstanceShaderItems", &ShaderManagementConsoleRequestBus::Events::GetMaterialInstanceShaderItems)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
required.push_back(AZ_CRC_CE("AssetBrowserService"));
|
||||
required.push_back(AZ_CRC_CE("PropertyManagerService"));
|
||||
required.push_back(AZ_CRC_CE("SourceControlService"));
|
||||
required.push_back(AZ_CRC_CE("AtomToolsMainWindowSystemService"));
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC_CE("ShaderManagementConsoleWindowService"));
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC_CE("ShaderManagementConsoleWindowService"));
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::Activate()
|
||||
{
|
||||
AzToolsFramework::EditorWindowRequestBus::Handler::BusConnect();
|
||||
AtomToolsFramework::AtomToolsMainWindowFactoryRequestBus::Handler::BusConnect();
|
||||
ShaderManagementConsoleRequestBus::Handler::BusConnect();
|
||||
AzToolsFramework::SourceControlConnectionRequestBus::Broadcast(&AzToolsFramework::SourceControlConnectionRequests::EnableSourceControl, true);
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::Deactivate()
|
||||
{
|
||||
ShaderManagementConsoleRequestBus::Handler::BusDisconnect();
|
||||
AtomToolsFramework::AtomToolsMainWindowFactoryRequestBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorWindowRequestBus::Handler::BusDisconnect();
|
||||
|
||||
m_window.reset();
|
||||
}
|
||||
|
||||
QWidget* ShaderManagementConsoleWindowComponent::GetAppMainWindow()
|
||||
{
|
||||
return m_window.get();
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::CreateMainWindow()
|
||||
{
|
||||
m_assetBrowserInteractions.reset(aznew ShaderManagementConsoleBrowserInteractions);
|
||||
|
||||
m_window.reset(aznew ShaderManagementConsoleWindow);
|
||||
m_window->show();
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleWindowComponent::DestroyMainWindow()
|
||||
{
|
||||
m_window.reset();
|
||||
}
|
||||
|
||||
AZ::Data::AssetInfo ShaderManagementConsoleWindowComponent::GetSourceAssetInfo(const AZStd::string& sourceAssetFileName)
|
||||
{
|
||||
bool result = false;
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
AZStd::string watchFolder;
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
result, &AzToolsFramework::AssetSystem::AssetSystemRequest::GetSourceInfoBySourcePath, sourceAssetFileName.c_str(), assetInfo,
|
||||
watchFolder);
|
||||
AZ_Error(nullptr, result, "Failed to get the asset info for the file: %s.", sourceAssetFileName.c_str());
|
||||
|
||||
return assetInfo;
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::Data::AssetId> ShaderManagementConsoleWindowComponent::FindMaterialAssetsUsingShader(const AZStd::string& shaderFilePath)
|
||||
{
|
||||
// Collect the material types referencing the shader
|
||||
AZStd::vector<AZStd::string> materialTypeSources;
|
||||
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseConnection assetDatabaseConnection;
|
||||
assetDatabaseConnection.OpenDatabase();
|
||||
|
||||
assetDatabaseConnection.QuerySourceDependencyByDependsOnSource(
|
||||
shaderFilePath.c_str(),
|
||||
nullptr,
|
||||
AzToolsFramework::AssetDatabase::SourceFileDependencyEntry::DEP_Any,
|
||||
[&](AzToolsFramework::AssetDatabase::SourceFileDependencyEntry& sourceFileDependencyEntry) {
|
||||
AZStd::string assetExtension;
|
||||
if (AzFramework::StringFunc::Path::GetExtension(sourceFileDependencyEntry.m_source.c_str(), assetExtension, false))
|
||||
{
|
||||
if (assetExtension == "materialtype")
|
||||
{
|
||||
materialTypeSources.push_back(sourceFileDependencyEntry.m_source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
AzToolsFramework::AssetDatabase::ProductDatabaseEntryContainer productDependencies;
|
||||
for (const auto& materialTypeSource : materialTypeSources)
|
||||
{
|
||||
bool result = false;
|
||||
AZ::Data::AssetInfo materialTypeSourceAssetInfo;
|
||||
AZStd::string watchFolder;
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
result,
|
||||
&AzToolsFramework::AssetSystem::AssetSystemRequest::GetSourceInfoBySourcePath,
|
||||
materialTypeSource.c_str(),
|
||||
materialTypeSourceAssetInfo,
|
||||
watchFolder
|
||||
);
|
||||
|
||||
assetDatabaseConnection.QueryDirectReverseProductDependenciesBySourceGuidSubId(
|
||||
materialTypeSourceAssetInfo.m_assetId.m_guid,
|
||||
materialTypeSourceAssetInfo.m_assetId.m_subId,
|
||||
[&](AzToolsFramework::AssetDatabase::ProductDatabaseEntry& entry) {
|
||||
AZStd::string assetExtension;
|
||||
if (AzFramework::StringFunc::Path::GetExtension(entry.m_productName.c_str(), assetExtension, false))
|
||||
{
|
||||
if (assetExtension == "azmaterial")
|
||||
{
|
||||
productDependencies.push_back(entry);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::Data::AssetId> results;
|
||||
results.reserve(productDependencies.size());
|
||||
for (auto product : productDependencies)
|
||||
{
|
||||
assetDatabaseConnection.QueryCombinedByProductID(
|
||||
product.m_productID,
|
||||
[&](AzToolsFramework::AssetDatabase::CombinedDatabaseEntry& combined) {
|
||||
results.push_back({combined.m_sourceGuid, combined.m_subID});
|
||||
return false;
|
||||
},
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::RPI::ShaderCollection::Item> ShaderManagementConsoleWindowComponent::GetMaterialInstanceShaderItems(const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
auto materialAsset = AZ::RPI::AssetUtils::LoadAssetById<AZ::RPI::MaterialAsset>(assetId, AZ::RPI::AssetUtils::TraceLevel::Error);
|
||||
|
||||
auto materialInstance = AZ::RPI::Material::Create(materialAsset);
|
||||
AZ_Error(nullptr, materialAsset, "Failed to get a material instance from product asset id: %s", assetId.ToString<AZStd::string>().c_str());
|
||||
|
||||
if (materialInstance != nullptr)
|
||||
{
|
||||
return AZStd::vector<AZ::RPI::ShaderCollection::Item>(materialInstance->GetShaderCollection().begin(), materialInstance->GetShaderCollection().end());
|
||||
}
|
||||
return AZStd::vector<AZ::RPI::ShaderCollection::Item>();
|
||||
}
|
||||
}
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Atom/Core/ShaderManagementConsoleRequestBus.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
|
||||
#include <AtomToolsFramework/Window/AtomToolsMainWindowFactoryRequestBus.h>
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
|
||||
|
||||
#include <Window/ShaderManagementConsoleBrowserInteractions.h>
|
||||
#include <Window/ShaderManagementConsoleWindow.h>
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
//! ShaderManagementConsoleWindowComponent is the entry point for the Shader Management Console gem user interface, and is mainly
|
||||
//! used for initialization and registration of other classes, including ShaderManagementConsoleWindow.
|
||||
class ShaderManagementConsoleWindowComponent
|
||||
: public AZ::Component
|
||||
, private AtomToolsFramework::AtomToolsMainWindowFactoryRequestBus::Handler
|
||||
, private ShaderManagementConsoleRequestBus::Handler
|
||||
, private AzToolsFramework::EditorWindowRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(ShaderManagementConsoleWindowComponent, "{03976F19-3C74-49FE-A15F-7D3CADBA616C}");
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
|
||||
private:
|
||||
// Temporary structure when generating shader variants.
|
||||
struct ShaderVariantListInfo
|
||||
{
|
||||
AZStd::string m_materialFileName;
|
||||
AZStd::vector<AZ::RPI::ShaderCollection::Item> m_shaderItems;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzToolsFramework::EditorWindowRequests::Bus::Handler
|
||||
QWidget* GetAppMainWindow() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// AtomToolsMainWindowFactoryRequestBus::Handler overrides...
|
||||
void CreateMainWindow() override;
|
||||
void DestroyMainWindow() override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ShaderManagementConsoleRequestBus::Handler overrides...
|
||||
AZ::Data::AssetInfo GetSourceAssetInfo(const AZStd::string& sourceAssetFileName) override;
|
||||
AZStd::vector<AZ::Data::AssetId> FindMaterialAssetsUsingShader(const AZStd::string& shaderFilePath) override;
|
||||
AZStd::vector<AZ::RPI::ShaderCollection::Item> GetMaterialInstanceShaderItems(const AZ::Data::AssetId& assetId) override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Component interface implementation
|
||||
void Init() override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AZStd::unique_ptr<ShaderManagementConsoleWindow> m_window;
|
||||
AZStd::unique_ptr<ShaderManagementConsoleBrowserInteractions> m_assetBrowserInteractions;
|
||||
};
|
||||
}
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/Window/ShaderManagementConsoleWindowModule.h>
|
||||
#include <Window/ShaderManagementConsoleWindowComponent.h>
|
||||
|
||||
void InitShaderManagementConsoleResources()
|
||||
{
|
||||
// Must register qt resources from other modules
|
||||
Q_INIT_RESOURCE(ShaderManagementConsole);
|
||||
Q_INIT_RESOURCE(InspectorWidget);
|
||||
Q_INIT_RESOURCE(AtomToolsAssetBrowser);
|
||||
}
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
ShaderManagementConsoleWindowModule::ShaderManagementConsoleWindowModule()
|
||||
{
|
||||
InitShaderManagementConsoleResources();
|
||||
|
||||
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
ShaderManagementConsoleWindowComponent::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
|
||||
AZ::ComponentTypeList ShaderManagementConsoleWindowModule::GetRequiredSystemComponents() const
|
||||
{
|
||||
return AZ::ComponentTypeList{
|
||||
azrtti_typeid<ShaderManagementConsoleWindowComponent>(),
|
||||
};
|
||||
}
|
||||
} // namespace ShaderManagementConsole
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/PlatformDef.h>
|
||||
#include <Window/ToolBar/ShaderManagementConsoleToolBar.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <AzQtComponents/Components/Widgets/ToolBar.h>
|
||||
#include <QMenu>
|
||||
#include <QToolButton>
|
||||
#include <QAction>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
ShaderManagementConsoleToolBar::ShaderManagementConsoleToolBar(QWidget* parent)
|
||||
: QToolBar(parent)
|
||||
{
|
||||
AzQtComponents::ToolBar::addMainToolBarStyle(this);
|
||||
}
|
||||
|
||||
ShaderManagementConsoleToolBar::~ShaderManagementConsoleToolBar()
|
||||
{
|
||||
}
|
||||
} // namespace ShaderManagementConsole
|
||||
|
||||
#include <Window/ToolBar/moc_ShaderManagementConsoleToolBar.cpp>
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QToolBar>
|
||||
#endif
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
class ModelComboBox;
|
||||
class LightingPresetComboBox;
|
||||
|
||||
class ShaderManagementConsoleToolBar
|
||||
: public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
ShaderManagementConsoleToolBar(QWidget* parent = 0);
|
||||
~ShaderManagementConsoleToolBar();
|
||||
|
||||
private:
|
||||
};
|
||||
} // namespace ShaderManagementConsole
|
||||
Reference in New Issue
Block a user