Did a major refactor of ui to be less dependent on levels
Signed-off-by: srikappa-amzn <srikappa@amazon.com>
This commit is contained in:
+20
-28
@@ -728,19 +728,26 @@ void CCryEditApp::OnFileSave()
|
||||
|
||||
const QScopedValueRollback<bool> rollback(m_savingLevel, true);
|
||||
|
||||
GetIEditor()->GetDocument()->DoFileSave();
|
||||
|
||||
|
||||
bool usePrefabSystemForLevels = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
|
||||
|
||||
if (usePrefabSystemForLevels)
|
||||
|
||||
|
||||
if (!usePrefabSystemForLevels)
|
||||
{
|
||||
auto prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
if (prefabSystemComponentInterface->AreDirtyTemplatesPresent())
|
||||
{
|
||||
GetIEditor()->GetDocument()->ExecuteSavePrefabsDialog();
|
||||
}
|
||||
GetIEditor()->GetDocument()->DoFileSave();
|
||||
}
|
||||
else
|
||||
{
|
||||
//auto prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
auto prefabEditorEntityOwnershipService = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
|
||||
AzToolsFramework::Prefab::TemplateId rootPrefabTemplateId = prefabEditorEntityOwnershipService->GetRootPrefabTemplateId();
|
||||
auto prefabIntegrationInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabIntegrationInterface>::Get();
|
||||
prefabIntegrationInterface->ExecuteSavePrefabsDialog(rootPrefabTemplateId, true);
|
||||
// prefabSystemComponentInterface->AreDirtyTemplatesPresent(rootPrefabTemplateId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3186,18 +3193,12 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
|
||||
}
|
||||
else
|
||||
{
|
||||
using namespace AzToolsFramework::Prefab;
|
||||
auto prefabEditorEntityOwnershipInterface = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
|
||||
auto prefabIntegrationInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabIntegrationInterface>::Get();
|
||||
AzToolsFramework::Prefab::TemplateId rootPrefabTemplateId = prefabEditorEntityOwnershipInterface->GetRootPrefabTemplateId();
|
||||
|
||||
auto prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
auto prefabSaveSelectionDialog = GetIEditor()->GetDocument()->ConstructSaveLevelDialog();
|
||||
|
||||
int prefabSaveSelection = prefabSaveSelectionDialog->exec();
|
||||
QCheckBox* saveAllPrefabsPreferenceCheckBox =
|
||||
prefabSaveSelectionDialog->findChild<QCheckBox*>("SaveAllPrefabsPreferenceCheckBox");
|
||||
QCheckBox* saveAllPrefabsCheckBox = prefabSaveSelectionDialog->findChild<QCheckBox*>("SaveAllPrefabsCheckbox");
|
||||
SavePrefabsPreference savePrefabsPreference = saveAllPrefabsCheckBox->isChecked()
|
||||
? SavePrefabsPreference::SaveAll
|
||||
: SavePrefabsPreference::SaveNone;
|
||||
int prefabSaveSelection =
|
||||
prefabIntegrationInterface->ExecuteClosePrefabDialog(rootPrefabTemplateId);
|
||||
|
||||
// In order to get the accept and reject codes of QDialog and QDialogButtonBox aligned, we do (1-prefabSaveSelection) here.
|
||||
switch (1 - prefabSaveSelection)
|
||||
@@ -3210,16 +3211,7 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled)
|
||||
wasCreateLevelOperationCancelled = true;
|
||||
return false;
|
||||
}
|
||||
if (saveAllPrefabsPreferenceCheckBox->checkState() == Qt::CheckState::Checked)
|
||||
{
|
||||
gSettings.SetSavePrefabsPreference(savePrefabsPreference);
|
||||
gSettings.Save();
|
||||
}
|
||||
if (savePrefabsPreference == SavePrefabsPreference::SaveAll)
|
||||
{
|
||||
prefabSystemComponentInterface->SaveAllDirtyTemplates();
|
||||
}
|
||||
bIsDocModified = prefabSystemComponentInterface->AreDirtyTemplatesPresent();
|
||||
bIsDocModified = false;
|
||||
break;
|
||||
case QDialogButtonBox::RejectRole:
|
||||
wasCreateLevelOperationCancelled = true;
|
||||
|
||||
+26
-219
@@ -15,8 +15,14 @@
|
||||
#include <QDateTime>
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGroupBox>
|
||||
#include <QListWidget>
|
||||
#include <QScrollArea>
|
||||
#include <QSizePolicy>
|
||||
#include <AzQtComponents/Components/FlowLayout.h>
|
||||
#include <AzQtComponents/Components/StyleManager.h>
|
||||
#include <AzQtComponents/Components/Widgets/CheckBox.h>
|
||||
#include <AzQtComponents/Components/Widgets/CardHeader.h>
|
||||
|
||||
// AzCore
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
@@ -34,9 +40,6 @@
|
||||
#include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
|
||||
#include <AzToolsFramework/UI/Layer/NameConflictWarning.hxx>
|
||||
#include <AzToolsFramework/API/EditorLevelNotificationBus.h>
|
||||
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
||||
|
||||
// Editor
|
||||
#include "Settings.h"
|
||||
@@ -138,6 +141,14 @@ CCryEditDoc::CCryEditDoc()
|
||||
RegisterConsoleVariables();
|
||||
|
||||
MainWindow::instance()->GetActionManager()->RegisterActionHandler(ID_FILE_SAVE_AS, this, &CCryEditDoc::OnFileSaveAs);
|
||||
m_prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
AZ_Assert(m_prefabSystemComponentInterface, "PrefabSystemComponentInterface is not found.");
|
||||
m_prefabEditorEntityOwnershipInterface = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
|
||||
AZ_Assert(m_prefabEditorEntityOwnershipInterface, "PrefabEditorEntityOwnershipInterface is not found.");
|
||||
m_prefabLoaderInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabLoaderInterface>::Get();
|
||||
AZ_Assert(m_prefabLoaderInterface, "PrefabLoaderInterface is not found.");
|
||||
m_prefabIntegrationInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabIntegrationInterface>::Get();
|
||||
AZ_Assert(m_prefabIntegrationInterface, "PrefabIntegrationInterface is not found.");
|
||||
}
|
||||
|
||||
CCryEditDoc::~CCryEditDoc()
|
||||
@@ -699,29 +710,18 @@ bool CCryEditDoc::SaveModified()
|
||||
{
|
||||
using namespace AzToolsFramework::Prefab;
|
||||
|
||||
auto prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
auto prefabSaveSelectionDialog = ConstructSaveLevelDialog();
|
||||
|
||||
int prefabSaveSelection = prefabSaveSelectionDialog->exec();
|
||||
QCheckBox* saveAllPrefabsPreferenceCheckBox = prefabSaveSelectionDialog->findChild<QCheckBox*>("SaveAllPrefabsPreferenceCheckBox");
|
||||
QCheckBox* saveAllPrefabsCheckBox = prefabSaveSelectionDialog->findChild<QCheckBox*>("SaveAllPrefabsCheckbox");
|
||||
SavePrefabsPreference savePrefabsPreference =
|
||||
saveAllPrefabsCheckBox->isChecked() ? SavePrefabsPreference::SaveAll : SavePrefabsPreference::SaveNone;
|
||||
TemplateId rootPrefabTemplateId = m_prefabEditorEntityOwnershipInterface->GetRootPrefabTemplateId();
|
||||
if (!m_prefabSystemComponentInterface->AreDirtyTemplatesPresent(rootPrefabTemplateId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int prefabSaveSelection = m_prefabIntegrationInterface->ExecuteClosePrefabDialog(rootPrefabTemplateId);
|
||||
|
||||
// In order to get the accept and reject codes of QDialog and QDialogButtonBox aligned, we do (1-prefabSaveSelection) here.
|
||||
switch (1 - prefabSaveSelection)
|
||||
{
|
||||
case QDialogButtonBox::AcceptRole:
|
||||
DoFileSave();
|
||||
if (saveAllPrefabsPreferenceCheckBox->checkState() == Qt::CheckState::Checked)
|
||||
{
|
||||
gSettings.SetSavePrefabsPreference(savePrefabsPreference);
|
||||
gSettings.Save();
|
||||
}
|
||||
if (savePrefabsPreference == SavePrefabsPreference::SaveAll)
|
||||
{
|
||||
prefabSystemComponentInterface->SaveAllDirtyTemplates();
|
||||
}
|
||||
return true;
|
||||
case QDialogButtonBox::RejectRole:
|
||||
return false;
|
||||
@@ -749,11 +749,9 @@ void CCryEditDoc::OnFileSaveAs()
|
||||
usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled);
|
||||
if (usePrefabSystemForLevels)
|
||||
{
|
||||
auto prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
if (prefabSystemComponentInterface->AreDirtyTemplatesPresent())
|
||||
{
|
||||
ExecuteSavePrefabsDialog();
|
||||
}
|
||||
AzToolsFramework::Prefab::TemplateId rootPrefabTemplateId =
|
||||
m_prefabEditorEntityOwnershipInterface->GetRootPrefabTemplateId();
|
||||
SetModifiedFlag(m_prefabSystemComponentInterface->AreDirtyTemplatesPresent(rootPrefabTemplateId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1311,8 +1309,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto prefabEditorEntityOwnershipInterface = AZ::Interface<AzToolsFramework::PrefabEditorEntityOwnershipInterface>::Get();
|
||||
if (prefabEditorEntityOwnershipInterface)
|
||||
if (m_prefabEditorEntityOwnershipInterface)
|
||||
{
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
AZ_Assert(fileIO, "No File IO implementation available");
|
||||
@@ -1323,7 +1320,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename)
|
||||
if (openResult)
|
||||
{
|
||||
AZ::IO::FileIOStream stream(tempSaveFileHandle, AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeBinary, false);
|
||||
contentsAllSaved = prefabEditorEntityOwnershipInterface->SaveToStream(stream, AZStd::string_view(filenameStrData.data(), filenameStrData.size()));
|
||||
contentsAllSaved = m_prefabEditorEntityOwnershipInterface->SaveToStream(stream, AZStd::string_view(filenameStrData.data(), filenameStrData.size()));
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
@@ -2264,196 +2261,6 @@ void CCryEditDoc::OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAsset
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AZStd::shared_ptr<QDialog> CCryEditDoc::ConstructSaveLevelDialog()
|
||||
{
|
||||
using namespace AzToolsFramework::Prefab;
|
||||
auto prefabLoaderInterface = AZ::Interface<PrefabLoaderInterface>::Get();
|
||||
SavePrefabsPreference savePrefabsPreference = prefabLoaderInterface->GetSavePrefabsPreference();
|
||||
|
||||
AZStd::shared_ptr<QDialog> saveModifiedMessageBox = AZStd::make_shared<QDialog>(AzToolsFramework::GetActiveWindow());
|
||||
AZStd::weak_ptr<QDialog> saveModifiedMessageBoxWeakPtr(saveModifiedMessageBox);
|
||||
// saveModifiedMessageBox.overrideWindowFlags((saveModifiedMessageBox.windowFlags()) & ~Qt::WindowCloseButtonHint);
|
||||
saveModifiedMessageBox->setObjectName("SaveDirtyLevelDialog");
|
||||
|
||||
// Main Content section begins.
|
||||
QVBoxLayout* contentLayout = new QVBoxLayout(saveModifiedMessageBox.get());
|
||||
QFrame* levelEntitiesSaveQuestionFrame = new QFrame(saveModifiedMessageBox.get());
|
||||
QHBoxLayout* levelEntitiesSaveQuestionLayout = new QHBoxLayout(saveModifiedMessageBox.get());
|
||||
levelEntitiesSaveQuestionFrame->setObjectName("LevelEntitiesSaveQuestionFrame");
|
||||
|
||||
// Add a warning icon next to save entities question.
|
||||
levelEntitiesSaveQuestionFrame->setLayout(levelEntitiesSaveQuestionLayout);
|
||||
QPixmap warningIcon(QString(":/Notifications/warning.svg"));
|
||||
QLabel* warningIconContainer = new QLabel();
|
||||
warningIconContainer->setPixmap(warningIcon);
|
||||
warningIconContainer->setFixedWidth(warningIcon.width());
|
||||
levelEntitiesSaveQuestionLayout->addWidget(warningIconContainer);
|
||||
|
||||
// Ask user if they want to save entities in level.
|
||||
QLabel* levelEntitiesSaveQuestionLabel = new QLabel("Do you want to save unsaved entities in the level?");
|
||||
levelEntitiesSaveQuestionLayout->addWidget(levelEntitiesSaveQuestionLabel);
|
||||
contentLayout->addWidget(levelEntitiesSaveQuestionFrame);
|
||||
|
||||
// Ask user if they want to save unsaved prefabs in the level too.
|
||||
QCheckBox* saveAllPrefabsCheckbox = new QCheckBox("Save all unsaved prefabs in the level too.");
|
||||
AzQtComponents::CheckBox::applyToggleSwitchStyle(saveAllPrefabsCheckbox);
|
||||
saveAllPrefabsCheckbox->setObjectName("SaveAllPrefabsCheckbox");
|
||||
if (savePrefabsPreference == SavePrefabsPreference::SaveAll)
|
||||
{
|
||||
saveAllPrefabsCheckbox->setCheckState(Qt::CheckState::Checked);
|
||||
}
|
||||
QObject::connect(
|
||||
saveAllPrefabsCheckbox, &QCheckBox::stateChanged,
|
||||
[&savePrefabsPreference](int state)
|
||||
{
|
||||
savePrefabsPreference = static_cast<Qt::CheckState>(state) == Qt::CheckState::Checked ? SavePrefabsPreference::SaveAll
|
||||
: SavePrefabsPreference::SaveNone;
|
||||
});
|
||||
contentLayout->addWidget(saveAllPrefabsCheckbox);
|
||||
|
||||
// Footer section begins.
|
||||
QFrame* footerSeparatorLine = new QFrame();
|
||||
footerSeparatorLine->setObjectName("FooterSeparatorLine");
|
||||
footerSeparatorLine->setFrameShape(QFrame::HLine);
|
||||
contentLayout->addWidget(footerSeparatorLine);
|
||||
QHBoxLayout* footerLayout = new QHBoxLayout(saveModifiedMessageBox.get());
|
||||
|
||||
// Provide option for user to remember their prefab save preference.
|
||||
QCheckBox* saveAllPrefabsPreferenceCheckBox = new QCheckBox("Remember my preference.");
|
||||
saveAllPrefabsPreferenceCheckBox->setObjectName("SaveAllPrefabsPreferenceCheckBox");
|
||||
AzQtComponents::CheckBox::applyToggleSwitchStyle(saveAllPrefabsPreferenceCheckBox);
|
||||
if (savePrefabsPreference != SavePrefabsPreference::Unspecified)
|
||||
{
|
||||
saveAllPrefabsPreferenceCheckBox->setCheckState(Qt::CheckState::Checked);
|
||||
}
|
||||
QVBoxLayout* footerPreferenceLayout = new QVBoxLayout(saveModifiedMessageBox.get());
|
||||
footerPreferenceLayout->addWidget(saveAllPrefabsPreferenceCheckBox);
|
||||
QLabel* prefabSavePreferenceHint = new QLabel("You can change this anytime in Edit -> Editor Settings -> GlobalPreferences.");
|
||||
prefabSavePreferenceHint->setObjectName("PrefabSavePreferenceHint");
|
||||
footerPreferenceLayout->addWidget(prefabSavePreferenceHint);
|
||||
footerLayout->addLayout(footerPreferenceLayout);
|
||||
QDialogButtonBox* prefabSaveConfirmationButtons =
|
||||
new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Discard | QDialogButtonBox::Cancel);
|
||||
footerLayout->addWidget(prefabSaveConfirmationButtons);
|
||||
contentLayout->addLayout(footerLayout);
|
||||
connect(prefabSaveConfirmationButtons, &QDialogButtonBox::accepted, saveModifiedMessageBox.get(), &QDialog::accept);
|
||||
connect(prefabSaveConfirmationButtons, &QDialogButtonBox::rejected, saveModifiedMessageBox.get(), &QDialog::reject);
|
||||
connect(
|
||||
prefabSaveConfirmationButtons, &QDialogButtonBox::clicked, saveModifiedMessageBox.get(),
|
||||
[saveModifiedMessageBoxWeakPtr, prefabSaveConfirmationButtons](QAbstractButton* button)
|
||||
{
|
||||
int prefabSaveSelection = prefabSaveConfirmationButtons->buttonRole(button);
|
||||
saveModifiedMessageBoxWeakPtr.lock()->done(prefabSaveSelection);
|
||||
});
|
||||
AzQtComponents::StyleManager::setStyleSheet(saveModifiedMessageBox.get(), QStringLiteral("style:Editor.qss"));
|
||||
return saveModifiedMessageBox;
|
||||
}
|
||||
|
||||
void CCryEditDoc::ExecuteSavePrefabsDialog()
|
||||
{
|
||||
using namespace AzToolsFramework::Prefab;
|
||||
|
||||
auto prefabSystemComponentInterface = AZ::Interface<AzToolsFramework::Prefab::PrefabSystemComponentInterface>::Get();
|
||||
auto prefabLoaderInterface = AZ::Interface<PrefabLoaderInterface>::Get();
|
||||
SavePrefabsPreference savePrefabsPreference = prefabLoaderInterface->GetSavePrefabsPreference();
|
||||
|
||||
if (savePrefabsPreference == SavePrefabsPreference::SaveAll)
|
||||
{
|
||||
prefabSystemComponentInterface->SaveAllDirtyTemplates();
|
||||
SetModifiedFlag(false);
|
||||
}
|
||||
else if (savePrefabsPreference == SavePrefabsPreference::SaveNone)
|
||||
{
|
||||
if (prefabSystemComponentInterface->AreDirtyTemplatesPresent())
|
||||
{
|
||||
SetModifiedFlag(true);
|
||||
}
|
||||
}
|
||||
else // SavePrefabsPreference::Unspecified
|
||||
{
|
||||
QDialog saveModifiedMessageBox(AzToolsFramework::GetActiveWindow());
|
||||
|
||||
// Main Content section begins.
|
||||
saveModifiedMessageBox.setObjectName("SaveAllPrefabsDialog");
|
||||
QBoxLayout* contentLayout = new QVBoxLayout(&saveModifiedMessageBox);
|
||||
QFrame* levelSavedMessageFrame = new QFrame(&saveModifiedMessageBox);
|
||||
QHBoxLayout* levelSavedMessageLayout = new QHBoxLayout(&saveModifiedMessageBox);
|
||||
levelSavedMessageFrame->setObjectName("LevelSavedMessageFrame");
|
||||
|
||||
// Add a checkMark icon next to the level entities saved message.
|
||||
QPixmap checkMarkIcon(QString(":/Notifications/checkmark.svg"));
|
||||
QLabel* levelSavedSuccessfullyIconContainer = new QLabel();
|
||||
levelSavedSuccessfullyIconContainer->setPixmap(checkMarkIcon);
|
||||
levelSavedSuccessfullyIconContainer->setFixedWidth(checkMarkIcon.width());
|
||||
|
||||
// Add a message that level entities are saved successfully.
|
||||
QLabel* levelSavedSuccessfullyLabel = new QLabel("All entities inside level have been saved successfully.");
|
||||
levelSavedSuccessfullyLabel->setObjectName("LevelSavedSuccessfullyLabel");
|
||||
levelSavedMessageLayout->addWidget(levelSavedSuccessfullyIconContainer);
|
||||
levelSavedMessageLayout->addWidget(levelSavedSuccessfullyLabel);
|
||||
levelSavedMessageFrame->setLayout(levelSavedMessageLayout);
|
||||
|
||||
QFrame* prefabSaveQuestionFrame = new QFrame(&saveModifiedMessageBox);
|
||||
QHBoxLayout* prefabSaveQuestionLayout = new QHBoxLayout(&saveModifiedMessageBox);
|
||||
|
||||
// Add a warning icon next to prefabs save question.
|
||||
QLabel* warningIconContainer = new QLabel();
|
||||
QPixmap warningIcon(QString(":/Notifications/warning.svg"));
|
||||
warningIconContainer->setPixmap(warningIcon);
|
||||
warningIconContainer->setFixedWidth(warningIcon.width());
|
||||
prefabSaveQuestionLayout->addWidget(warningIconContainer);
|
||||
|
||||
// Ask if user wants all prefabs saved.
|
||||
QLabel* prefabSaveQuestionLabel = new QLabel("Do you want to save all unsaved prefabs?");
|
||||
prefabSaveQuestionFrame->setObjectName("PrefabSaveQuestionFrame");
|
||||
prefabSaveQuestionLayout->addWidget(prefabSaveQuestionLabel);
|
||||
prefabSaveQuestionFrame->setLayout(prefabSaveQuestionLayout);
|
||||
contentLayout->addWidget(levelSavedMessageFrame);
|
||||
contentLayout->addWidget(prefabSaveQuestionFrame);
|
||||
|
||||
// Footer section begins.
|
||||
QFrame* footerSeparatorLine = new QFrame();
|
||||
footerSeparatorLine->setObjectName("FooterSeparatorLine");
|
||||
footerSeparatorLine->setFrameShape(QFrame::HLine);
|
||||
contentLayout->addWidget(footerSeparatorLine);
|
||||
QHBoxLayout* footerLayout = new QHBoxLayout(&saveModifiedMessageBox);
|
||||
|
||||
// Provide option for user to remember their prefab save preference.
|
||||
QCheckBox* saveAllPrefabsPreference = new QCheckBox("Remember my preference.");
|
||||
AzQtComponents::CheckBox::applyToggleSwitchStyle(saveAllPrefabsPreference);
|
||||
QVBoxLayout* footerPreferenceLayout = new QVBoxLayout(&saveModifiedMessageBox);
|
||||
footerPreferenceLayout->addWidget(saveAllPrefabsPreference);
|
||||
QLabel* prefabSavePreferenceHint = new QLabel("You can change this anytime in Edit -> Editor Settings -> GlobalPreferences.");
|
||||
prefabSavePreferenceHint->setObjectName("PrefabSavePreferenceHint");
|
||||
footerPreferenceLayout->addWidget(prefabSavePreferenceHint);
|
||||
footerLayout->addLayout(footerPreferenceLayout);
|
||||
QDialogButtonBox* prefabSaveConfirmationButtons = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::No);
|
||||
footerLayout->addWidget(prefabSaveConfirmationButtons);
|
||||
contentLayout->addLayout(footerLayout);
|
||||
connect(prefabSaveConfirmationButtons, &QDialogButtonBox::accepted, &saveModifiedMessageBox, &QDialog::accept);
|
||||
connect(prefabSaveConfirmationButtons, &QDialogButtonBox::rejected, &saveModifiedMessageBox, &QDialog::reject);
|
||||
AzQtComponents::StyleManager::setStyleSheet(saveModifiedMessageBox.parentWidget(), QStringLiteral("style:Editor.qss"));
|
||||
|
||||
int prefabSaveSelection = saveModifiedMessageBox.exec();
|
||||
|
||||
if (saveAllPrefabsPreference->checkState() == Qt::CheckState::Checked)
|
||||
{
|
||||
gSettings.SetSavePrefabsPreference(savePrefabsPreference);
|
||||
gSettings.Save();
|
||||
}
|
||||
switch (prefabSaveSelection)
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
prefabSystemComponentInterface->SaveAllDirtyTemplates();
|
||||
SetModifiedFlag(false);
|
||||
break;
|
||||
case QDialog::Rejected:
|
||||
SetModifiedFlag(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void CryEditDocFuncsHandler::Reflect(AZ::ReflectContext* context)
|
||||
|
||||
@@ -13,8 +13,13 @@
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "DocMultiArchive.h"
|
||||
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
|
||||
#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
|
||||
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationInterface.h>
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzQtComponents/Components/Widgets/Card.h>
|
||||
#include <TimeValue.h>
|
||||
#include <IEditor.h>
|
||||
#endif
|
||||
@@ -104,12 +109,6 @@ public: // Create from serialization only
|
||||
|
||||
bool CanCloseFrame();
|
||||
|
||||
//! Returns a Modal containing options to save the current level.
|
||||
AZStd::shared_ptr<QDialog> ConstructSaveLevelDialog();
|
||||
|
||||
//! Executes a Modal asking users about their prefabs save preference.
|
||||
void ExecuteSavePrefabsDialog();
|
||||
|
||||
enum class FetchPolicy
|
||||
{
|
||||
DELETE_FOLDER,
|
||||
@@ -215,6 +214,10 @@ protected:
|
||||
const char* m_envProbeSliceRelativePath = "EngineAssets/Slices/DefaultLevelSetup.slice";
|
||||
const float m_envProbeHeight = 200.0f;
|
||||
bool m_hasErrors = false; ///< This is used to warn the user that they may lose work when they go to save.
|
||||
AzToolsFramework::Prefab::PrefabSystemComponentInterface* m_prefabSystemComponentInterface = nullptr;
|
||||
AzToolsFramework::PrefabEditorEntityOwnershipInterface* m_prefabEditorEntityOwnershipInterface = nullptr;
|
||||
AzToolsFramework::Prefab::PrefabLoaderInterface* m_prefabLoaderInterface = nullptr;
|
||||
AzToolsFramework::Prefab::PrefabIntegrationInterface* m_prefabIntegrationInterface = nullptr;
|
||||
};
|
||||
|
||||
class CAutoDocNotReady
|
||||
|
||||
@@ -42,9 +42,9 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
|
||||
->Field("EnableSceneInspector", &GeneralSettings::m_enableSceneInspector)
|
||||
->Field("RestoreViewportCamera", &GeneralSettings::m_restoreViewportCamera);
|
||||
|
||||
serialize.Class<PrefabSettings>()
|
||||
serialize.Class<GlobalSaveSettings>()
|
||||
->Version(1)
|
||||
->Field("SavePrefabsPreference", &PrefabSettings::m_savePrefabsPreference);
|
||||
->Field("SaveAllPrefabsPreference", &GlobalSaveSettings::m_saveAllPrefabsPreference);
|
||||
|
||||
serialize.Class<Messaging>()
|
||||
->Version(2)
|
||||
@@ -68,7 +68,7 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
|
||||
serialize.Class<CEditorPreferencesPage_General>()
|
||||
->Version(1)
|
||||
->Field("General Settings", &CEditorPreferencesPage_General::m_generalSettings)
|
||||
->Field("Prefab Settings", &CEditorPreferencesPage_General::m_prefabSettings)
|
||||
->Field("Global Save Settings", &CEditorPreferencesPage_General::m_globalSaveSettings)
|
||||
->Field("Messaging", &CEditorPreferencesPage_General::m_messaging)
|
||||
->Field("Undo", &CEditorPreferencesPage_General::m_undo)
|
||||
->Field("Deep Selection", &CEditorPreferencesPage_General::m_deepSelection)
|
||||
@@ -97,13 +97,13 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_restoreViewportCamera, EditorPreferencesGeneralRestoreViewportCameraSettingName, "Keep the original editor viewport transform when exiting game mode.")
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_enableSceneInspector, "Enable Scene Inspector (EXPERIMENTAL)", "Enable the option to inspect the internal data loaded from scene files like .fbx. This is an experimental feature. Restart the Scene Settings if the option is not visible under the Help menu.");
|
||||
|
||||
editContext->Class<PrefabSettings>("Prefabs", "")
|
||||
editContext->Class<GlobalSaveSettings>("Global Save Settings (File > Save & Ctrl+S)", "")
|
||||
->DataElement(
|
||||
AZ::Edit::UIHandlers::ComboBox, &PrefabSettings::m_savePrefabsPreference, "Save Prefabs Preference",
|
||||
"When saving levels, this option controls whether and how prefabs should be saved along with the level.")
|
||||
->EnumAttribute(AzToolsFramework::Prefab::SavePrefabsPreference::Unspecified, "Unspecified")
|
||||
->EnumAttribute(AzToolsFramework::Prefab::SavePrefabsPreference::SaveAll, "Save All")
|
||||
->EnumAttribute(AzToolsFramework::Prefab::SavePrefabsPreference::SaveNone, "Save None");
|
||||
AZ::Edit::UIHandlers::ComboBox, &GlobalSaveSettings::m_saveAllPrefabsPreference, "Save Prefabs Preference",
|
||||
"This option controls whether prefabs should be saved along with the level")
|
||||
->EnumAttribute(AzToolsFramework::Prefab::SaveAllPrefabsPreference::AskEveryTime, "Ask every time")
|
||||
->EnumAttribute(AzToolsFramework::Prefab::SaveAllPrefabsPreference::SaveAll, "Save all")
|
||||
->EnumAttribute(AzToolsFramework::Prefab::SaveAllPrefabsPreference::SaveNone, "Save none");
|
||||
|
||||
editContext->Class<Messaging>("Messaging", "")
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &Messaging::m_showDashboard, "Show Welcome to Open 3D Engine at startup", "Show Welcome to Open 3D Engine at startup")
|
||||
@@ -128,7 +128,7 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize)
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20))
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_generalSettings, "General Settings", "General Editor Preferences")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_prefabSettings, "Prefabs", "Prefab Settings")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_globalSaveSettings, "Global Save Settings", "Global Save Settings")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_messaging, "Messaging", "Messaging")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_undo, "Undo", "Undo Preferences")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_General::m_deepSelection, "Selection", "Selection")
|
||||
@@ -176,7 +176,7 @@ void CEditorPreferencesPage_General::OnApply()
|
||||
}
|
||||
|
||||
//prefabs
|
||||
gSettings.prefabSettings.savePrefabsPreference = m_prefabSettings.m_savePrefabsPreference;
|
||||
gSettings.globalSaveSettings.saveAllPrefabsPreference = m_globalSaveSettings.m_saveAllPrefabsPreference;
|
||||
|
||||
//undo
|
||||
gSettings.undoLevels = m_undo.m_undoLevels;
|
||||
@@ -208,7 +208,7 @@ void CEditorPreferencesPage_General::InitializeSettings()
|
||||
m_generalSettings.m_toolbarIconSize = static_cast<AzQtComponents::ToolBar::ToolBarIconSize>(gSettings.gui.nToolbarIconSize);
|
||||
|
||||
//prefabs
|
||||
m_prefabSettings.m_savePrefabsPreference = gSettings.prefabSettings.savePrefabsPreference;
|
||||
m_globalSaveSettings.m_saveAllPrefabsPreference = gSettings.globalSaveSettings.saveAllPrefabsPreference;
|
||||
|
||||
//Messaging
|
||||
m_messaging.m_showDashboard = gSettings.bShowDashboardAtStartup;
|
||||
|
||||
@@ -58,10 +58,10 @@ private:
|
||||
bool m_enableSceneInspector;
|
||||
};
|
||||
|
||||
struct PrefabSettings
|
||||
struct GlobalSaveSettings
|
||||
{
|
||||
AZ_TYPE_INFO(PrefabSettings, "{E297DAE3-3985-4BC2-8B43-45F3B1522F6B}");
|
||||
AzToolsFramework::Prefab::SavePrefabsPreference m_savePrefabsPreference;
|
||||
AZ_TYPE_INFO(GlobalSaveSettings, "{E297DAE3-3985-4BC2-8B43-45F3B1522F6B}");
|
||||
AzToolsFramework::Prefab::SaveAllPrefabsPreference m_saveAllPrefabsPreference;
|
||||
};
|
||||
|
||||
struct Messaging
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
};
|
||||
|
||||
GeneralSettings m_generalSettings;
|
||||
PrefabSettings m_prefabSettings;
|
||||
GlobalSaveSettings m_globalSaveSettings;
|
||||
Messaging m_messaging;
|
||||
Undo m_undo;
|
||||
DeepSelection m_deepSelection;
|
||||
|
||||
@@ -255,7 +255,7 @@ SEditorSettings::SEditorSettings()
|
||||
g_TemporaryLevelName = nullptr;
|
||||
|
||||
sliceSettings.dynamicByDefault = false;
|
||||
prefabSettings.savePrefabsPreference = AzToolsFramework::Prefab::SavePrefabsPreference::Unspecified;
|
||||
globalSaveSettings.saveAllPrefabsPreference = AzToolsFramework::Prefab::SaveAllPrefabsPreference::AskEveryTime;
|
||||
}
|
||||
|
||||
void SEditorSettings::Connect()
|
||||
@@ -672,7 +672,7 @@ void SEditorSettings::Save()
|
||||
|
||||
AzToolsFramework::Prefab::PrefabLoaderInterface* prefabLoaderInterface =
|
||||
AZ::Interface<AzToolsFramework::Prefab::PrefabLoaderInterface>::Get();
|
||||
prefabLoaderInterface->SetSavePrefabsPreference(prefabSettings.savePrefabsPreference);
|
||||
prefabLoaderInterface->SetSaveAllPrefabsPreference(globalSaveSettings.saveAllPrefabsPreference);
|
||||
|
||||
SaveSettingsRegistryFile();
|
||||
}
|
||||
@@ -682,7 +682,7 @@ void SEditorSettings::Load()
|
||||
{
|
||||
AzToolsFramework::Prefab::PrefabLoaderInterface* prefabLoaderInterface =
|
||||
AZ::Interface<AzToolsFramework::Prefab::PrefabLoaderInterface>::Get();
|
||||
prefabSettings.savePrefabsPreference = prefabLoaderInterface->GetSavePrefabsPreference();
|
||||
globalSaveSettings.saveAllPrefabsPreference = prefabLoaderInterface->GetSaveAllPrefabsPreference();
|
||||
|
||||
// Load from Settings Registry
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
@@ -1082,11 +1082,6 @@ void SEditorSettings::ConvertPath(const AZStd::string_view sourcePath, AZStd::st
|
||||
AZStd::replace(category.begin(), category.end(), '|', '\\');
|
||||
}
|
||||
|
||||
void SEditorSettings::SetSavePrefabsPreference(AzToolsFramework::Prefab::SavePrefabsPreference savePrefabsPreference)
|
||||
{
|
||||
prefabSettings.savePrefabsPreference = savePrefabsPreference;
|
||||
}
|
||||
|
||||
AzToolsFramework::EditorSettingsAPIRequests::SettingOutcome SEditorSettings::GetValue(const AZStd::string_view path)
|
||||
{
|
||||
if (path.find("|") == AZStd::string_view::npos)
|
||||
|
||||
@@ -231,9 +231,9 @@ struct SSliceSettings
|
||||
bool dynamicByDefault;
|
||||
};
|
||||
|
||||
struct SPrefabSettings
|
||||
struct SGlobalSaveSettings
|
||||
{
|
||||
AzToolsFramework::Prefab::SavePrefabsPreference savePrefabsPreference;
|
||||
AzToolsFramework::Prefab::SaveAllPrefabsPreference saveAllPrefabsPreference;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -472,12 +472,10 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
|
||||
SSliceSettings sliceSettings;
|
||||
|
||||
SPrefabSettings prefabSettings;
|
||||
SGlobalSaveSettings globalSaveSettings;
|
||||
|
||||
bool prefabSystem = true; ///< Toggle to enable/disable the Prefab system for level entities.
|
||||
|
||||
void SetSavePrefabsPreference(AzToolsFramework::Prefab::SavePrefabsPreference savePrefabsPreference);
|
||||
|
||||
private:
|
||||
void SaveValue(const char* sSection, const char* sKey, int value);
|
||||
void SaveValue(const char* sSection, const char* sKey, const QColor& value);
|
||||
|
||||
@@ -245,29 +245,44 @@ QTableWidget#recentLevelTable::item {
|
||||
qproperty-iconSize: 16px 16px;
|
||||
}
|
||||
|
||||
#LevelSavedMessageFrame{
|
||||
QListWidget::item
|
||||
{
|
||||
border : none;
|
||||
}
|
||||
|
||||
#SavePrefabDialog, #SaveAllFilesDialog
|
||||
{
|
||||
min-width : 640px;
|
||||
}
|
||||
|
||||
#SaveDependentPrefabsCard
|
||||
{
|
||||
margin: 0px 15px 10px 15px;
|
||||
}
|
||||
|
||||
#PrefabSavedMessageFrame{
|
||||
border: 1px solid green;
|
||||
margin: 10px 15px 10px 15px;
|
||||
border-radius: 2px;
|
||||
margin: 5px 20px 5px 20px;
|
||||
padding: 5px 2px 5px 2px;
|
||||
}
|
||||
|
||||
#SaveAllPrefabsDialog #PrefabSaveQuestionFrame, #SaveDirtyLevelDialog #LevelEntitiesSaveQuestionFrame, #SaveAllPrefabsCheckbox
|
||||
#SavePrefabDialog #PrefabSaveWarningFrame
|
||||
{
|
||||
border: 1px solid orange;
|
||||
margin: 10px 15px 10px 15px;
|
||||
border-radius: 2px;
|
||||
margin: 5px 20px 5px 20px;
|
||||
padding: 5px 2px 5px 2px;
|
||||
color : white;
|
||||
}
|
||||
|
||||
#SaveAllPrefabsDialog #FooterSeparatorLine, #SaveDirtyLevelDialog #FooterSeparatorLine
|
||||
#SaveAllFilesDialog #FooterSeparatorLine, #SavePrefabDialog #FooterSeparatorLine
|
||||
{
|
||||
color: gray;
|
||||
}
|
||||
|
||||
#SaveAllPrefabsDialog #PrefabSavePreferenceHint, #SaveDirtyLevelDialog #PrefabSavePreferenceHint
|
||||
#SaveAllFilesDialog #PrefabSavePreferenceHint, #SavePrefabDialog #PrefabSavePreferenceHint
|
||||
{
|
||||
font: italic;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user