diff --git a/Code/Editor/CryEdit.cpp b/Code/Editor/CryEdit.cpp index b60351b6b9..83a98ca67b 100644 --- a/Code/Editor/CryEdit.cpp +++ b/Code/Editor/CryEdit.cpp @@ -736,7 +736,11 @@ void CCryEditApp::OnFileSave() if (usePrefabSystemForLevels) { - GetIEditor()->GetDocument()->ExecuteSavePrefabsDialog(); + auto prefabSystemComponentInterface = AZ::Interface::Get(); + if (prefabSystemComponentInterface->AreDirtyTemplatesPresent()) + { + GetIEditor()->GetDocument()->ExecuteSavePrefabsDialog(); + } } } @@ -3195,6 +3199,7 @@ bool CCryEditApp::CreateLevel(bool& wasCreateLevelOperationCancelled) ? SavePrefabsPreference::SaveAll : SavePrefabsPreference::SaveNone; + // 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: diff --git a/Code/Editor/CryEditDoc.cpp b/Code/Editor/CryEditDoc.cpp index 208604e2dd..3e619aba24 100644 --- a/Code/Editor/CryEditDoc.cpp +++ b/Code/Editor/CryEditDoc.cpp @@ -707,7 +707,8 @@ bool CCryEditDoc::SaveModified() QCheckBox* saveAllPrefabsCheckBox = prefabSaveSelectionDialog->findChild("SaveAllPrefabsCheckbox"); SavePrefabsPreference savePrefabsPreference = saveAllPrefabsCheckBox->isChecked() ? SavePrefabsPreference::SaveAll : SavePrefabsPreference::SaveNone; - + + // 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: diff --git a/Code/Editor/SaveAllPrefabsDialog.cpp b/Code/Editor/SaveAllPrefabsDialog.cpp new file mode 100644 index 0000000000..4a344b32ae --- /dev/null +++ b/Code/Editor/SaveAllPrefabsDialog.cpp @@ -0,0 +1,29 @@ +/* + * 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 + #include "SaveAllPrefabsDialog.h" + #include + +AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING +#include +AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING + +SaveAllPrefabsDialog::SaveAllPrefabsDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::SaveAllPrefabsDialog) +{ + ui->setupUi(this); + AzQtComponents::CheckBox::applyToggleSwitchStyle(ui->saveAllPrefabsCheckBox); + AzQtComponents::CheckBox::applyToggleSwitchStyle(ui->rememberPrefabSavePreferenceCheckBox); +} + +SaveAllPrefabsDialog::~SaveAllPrefabsDialog() +{ + delete ui; +} diff --git a/Code/Editor/SaveAllPrefabsDialog.h b/Code/Editor/SaveAllPrefabsDialog.h new file mode 100644 index 0000000000..807f902309 --- /dev/null +++ b/Code/Editor/SaveAllPrefabsDialog.h @@ -0,0 +1,29 @@ +/* + * 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 +#include + +namespace Ui +{ + class SaveAllPrefabsDialog; +} + + + class SaveAllPrefabsDialog : public QDialog + { + public: + SaveAllPrefabsDialog(QWidget* pParent = nullptr); + ~SaveAllPrefabsDialog(); + + private: + Ui::SaveAllPrefabsDialog* ui; + }; + diff --git a/Code/Editor/SaveAllPrefabsDialog.ui b/Code/Editor/SaveAllPrefabsDialog.ui new file mode 100644 index 0000000000..8d1e70b935 --- /dev/null +++ b/Code/Editor/SaveAllPrefabsDialog.ui @@ -0,0 +1,107 @@ + + + SaveAllPrefabsDialog + + + + 0 + 0 + 800 + 600 + + + + Dialog + + + + + + Changes in level saved successfully + + + + + + + Second text + + + + + + + + + CheckBox + + + + + + + TextLabel + + + + + + + + + Qt::Horizontal + + + + + + + + + + + + + CheckBox + + + + + + + TextLabel + + + + + + + + + TextLabel + + + + + + + + + PushButton + + + + + + + PushButton + + + + + + + + + + diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h index f9b8e679b5..1cd36e8055 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h @@ -18,6 +18,7 @@ namespace AzToolsFramework { + class PrefabEditorEntityOwnershipInterface { public: diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp index f336a9765c..7df1e1b5c1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp index d8c308528d..2f0a0601b9 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp @@ -676,7 +676,7 @@ namespace AzToolsFramework { registry->GetObject(savePrefabsPreference, s_savePrefabsKey); } - return static_cast(savePrefabsPreference); + return savePrefabsPreference; } void PrefabLoader::SetSavePrefabsPreference(SavePrefabsPreference savePrefabsPreference)