Files
o3de/Code/Editor/Plugins/EditorAssetImporter/ImporterRootDisplay.cpp
T
Allen Jackson de97ad6ade {lyn8578} adding UX for assinging a Python scene builder (#7551)
* {lyn8578} adding UX for assinging a Python scene builder

Signed-off-by: Allen Jackson <23512001+jackalbe@users.noreply.github.com>

* improved the Reset and Assign script logic

Signed-off-by: Allen Jackson <23512001+jackalbe@users.noreply.github.com>

* GUI updates to highlight the scene script


Signed-off-by: Allen Jackson <23512001+jackalbe@users.noreply.github.com>

* save off the script file name instead of holding onto the rule
update the header display name separate from setting the scene

Signed-off-by: Allen Jackson <23512001+jackalbe@users.noreply.github.com>
2022-02-15 15:01:43 -06:00

102 lines
2.8 KiB
C++

/*
* 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 <ImporterRootDisplay.h>
#include <ui_ImporterRootDisplay.h>
#include <IEditor.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneUI/CommonWidgets/OverlayWidget.h>
#include <SceneAPI/SceneUI/SceneWidgets/ManifestWidget.h>
#include <AzCore/Debug/Profiler.h>
#include <AzCore/Serialization/SerializeContext.h>
ImporterRootDisplay::ImporterRootDisplay(AZ::SerializeContext* serializeContext, QWidget* parent)
: QWidget(parent)
, ui(new Ui::ImporterRootDisplay())
, m_manifestWidget(new AZ::SceneAPI::UI::ManifestWidget(serializeContext))
, m_hasUnsavedChanges(false)
{
ui->setupUi(this);
ui->m_manifestWidgetAreaLayout->addWidget(m_manifestWidget.data());
ui->m_updateButton->setEnabled(false);
ui->m_updateButton->setProperty("class", "Primary");
connect(ui->m_updateButton, &QPushButton::clicked, this, &ImporterRootDisplay::UpdateClicked);
BusConnect();
}
ImporterRootDisplay::~ImporterRootDisplay()
{
BusDisconnect();
delete ui;
}
AZ::SceneAPI::UI::ManifestWidget* ImporterRootDisplay::GetManifestWidget()
{
return m_manifestWidget.data();
}
void ImporterRootDisplay::SetSceneHeaderText(const QString& headerText)
{
ui->m_filePathText->setText(headerText);
}
void ImporterRootDisplay::SetSceneDisplay(const QString& headerText, const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene)
{
AZ_PROFILE_FUNCTION(Editor);
if (!scene)
{
AZ_Assert(scene, "No scene provided to display.");
return;
}
SetSceneHeaderText(headerText);
HandleSceneWasReset(scene);
ui->m_updateButton->setEnabled(false);
m_hasUnsavedChanges = false;
}
void ImporterRootDisplay::HandleSceneWasReset(const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene>& scene)
{
AZ_PROFILE_FUNCTION(Editor);
// Don't accept updates while the widget is being filled in.
BusDisconnect();
m_manifestWidget->BuildFromScene(scene);
BusConnect();
}
void ImporterRootDisplay::HandleSaveWasSuccessful()
{
ui->m_updateButton->setEnabled(false);
m_hasUnsavedChanges = false;
}
bool ImporterRootDisplay::HasUnsavedChanges() const
{
return m_hasUnsavedChanges;
}
void ImporterRootDisplay::ObjectUpdated(const AZ::SceneAPI::Containers::Scene& scene, const AZ::SceneAPI::DataTypes::IManifestObject* /*target*/, void* /*sender*/)
{
if (m_manifestWidget)
{
if (&scene == m_manifestWidget->GetScene().get())
{
m_hasUnsavedChanges = true;
ui->m_updateButton->setEnabled(true);
}
}
}
#include <moc_ImporterRootDisplay.cpp>