Focus Mode | Make Ctrl+S shortcut contextual to Prefab Focus (#7649)
* Change the Ctrl+S flow to save the currently focused prefab instead of the root. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Ensure the Outliner is refreshed on save Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Rename ExecuteClosePrefabDialog to be more accurate (the function also does the saving, it's not just creating the dialog). Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Minor changes to labeling. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Adjust labeling to reflect changes in behavior. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Revert labeling changes Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Additional checks to guarantee the system works in test mode Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Additional check to prevent crashes when the editor somehow triggers save during automated tests. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Simplify checks Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Update preferences and dialog labels to reflect new behavior. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
@@ -84,7 +84,7 @@ namespace AzToolsFramework::Prefab
|
||||
//! The alias path for the instance the editor is currently focusing on, starting from the root instance.
|
||||
RootAliasPath m_rootAliasFocusPath = RootAliasPath();
|
||||
//! The templateId of the focused instance.
|
||||
TemplateId m_focusedTemplateId;
|
||||
TemplateId m_focusedTemplateId = Prefab::InvalidTemplateId;
|
||||
//! A path containing the filenames of the instances in the focus hierarchy, separated with a /.
|
||||
AZ::IO::Path m_filenameFocusPath;
|
||||
//! The length of the current focus path. Stored to simplify internal checks.
|
||||
|
||||
@@ -1206,6 +1206,12 @@ namespace AzToolsFramework
|
||||
});
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::OnPrefabTemplateDirtyFlagUpdated(
|
||||
[[maybe_unused]] Prefab::TemplateId templateId, [[maybe_unused]] bool status)
|
||||
{
|
||||
m_gui->m_objectTree->update();
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::OnEntityInfoUpdatedAddChildEnd(AZ::EntityId /*parentId*/, AZ::EntityId childId)
|
||||
{
|
||||
QueueContentUpdateSort(childId);
|
||||
|
||||
@@ -112,6 +112,7 @@ namespace AzToolsFramework
|
||||
// PrefabPublicNotificationBus
|
||||
void OnPrefabInstancePropagationBegin() override;
|
||||
void OnPrefabInstancePropagationEnd() override;
|
||||
void OnPrefabTemplateDirtyFlagUpdated(Prefab::TemplateId templateId, bool status) override;
|
||||
|
||||
// EditorWindowUIRequestBus overrides
|
||||
void SetEditorUiEnabled(bool enable) override;
|
||||
|
||||
+4
-6
@@ -30,14 +30,12 @@ namespace AzToolsFramework
|
||||
*/
|
||||
virtual AZ::EntityId CreateNewEntityAtPosition(const AZ::Vector3& position, AZ::EntityId parentId) = 0;
|
||||
|
||||
//! Constructs and executes the close dialog on a prefab template corresponding to templateId.
|
||||
//! Handles the save on close behavior for the root prefab with the TemplateId provided.
|
||||
//! @param templateId The id of the template the user chose to close.
|
||||
virtual int ExecuteClosePrefabDialog(TemplateId templateId) = 0;
|
||||
virtual int HandleRootPrefabClosure(TemplateId templateId) = 0;
|
||||
|
||||
//! Constructs and executes the save dialog on a prefab template corresponding to templateId.
|
||||
//! @param templateId The id of the template the user chose to save.
|
||||
//! @param useSaveAllPrefabsPreference A flag indicating whether SaveAllPrefabsPreference should be used for saving templates.
|
||||
virtual void ExecuteSavePrefabDialog(TemplateId templateId, bool useSaveAllPrefabsPreference = false) = 0;
|
||||
//! Saves the prefab currently focused in the main editor window and all its descendants.
|
||||
virtual void SaveCurrentPrefab() = 0;
|
||||
};
|
||||
|
||||
} // namespace Prefab
|
||||
|
||||
+16
-3
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <AzToolsFramework/ContainerEntity/ContainerEntityInterface.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
||||
#include <AzToolsFramework/Prefab/EditorPrefabComponent.h>
|
||||
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
|
||||
@@ -47,6 +48,7 @@ namespace AzToolsFramework
|
||||
|
||||
ContainerEntityInterface* PrefabIntegrationManager::s_containerEntityInterface = nullptr;
|
||||
EditorEntityUiInterface* PrefabIntegrationManager::s_editorEntityUiInterface = nullptr;
|
||||
PrefabFocusInterface* PrefabIntegrationManager::s_prefabFocusInterface = nullptr;
|
||||
PrefabFocusPublicInterface* PrefabIntegrationManager::s_prefabFocusPublicInterface = nullptr;
|
||||
PrefabLoaderInterface* PrefabIntegrationManager::s_prefabLoaderInterface = nullptr;
|
||||
PrefabPublicInterface* PrefabIntegrationManager::s_prefabPublicInterface = nullptr;
|
||||
@@ -81,6 +83,13 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
s_prefabFocusInterface = AZ::Interface<PrefabFocusInterface>::Get();
|
||||
if (s_prefabFocusInterface == nullptr)
|
||||
{
|
||||
AZ_Assert(false, "Prefab - could not get PrefabFocusInterface on PrefabIntegrationManager construction.");
|
||||
return;
|
||||
}
|
||||
|
||||
s_prefabFocusPublicInterface = AZ::Interface<PrefabFocusPublicInterface>::Get();
|
||||
if (s_prefabFocusPublicInterface == nullptr)
|
||||
{
|
||||
@@ -939,14 +948,18 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
int PrefabIntegrationManager::ExecuteClosePrefabDialog(TemplateId templateId)
|
||||
int PrefabIntegrationManager::HandleRootPrefabClosure(TemplateId templateId)
|
||||
{
|
||||
return m_prefabSaveHandler.ExecuteClosePrefabDialog(templateId);
|
||||
}
|
||||
|
||||
void PrefabIntegrationManager::ExecuteSavePrefabDialog(TemplateId templateId, bool useSaveAllPrefabsPreference)
|
||||
void PrefabIntegrationManager::SaveCurrentPrefab()
|
||||
{
|
||||
m_prefabSaveHandler.ExecuteSavePrefabDialog(templateId, useSaveAllPrefabsPreference);
|
||||
if (s_prefabFocusInterface)
|
||||
{
|
||||
TemplateId currentTemplateId = s_prefabFocusInterface->GetFocusedPrefabTemplateId(s_editorEntityContextId);
|
||||
m_prefabSaveHandler.ExecuteSavePrefabDialog(currentTemplateId, true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Prefab
|
||||
|
||||
+4
-2
@@ -28,6 +28,7 @@ namespace AzToolsFramework
|
||||
|
||||
namespace Prefab
|
||||
{
|
||||
class PrefabFocusInterface;
|
||||
class PrefabFocusPublicInterface;
|
||||
class PrefabLoaderInterface;
|
||||
class PrefabPublicInterface;
|
||||
@@ -65,8 +66,8 @@ namespace AzToolsFramework
|
||||
|
||||
// PrefabIntegrationInterface overrides ...
|
||||
AZ::EntityId CreateNewEntityAtPosition(const AZ::Vector3& position, AZ::EntityId parentId) override;
|
||||
int ExecuteClosePrefabDialog(TemplateId templateId) override;
|
||||
void ExecuteSavePrefabDialog(TemplateId templateId, bool useSaveAllPrefabsPreference) override;
|
||||
int HandleRootPrefabClosure(TemplateId templateId) override;
|
||||
void SaveCurrentPrefab() override;
|
||||
|
||||
private:
|
||||
// Handles the UI for prefab save operations.
|
||||
@@ -113,6 +114,7 @@ namespace AzToolsFramework
|
||||
|
||||
static ContainerEntityInterface* s_containerEntityInterface;
|
||||
static EditorEntityUiInterface* s_editorEntityUiInterface;
|
||||
static PrefabFocusInterface* s_prefabFocusInterface;
|
||||
static PrefabFocusPublicInterface* s_prefabFocusPublicInterface;
|
||||
static PrefabLoaderInterface* s_prefabLoaderInterface;
|
||||
static PrefabPublicInterface* s_prefabPublicInterface;
|
||||
|
||||
+13
-2
@@ -153,7 +153,18 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabSaveHandler::ExecuteSavePrefabDialog(TemplateId templateId, bool useSaveAllPrefabsPreference)
|
||||
{
|
||||
if (templateId == Prefab::InvalidTemplateId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto prefabTemplate = s_prefabSystemComponentInterface->FindTemplate(templateId);
|
||||
|
||||
if (!prefabTemplate.has_value())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::IO::Path prefabTemplatePath = prefabTemplate->get().GetFilePath();
|
||||
|
||||
if (s_prefabSystemComponentInterface->IsTemplateDirty(templateId))
|
||||
@@ -613,10 +624,10 @@ namespace AzToolsFramework
|
||||
contentLayout->addWidget(footerSeparatorLine);
|
||||
|
||||
QLabel* prefabSavePreferenceHint = new QLabel(
|
||||
"<u>You can prevent this window from showing in the future by updating your global save preferences.</u>",
|
||||
"You can prevent this from showing in the future by updating your preferences.",
|
||||
savePrefabDialog.get());
|
||||
prefabSavePreferenceHint->setToolTip(
|
||||
"Go to 'Edit > Editor Settings > Global Preferences... > Global save preferences' to update your preference");
|
||||
"Go to 'Edit > Editor Settings > Global Preferences... > Prefab Save Settings' to update your preference");
|
||||
prefabSavePreferenceHint->setObjectName(PrefabSavePreferenceHint);
|
||||
footerLayout->addWidget(prefabSavePreferenceHint);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user