Merge branch 'main' into LY-113714

This commit is contained in:
sphrose
2021-04-16 10:00:04 +01:00
2723 changed files with 46265 additions and 543702 deletions
@@ -601,7 +601,7 @@ namespace AzToolsFramework
virtual ResolveToolPathOutcome ResolveConfigToolsPath(const char* toolApplicationName) const = 0;
/**
* LUMBERYARD INTERNAL USE ONLY.
* Open 3D Engine Internal use only.
*
* Run a specific redo command separate from the undo/redo system.
* In many cases before a modifcation on an entity takes place, it is first packaged into
@@ -92,7 +92,7 @@ namespace AzToolsFramework
namespace Internal
{
static const char* s_engineConfigFileName = "engine.json";
static const char* s_engineConfigEngineVersionKey = "LumberyardVersion";
static const char* s_engineConfigEngineVersionKey = "O3DEVersion";
static const char* s_startupLogWindow = "Startup";
@@ -155,7 +155,7 @@ namespace AzToolsFramework
void CreateAndAddEntityFromComponentTags(const AZStd::vector<AZ::Crc32>& requiredTags, const char* entityName) override;
/* LUMBERYARD INTERNAL USE ONLY. */
/* Open 3D Engine INTERNAL USE ONLY. */
void RunRedoSeparately(UndoSystem::URSequencePoint* redoCommand) override;
//////////////////////////////////////////////////////////////////////////
@@ -255,10 +255,8 @@ namespace AzToolsFramework::AssetUtils
return configFiles;
}
bool UpdateFilePathToCorrectCase(const QString& root, QString& relativePathFromRoot)
bool UpdateFilePathToCorrectCase(AZStd::string_view rootPath, AZStd::string& relPathFromRoot)
{
AZStd::string rootPath(root.toUtf8().data());
AZStd::string relPathFromRoot(relativePathFromRoot.toUtf8().data());
AZ::StringFunc::Path::Normalize(relPathFromRoot);
AZStd::vector<AZStd::string> tokens;
AZ::StringFunc::Tokenize(relPathFromRoot.c_str(), tokens, AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING);
@@ -321,7 +319,6 @@ namespace AzToolsFramework::AssetUtils
{
relPathFromRoot.clear();
AZ::StringFunc::Join(relPathFromRoot, tokens.begin(), tokens.end(), AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING);
relativePathFromRoot = relPathFromRoot.c_str();
}
return success;
@@ -52,5 +52,5 @@ namespace AzToolsFramework::AssetUtils
//! which will be normalized and updated to be correct casing.
//! @return if such a file does NOT exist, it returns FALSE, else returns TRUE.
//! @note A very expensive function! Call sparingly.
bool UpdateFilePathToCorrectCase(const QString& root, QString& relativePathFromRoot);
bool UpdateFilePathToCorrectCase(AZStd::string_view root, AZStd::string& relativePathFromRoot);
} //namespace AzToolsFramework::AssetUtils
@@ -23,7 +23,7 @@
#include <AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.h>
AZ_PUSH_DISABLE_WARNING(4251 4244, "-Wunknown-warning-option") // disable warnings spawned by QT
#include "AssetBrowser/AssetPicker/ui_AssetPickerDialog.h"
#include <AzToolsFramework/AssetBrowser/AssetPicker/ui_AssetPickerDialog.h>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QKeyEvent>
@@ -17,7 +17,7 @@
// 4251: class needs to have dll-interface to be used by clients of class
// 4800: forcing value to bool 'true' or 'false' (performance warning)
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option")
#include "AssetBrowser/Previewer/ui_EmptyPreviewer.h"
#include <AzToolsFramework/AssetBrowser/Previewer/ui_EmptyPreviewer.h>
AZ_POP_DISABLE_WARNING
namespace AzToolsFramework
@@ -45,4 +45,4 @@ namespace AzToolsFramework
}
}
#include <AssetBrowser/Previewer/moc_EmptyPreviewer.cpp>
#include <AssetBrowser/Previewer/moc_EmptyPreviewer.cpp>
@@ -11,7 +11,7 @@
*/
#include <AzQtComponents/Components/ExtendedLabel.h>
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include <AssetBrowser/Search/ui_FilterByWidget.h>
#include <AzToolsFramework/AssetBrowser/Search/ui_FilterByWidget.h>
AZ_POP_DISABLE_WARNING
#include <AzToolsFramework/AssetBrowser/Search/FilterByWidget.h>
@@ -39,4 +39,4 @@ namespace AzToolsFramework
} // namespace AssetBrowser
} // namespace AzToolsFramework
#include "AssetBrowser/Search/moc_FilterByWidget.cpp"
#include "AssetBrowser/Search/moc_FilterByWidget.cpp"
@@ -18,7 +18,7 @@
#include <AzToolsFramework/AssetBrowser/Search/FilterByWidget.h>
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include <AssetBrowser/Search/ui_SearchAssetTypeSelectorWidget.h>
#include <AzToolsFramework/AssetBrowser/Search/ui_SearchAssetTypeSelectorWidget.h>
AZ_POP_DISABLE_WARNING
#include <QPushButton>
@@ -154,4 +154,4 @@ namespace AzToolsFramework
} // namespace AssetBrowser
} // namespace AzToolsFramework
#include "AssetBrowser/Search/moc_SearchAssetTypeSelectorWidget.cpp"
#include "AssetBrowser/Search/moc_SearchAssetTypeSelectorWidget.cpp"
@@ -12,7 +12,7 @@
#include "SearchParametersWidget.h"
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include "AssetBrowser/Search/ui_SearchParametersWidget.h"
#include <AzToolsFramework/AssetBrowser/Search/ui_SearchParametersWidget.h>
AZ_POP_DISABLE_WARNING
#include <AzQtComponents/Components/ExtendedLabel.h>
@@ -68,4 +68,4 @@ namespace AzToolsFramework
} // namespace AssetBrowser
} // namespace AzToolsFramework
#include "AssetBrowser/Search/moc_SearchParametersWidget.cpp"
#include "AssetBrowser/Search/moc_SearchParametersWidget.cpp"
@@ -54,7 +54,7 @@ namespace AzToolsFramework
//! Set unique asset browser name, used to persist tree expansion states
void SetName(const QString& name);
// LUMBERYARD_DEPRECATED
// O3DE_DEPRECATED
void LoadState(const QString& name);
void SaveState() const;
@@ -19,9 +19,9 @@
#include <AssetEditor/AssetEditorBus.h>
#include <AssetEditor/AssetEditorHeader.h>
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include <AssetEditor/ui_AssetEditorToolbar.h>
#include <AzToolsFramework/AssetEditor/ui_AssetEditorToolbar.h>
AZ_POP_DISABLE_WARNING
#include <AssetEditor/ui_AssetEditorStatusBar.h>
#include <AzToolsFramework/AssetEditor/ui_AssetEditorStatusBar.h>
#include <AssetBrowser/AssetSelectionModel.h>
@@ -256,6 +256,8 @@ namespace AzToolsFramework
m_userSettings = AZ::UserSettings::CreateFind<AssetEditorWidgetUserSettings>(k_assetEditorWidgetSettings, AZ::UserSettings::CT_LOCAL);
UpdateRecentFileListState();
QObject::connect(m_recentFileMenu, &QMenu::aboutToShow, this, &AssetEditorWidget::PopulateRecentMenu);
}
@@ -952,7 +954,8 @@ namespace AzToolsFramework
void AssetEditorWidget::AddRecentPath(const AZStd::string& recentPath)
{
m_userSettings->AddRecentPath(recentPath);
m_userSettings->AddRecentPath(recentPath);
UpdateRecentFileListState();
}
void AssetEditorWidget::PopulateRecentMenu()
@@ -989,6 +992,21 @@ namespace AzToolsFramework
m_saveAsAssetAction->setEnabled(true);
}
void AssetEditorWidget::UpdateRecentFileListState()
{
if (m_recentFileMenu)
{
if (!m_userSettings || m_userSettings->m_recentPaths.empty())
{
m_recentFileMenu->setEnabled(false);
}
else
{
m_recentFileMenu->setEnabled(true);
}
}
}
} // namespace AssetEditor
} // namespace AzToolsFramework
@@ -122,6 +122,8 @@ namespace AzToolsFramework
void OnCatalogAssetAdded(const AZ::Data::AssetId& assetId) override;
void OnCatalogAssetRemoved(const AZ::Data::AssetId& assetId, const AZ::Data::AssetInfo& assetInfo) override;
void UpdateRecentFileListState();
private:
void DirtyAsset();
@@ -191,10 +191,17 @@ namespace AzToolsFramework
{
if (componentClass->m_editData->m_name == componentTypeNames[i])
{
// Although it is rare, it can happen that two (or more) components can have the same name.
// We should only count the first occurrence, so that none of the names in componentTypeNames
// get skipped, but whichever component type that is encountered last will be the one
// that is captured in order to preserve the pre-existing behavior.
if (foundTypeIds[i].IsNull())
{
++counter;
}
foundTypeIds[i] = componentClass->m_typeId;
++counter;
//Although it is rare, it can happen that two components can have the same name.
//We will capture only the first occurrence.
return true;
}
}
@@ -130,7 +130,7 @@ namespace AzToolsFramework
int written = uuid.ToString(buffer, aznumeric_caster(bufferSize), false);
if (written > 0)
{
if (bufferSize - written > 0)
if (bufferSize > written)
{
buffer[written - 1] = '\n';
buffer[written] = 0;
@@ -453,6 +453,7 @@ namespace AzToolsFramework
{
loadedSuccessfully = static_cast<PrefabEditorEntityOwnershipService*>(m_entityOwnershipService.get())->LoadFromStream(
stream, AZStd::string_view(levelPakFile.toUtf8(), levelPakFile.size()) );
}
LoadFromStreamComplete(loadedSuccessfully);
@@ -707,7 +707,7 @@ namespace AzToolsFramework
{
QMessageBox::warning(AzToolsFramework::GetActiveWindow(),
QStringLiteral("Can't instantiate the selected slice"),
QString("The slice may contain UI elements that can't be instantiated in the main Lumberyard editor. "
QString("The slice may contain UI elements that can't be instantiated in the main Open 3D Engine editor. "
"Use the UI Editor to instantiate this slice or select another one."),
QMessageBox::Ok);
}
@@ -11,8 +11,10 @@
*/
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/TransformBus.h>
#include <AzCore/Script/ScriptSystemBus.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <AzFramework/Entity/GameEntityContextBus.h>
#include <AzFramework/Spawnable/RootSpawnableInterface.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h>
@@ -21,6 +23,7 @@
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
#include <AzToolsFramework/Prefab/PrefabLoader.h>
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
#include <AzToolsFramework/Prefab/PrefabUndoHelpers.h>
namespace AzToolsFramework
{
@@ -91,23 +94,47 @@ namespace AzToolsFramework
m_prefabSystemComponent->RemoveTemplate(templateId);
}
m_rootInstance->Reset();
AzFramework::EntityOwnershipServiceNotificationBus::Event(
m_entityContextId, &AzFramework::EntityOwnershipServiceNotificationBus::Events::OnEntityOwnershipServiceReset);
}
void PrefabEditorEntityOwnershipService::AddEntity(AZ::Entity* entity)
{
AZ_Assert(IsInitialized(), "Tried to add an entity without initializing the Entity Ownership Service");
ScopedUndoBatch undoBatch("Undo adding entity");
Prefab::PrefabDom instanceDomBeforeUpdate;
Prefab::PrefabDomUtils::StoreInstanceInPrefabDom(*m_rootInstance, instanceDomBeforeUpdate);
m_rootInstance->AddEntity(*entity);
HandleEntitiesAdded({ entity });
AZ::TransformBus::Event(entity->GetId(), &AZ::TransformInterface::SetParent, m_rootInstance->m_containerEntity->GetId());
Prefab::PrefabUndoHelpers::UpdatePrefabInstance(
*m_rootInstance, "Undo adding entity", instanceDomBeforeUpdate, undoBatch.GetUndoBatch());
}
void PrefabEditorEntityOwnershipService::AddEntities(const EntityList& entities)
{
AZ_Assert(IsInitialized(), "Tried to add entities without initializing the Entity Ownership Service");
ScopedUndoBatch undoBatch("Undo adding entities");
Prefab::PrefabDom instanceDomBeforeUpdate;
Prefab::PrefabDomUtils::StoreInstanceInPrefabDom(*m_rootInstance, instanceDomBeforeUpdate);
for (AZ::Entity* entity : entities)
{
m_rootInstance->AddEntity(*entity);
}
HandleEntitiesAdded(entities);
for (AZ::Entity* entity : entities)
{
AZ::TransformBus::Event(entity->GetId(), &AZ::TransformInterface::SetParent, m_rootInstance->m_containerEntity->GetId());
}
Prefab::PrefabUndoHelpers::UpdatePrefabInstance(
*m_rootInstance, "Undo adding entities", instanceDomBeforeUpdate, undoBatch.GetUndoBatch());
}
bool PrefabEditorEntityOwnershipService::DestroyEntity(AZ::Entity* entity)
@@ -172,6 +199,7 @@ namespace AzToolsFramework
m_rootInstance->SetTemplateId(templateId);
m_rootInstance->SetTemplateSourcePath(m_loaderInterface->GetRelativePathToProject(filename));
m_prefabSystemComponent->PropagateTemplateChanges(templateId);
return true;
}
@@ -295,6 +323,9 @@ namespace AzToolsFramework
void PrefabEditorEntityOwnershipService::StartPlayInEditor()
{
// This is a workaround until the replacement for GameEntityContext is done
AzFramework::GameEntityContextEventBus::Broadcast(&AzFramework::GameEntityContextEventBus::Events::OnPreGameEntitiesStarted);
if (m_rootInstance && !m_playInEditorData.m_isEnabled)
{
// Construct the runtime entities and products
@@ -339,11 +370,16 @@ namespace AzToolsFramework
m_playInEditorData.m_assets.emplace_back(product.ReleaseAsset().release(), AZ::Data::AssetLoadBehavior::Default);
}
if (rootSpawnableIndex != NoRootSpawnable)
{
m_playInEditorData.m_entities.Reset(m_playInEditorData.m_assets[rootSpawnableIndex]);
m_playInEditorData.m_entities.SpawnAllEntities();
}
// This is a workaround until the replacement for GameEntityContext is done
AzFramework::GameEntityContextEventBus::Broadcast(
&AzFramework::GameEntityContextEventBus::Events::OnGameEntitiesStarted);
}
else
{
@@ -402,6 +438,9 @@ namespace AzToolsFramework
AZ::ScriptSystemRequestBus::Broadcast(&AZ::ScriptSystemRequests::GarbageCollect);
});
m_playInEditorData.m_entities.Clear();
// This is a workaround until the replacement for GameEntityContext is done
AzFramework::GameEntityContextEventBus::Broadcast(&AzFramework::GameEntityContextEventBus::Events::OnGameEntitiesReset);
}
m_playInEditorData.m_isEnabled = false;
@@ -89,7 +89,7 @@ namespace AzToolsFramework
const AzFramework::CameraState& cameraState,
const ViewportInteraction::MouseInteraction& mouseInteraction);
// LUMBERYARD_DEPRECATED(LY-117150)
// O3DE_DEPRECATED(LY-117150)
/// Check if the modifier key state has changed - if so we may need to refresh
/// certain manipulator bounds.
AZ_DEPRECATED(
@@ -56,16 +56,6 @@ namespace AzToolsFramework
void EditorPrefabComponent::Activate()
{
PrefabPublicInterface* prefabPublicInterface = AZ::Interface<PrefabPublicInterface>::Get();
if (prefabPublicInterface && prefabPublicInterface->IsLevelInstanceContainerEntity(GetEntityId()))
{
EntityOutlinerWidgetInterface* entityOutlinerWidgetInterface = AZ::Interface<EntityOutlinerWidgetInterface>::Get();
if (entityOutlinerWidgetInterface)
{
entityOutlinerWidgetInterface->SetRootEntity(GetEntityId());
}
}
PrefabInstanceContainerNotificationBus::Broadcast(
&PrefabInstanceContainerNotifications::OnPrefabComponentActivate, GetEntityId());
}
@@ -154,7 +154,7 @@ namespace AzToolsFramework
if (instanceToTemplateEntityIdIterator != m_instanceToTemplateEntityIdMap.end())
{
entityAliasToRemove = instanceToTemplateEntityIdIterator->second;
bool isEntityRemoved = m_instanceEntityMapper->UnregisterEntity(entityId) &&
[[maybe_unused]] bool isEntityRemoved = m_instanceEntityMapper->UnregisterEntity(entityId) &&
m_templateToInstanceEntityIdMap.erase(entityAliasToRemove) && m_instanceToTemplateEntityIdMap.erase(entityId);
AZ_Assert(isEntityRemoved,
"Prefab - Failed to remove entity with id %s with a Prefab Instance derived from source asset %s "
@@ -31,7 +31,7 @@ namespace AzToolsFramework
class InstanceEntityScrubber
{
public:
AZ_RTTI(InstanceEntityScrubber, "{0BC12562-C240-48AD-89C6-EDF572C9B485}");
AZ_TYPE_INFO(InstanceEntityScrubber, "{0BC12562-C240-48AD-89C6-EDF572C9B485}");
explicit InstanceEntityScrubber(Instance::EntityList& entities);
@@ -209,7 +209,7 @@ namespace AzToolsFramework
EntityList entitiesInInstance;
entitiesInInstance.reserve(instance->m_entities.size() + 1);
if (instance->m_containerEntity->GetId().IsValid())
if (instance->m_containerEntity && instance->m_containerEntity->GetId().IsValid())
{
entitiesInInstance.emplace_back(instance->m_containerEntity.get());
}
@@ -219,11 +219,10 @@ namespace AzToolsFramework
entitiesInInstance.emplace_back(entity.get());
}
InstanceEntityScrubber** instanceEntityScrubber = jsonDeserializerContext.GetMetadata().Find<InstanceEntityScrubber*>();
if (instanceEntityScrubber && (*instanceEntityScrubber))
InstanceEntityScrubber* instanceEntityScrubber = jsonDeserializerContext.GetMetadata().Find<InstanceEntityScrubber>();
if (instanceEntityScrubber)
{
(*instanceEntityScrubber)->AddEntitiesToScrub(entitiesInInstance);
instanceEntityScrubber->AddEntitiesToScrub(entitiesInInstance);
}
}
@@ -43,14 +43,12 @@ namespace AzToolsFramework
const PrefabDom& modifiedState, const LinkId linkId) = 0;
//! Updates the affected template for a given entityId using the providedPatch
virtual bool PatchEntityInTemplate(PrefabDomValue& providedPatch, const AZ::EntityId& entityId) = 0;
virtual bool PatchEntityInTemplate(PrefabDomValue& providedPatch, const EntityAlias& entityAlias, const TemplateId& templateId) = 0;
virtual bool PatchEntityInTemplate(PrefabDom& providedPatch, AZ::EntityId entityId) = 0;
virtual void AppendEntityAliasToPatchPaths(PrefabDom& providedPatch, const AZ::EntityId& entityId) = 0;
//! Updates the template links (updating instances) for the given templateId using the providedPatch
virtual void PatchTemplate(PrefabDomValue& providedPatch, const TemplateId& templateId) = 0;
virtual bool PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId) = 0;
virtual void ApplyPatchesToInstance(const AZ::EntityId& entityId, PrefabDom& patches, const Instance& instanceToAddPatches) = 0;
@@ -107,7 +107,7 @@ namespace AzToolsFramework
return result.GetProcessing() != AZ::JsonSerializationResult::Processing::Halted;
}
bool InstanceToTemplatePropagator::PatchEntityInTemplate(PrefabDomValue& providedPatch, const AZ::EntityId& entityId)
bool InstanceToTemplatePropagator::PatchEntityInTemplate(PrefabDom& providedPatch, AZ::EntityId entityId)
{
InstanceOptionalReference instanceOptionalReference = m_instanceEntityMapperInterface->FindOwningInstance(entityId);
@@ -119,54 +119,10 @@ namespace AzToolsFramework
return false;
}
//get template space associated with instance
Instance& instance = instanceOptionalReference->get();
TemplateId templateId = instance.GetTemplateId();
//alias entity goes by in template -> get via owning instance map
AZStd::optional<EntityAlias> entityAlias = instance.GetEntityAlias(entityId);
if (!entityAlias)
{
AZ_Error("Prefab", false, "Failed to find an entity alias for the provided entity");
return false;
}
PrefabDom& templateDomReference = m_prefabSystemComponentInterface->FindTemplateDom(templateId);
return PatchEntityInTemplate(providedPatch, entityAlias.value(), templateId);
}
bool InstanceToTemplatePropagator::PatchEntityInTemplate(PrefabDomValue& providedPatch, const EntityAlias& entityAlias, const TemplateId& templateId)
{
PrefabDom& templateDomReference = m_prefabSystemComponentInterface->FindTemplateDom(templateId);
//query into the template dom for the alias
PrefabDomValueReference entityList = PrefabDomUtils::FindPrefabDomValue(templateDomReference, PrefabDomUtils::EntitiesName);
if (!entityList)
{
AZ_Error("Prefab", false, "Cannot patch entity in Template with id [%llu] because entity couldn't be found in the template", templateId);
return false;
}
PrefabDomValueReference entity = PrefabDomUtils::FindPrefabDomValue(entityList->get(), entityAlias.c_str());
if (!entity)
{
AZ_Error("Prefab", false, "Failed to aquire entity value reference");
return false;
}
//apply patch to section
AZ::JsonSerializationResult::ResultCode result = AZ::JsonSerialization::ApplyPatch(entity->get(),
templateDomReference.GetAllocator(), providedPatch, AZ::JsonMergeApproach::JsonPatch);
AZ_Error("Prefab", result.GetOutcome() == AZ::JsonSerializationResult::Outcomes::Success, "Patch was not successfully applied")
//trigger propagation
m_prefabSystemComponentInterface->PropagateTemplateChanges(templateId);
return true;
//get template id associated with instance
TemplateId templateId = instanceOptionalReference->get().GetTemplateId();
AppendEntityAliasToPatchPaths(providedPatch, entityId);
return PatchTemplate(providedPatch, templateId);
}
void InstanceToTemplatePropagator::AppendEntityAliasToPatchPaths(PrefabDom& providedPatch, const AZ::EntityId& entityId)
@@ -216,7 +172,7 @@ namespace AzToolsFramework
}
}
void InstanceToTemplatePropagator::PatchTemplate(PrefabDomValue& providedPatch, const TemplateId& templateId)
bool InstanceToTemplatePropagator::PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId)
{
PrefabDom& templateDomReference = m_prefabSystemComponentInterface->FindTemplateDom(templateId);
@@ -224,14 +180,17 @@ namespace AzToolsFramework
AZ::JsonSerializationResult::ResultCode result = AZ::JsonSerialization::ApplyPatch(templateDomReference,
templateDomReference.GetAllocator(), providedPatch, AZ::JsonMergeApproach::JsonPatch);
AZ_Error("Prefab", result.GetOutcome() == AZ::JsonSerializationResult::Outcomes::Success,
"Patch was not successfully applied");
//trigger propagation
if (result.GetOutcome() == AZ::JsonSerializationResult::Outcomes::Success)
{
m_prefabSystemComponentInterface->SetTemplateDirtyFlag(templateId, true);
m_prefabSystemComponentInterface->PropagateTemplateChanges(templateId);
return true;
}
else
{
AZ_Error("Prefab", false, "Patch was not successfully applied");
return false;
}
}
@@ -288,6 +247,8 @@ namespace AzToolsFramework
AddPatchesToLink(patches, linkToApplyPatches);
linkToApplyPatches.UpdateTarget();
m_prefabSystemComponentInterface->SetTemplateDirtyFlag(linkToApplyPatches.GetTargetTemplateId(), true);
m_prefabSystemComponentInterface->PropagateTemplateChanges(linkToApplyPatches.GetTargetTemplateId());
}
@@ -314,7 +275,6 @@ namespace AzToolsFramework
PrefabDom& linkDom = link.GetLinkDom();
PrefabDomValueReference linkPatchesReference =
PrefabDomUtils::FindPrefabDomValue(linkDom, PrefabDomUtils::PatchesName);
PrefabDom& templateDomReference = m_prefabSystemComponentInterface->FindTemplateDom(link.GetTargetTemplateId());
// This logic only covers addition of patches. If patches already exists, the given list of patches must be appended to them.
if (!linkPatchesReference.has_value())
@@ -31,21 +31,19 @@ namespace AzToolsFramework
bool GeneratePatch(PrefabDom& generatedPatch, const PrefabDom& initialState, const PrefabDom& modifiedState) override;
bool GeneratePatchForLink(PrefabDom& generatedPatch, const PrefabDom& initialState,
const PrefabDom& modifiedState, LinkId linkId) override;
bool PatchEntityInTemplate(PrefabDomValue& providedPatch, const AZ::EntityId& entityId) override;
bool PatchEntityInTemplate(PrefabDomValue& providedPatch, const EntityAlias& entityAlias, const TemplateId& templateId) override;
bool PatchEntityInTemplate(PrefabDom& providedPatch, AZ::EntityId entityId) override;
void AppendEntityAliasToPatchPaths(PrefabDom& providedPatch, const AZ::EntityId& entityId) override;
InstanceOptionalReference GetTopMostInstanceInHierarchy(AZ::EntityId entityId);
void PatchTemplate(PrefabDomValue& providedPatch, const AzToolsFramework::Prefab::TemplateId& templateId) override;
bool PatchTemplate(PrefabDomValue& providedPatch, TemplateId templateId) override;
void ApplyPatchesToInstance(const AZ::EntityId& entityId, PrefabDom& patches, const Instance& instanceToAddPatches) override;
void AddPatchesToLink(PrefabDom& patches, Link& link);
private:
InstanceEntityMapperInterface* m_instanceEntityMapperInterface;
PrefabSystemComponentInterface* m_prefabSystemComponentInterface;
@@ -19,6 +19,7 @@
#include <AzToolsFramework/Prefab/Instance/Instance.h>
#include <AzToolsFramework/Prefab/Instance/TemplateInstanceMapperInterface.h>
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
#include <AzToolsFramework/Prefab/Template/Template.h>
#include <AzToolsFramework/UI/Outliner/EntityOutlinerWidgetInterface.h>
@@ -121,8 +122,12 @@ namespace AzToolsFramework
Template& currentTemplate = currentTemplateReference->get();
Instance::EntityList newEntities;
if (!PrefabDomUtils::LoadInstanceFromPrefabDom(
*instanceToUpdate, newEntities, currentTemplate.GetPrefabDom()))
if (PrefabDomUtils::LoadInstanceFromPrefabDom(*instanceToUpdate, newEntities, currentTemplate.GetPrefabDom()))
{
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, newEntities);
}
else
{
AZ_Error(
"Prefab", false,
@@ -132,8 +137,6 @@ namespace AzToolsFramework
isUpdateSuccessful = false;
}
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, newEntities);
m_instancesUpdateQueue.pop();
@@ -142,12 +145,17 @@ namespace AzToolsFramework
ToolsApplicationRequestBus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, selectedEntityIds);
// Enable the Outliner
AZ::SystemTickBus::QueueFunction([entityOutlinerWidgetInterface]() {
if (entityOutlinerWidgetInterface)
if (entityOutlinerWidgetInterface)
{
entityOutlinerWidgetInterface->SetUpdatesEnabled(true);
auto prefabPublicInterface = AZ::Interface<PrefabPublicInterface>::Get();
if (prefabPublicInterface)
{
entityOutlinerWidgetInterface->SetUpdatesEnabled(true);
AZ::EntityId rootEntityId = prefabPublicInterface->GetLevelInstanceContainerEntityId();
entityOutlinerWidgetInterface->ExpandEntityChildren(rootEntityId);
}
});
}
}
m_updatingTemplateInstancesInQueue = false;
@@ -10,6 +10,7 @@
*
*/
#include <AzCore/Asset/AssetManager.h>
#include <AzCore/JSON/prettywriter.h>
#include <AzCore/Serialization/Json/JsonSerialization.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
@@ -78,6 +79,11 @@ namespace AzToolsFramework
bool LoadInstanceFromPrefabDom(Instance& instance, const PrefabDom& prefabDom, LoadInstanceFlags flags)
{
// When entities are rebuilt they are first destroyed. As a result any assets they were exclusively holding on to will
// be released and reloaded once the entities are built up again. By suspending asset release temporarily the asset reload
// is avoided.
AZ::Data::AssetManager::Instance().SuspendAssetRelease();
InstanceEntityIdMapper entityIdMapper;
entityIdMapper.SetLoadingInstance(instance);
if ((flags & LoadInstanceFlags::AssignRandomEntityId) == LoadInstanceFlags::AssignRandomEntityId)
@@ -91,10 +97,12 @@ namespace AzToolsFramework
// data has strict typing and doesn't look for inheritance both have to be explicitly added so they're found both locations.
settings.m_metadata.Add(static_cast<AZ::JsonEntityIdSerializer::JsonEntityIdMapper*>(&entityIdMapper));
settings.m_metadata.Add(&entityIdMapper);
AZ::JsonSerializationResult::ResultCode result =
AZ::JsonSerialization::Load(instance, prefabDom, settings);
AZ::Data::AssetManager::Instance().ResumeAssetRelease();
if (result.GetProcessing() == AZ::JsonSerializationResult::Processing::Halted)
{
AZ_Error("Prefab", false,
@@ -110,6 +118,11 @@ namespace AzToolsFramework
bool LoadInstanceFromPrefabDom(
Instance& instance, Instance::EntityList& newlyAddedEntities, const PrefabDom& prefabDom, LoadInstanceFlags flags)
{
// When entities are rebuilt they are first destroyed. As a result any assets they were exclusively holding on to will
// be released and reloaded once the entities are built up again. By suspending asset release temporarily the asset reload
// is avoided.
AZ::Data::AssetManager::Instance().SuspendAssetRelease();
InstanceEntityIdMapper entityIdMapper;
entityIdMapper.SetLoadingInstance(instance);
if ((flags & LoadInstanceFlags::AssignRandomEntityId) == LoadInstanceFlags::AssignRandomEntityId)
@@ -123,16 +136,16 @@ namespace AzToolsFramework
// data has strict typing and doesn't look for inheritance both have to be explicitly added so they're found both locations.
settings.m_metadata.Add(static_cast<AZ::JsonEntityIdSerializer::JsonEntityIdMapper*>(&entityIdMapper));
settings.m_metadata.Add(&entityIdMapper);
settings.m_metadata.Create<InstanceEntityScrubber>(newlyAddedEntities);
InstanceEntityScrubber instanceEntityScrubber(newlyAddedEntities);
settings.m_metadata.Add(&instanceEntityScrubber);
AZ::JsonSerializationResult::ResultCode result = AZ::JsonSerialization::Load(instance, prefabDom, settings);
AZ::JsonSerializationResult::ResultCode result =
AZ::JsonSerialization::Load(instance, prefabDom, settings);
AZ::Data::AssetManager::Instance().ResumeAssetRelease();
if (result.GetProcessing() == AZ::JsonSerializationResult::Processing::Halted)
{
AZ_Error("Prefab", false,
AZ_Error(
"Prefab", false,
"Failed to de-serialize Prefab Instance from Prefab DOM. "
"Unable to proceed.");
@@ -39,7 +39,7 @@ namespace AzToolsFramework
auto settingsRegistry = AZ::SettingsRegistry::Get();
AZ_Assert(settingsRegistry, "Settings registry is not set");
bool result =
[[maybe_unused]] bool result =
settingsRegistry->Get(m_projectPathWithOsSeparator.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath);
AZ_Assert(result, "Couldn't retrieve project root path");
m_projectPathWithSlashSeparator = AZ::IO::Path(m_projectPathWithOsSeparator.Native(), '/').MakePreferred();
@@ -182,7 +182,6 @@ namespace AzToolsFramework
for (PrefabDomValue::MemberIterator instanceIterator = instances.MemberBegin(); instanceIterator != instances.MemberEnd();
++instanceIterator)
{
const PrefabDomValue& instance = instanceIterator->value;
if (!LoadNestedInstance(instanceIterator, newTemplateId, progressedFilePathsSet))
{
isLoadedWithErrors = true;
@@ -349,8 +348,7 @@ namespace AzToolsFramework
"Prefab", false,
"PrefabLoader::SaveTemplate - Unable to save Prefab Template with id: %llu. "
"Template with that id is invalid",
templateId
);
templateId);
return AZStd::nullopt;
}
@@ -27,6 +27,7 @@
#include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
#include <AzToolsFramework/Prefab/PrefabUndo.h>
#include <AzToolsFramework/Prefab/PrefabUndoHelpers.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
namespace AzToolsFramework
@@ -57,7 +58,7 @@ namespace AzToolsFramework
m_prefabUndoCache.Destroy();
}
PrefabOperationResult PrefabPublicHandler::CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZStd::string_view filePath)
PrefabOperationResult PrefabPublicHandler::CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath)
{
// Retrieve entityList from entityIds
EntityList inputEntityList;
@@ -247,23 +248,8 @@ namespace AzToolsFramework
ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::SetSelectedEntities, selection);
PrefabDom instanceDomAfterUpdate;
m_instanceToTemplateInterface->GenerateDomForInstance(instanceDomAfterUpdate, entityOwningInstance);
// Generate the patch comparing the instance before and after the entity addition.
PrefabDom patch;
if (!m_instanceToTemplateInterface->GeneratePatch(patch, instanceDomBeforeUpdate, instanceDomAfterUpdate))
{
return AZ::Failure(AZStd::string::format(
"A valid patch couldn't be created for adding an entity with id '%llu'", static_cast<AZ::u64>(entityId)));
}
// create undo node
PrefabUndoInstance* state = aznew PrefabUndoInstance(AZStd::string::format("%llu", static_cast<AZ::u64>(entityId)));
state->Capture(instanceDomBeforeUpdate, instanceDomAfterUpdate, entityOwningInstance.GetTemplateId());
state->SetParent(undoBatch.GetUndoBatch());
state->Redo();
PrefabUndoHelpers::UpdatePrefabInstance(
entityOwningInstance, "Undo adding entity", instanceDomBeforeUpdate, undoBatch.GetUndoBatch());
return AZ::Success(entityId);
}
@@ -643,14 +629,17 @@ namespace AzToolsFramework
}
bool PrefabPublicHandler::RetrieveAndSortPrefabEntitiesAndInstances(
const EntityList& inputEntities, const Instance& commonRootEntityOwningInstance,
const EntityList& inputEntities, Instance& commonRootEntityOwningInstance,
EntityList& outEntities, AZStd::vector<AZStd::unique_ptr<Instance>>& outInstances) const
{
AZStd::queue<AZ::Entity*> entityQueue;
for (auto inputEntity : inputEntities)
{
entityQueue.push(inputEntity);
if (inputEntity && !IsLevelInstanceContainerEntity(inputEntity->GetId()))
{
entityQueue.push(inputEntity);
}
}
// Support sets to easily identify if we're processing the same entity multiple times.
@@ -664,17 +653,19 @@ namespace AzToolsFramework
// Get this entity's owning instance.
InstanceOptionalReference owningInstance = m_instanceEntityMapperInterface->FindOwningInstance(entity->GetId());
AZ_Assert(owningInstance.has_value(), "An error occored while retrieving entities and prefab instances : "
"Owning instance of entity with id '%llu' couldn't be found", entity->GetId());
AZ_Assert(
owningInstance.has_value(),
"An error occored while retrieving entities and prefab instances : "
"Owning instance of entity with id '%llu' couldn't be found",
entity->GetId());
// Check if this entity is owned by the same instance owning the root.
if (&owningInstance->get() == &commonRootEntityOwningInstance)
{
AZStd::unique_ptr<AZ::Entity> detachedEntity = owningInstance->get().DetachEntity(entity->GetId());
// If it's the same instance, we can add this entity to the new instance entities.
int priorEntitiesSize = entities.size();
entities.insert(detachedEntity.release());
entities.insert(entity);
// If the size of entities increased, then it wasn't added before.
// In that case, add the children of this entity to the queue.
@@ -714,20 +705,18 @@ namespace AzToolsFramework
// Store results
outEntities.clear();
outEntities.resize(entities.size());
AZStd::copy(entities.begin(), entities.end(), outEntities.begin());
outEntities.reserve(entities.size());
for (AZ::Entity* entity : entities)
{
outEntities.emplace_back(commonRootEntityOwningInstance.DetachEntity(entity->GetId()).release());
}
outInstances.clear();
outInstances.reserve(instances.size());
for (Instance* instancePtr : instances)
{
auto parentInstance = instancePtr->GetParentInstance();
if (parentInstance.has_value())
{
auto uniquePtr = parentInstance->get().DetachNestedInstance(instancePtr->GetInstanceAlias());
outInstances.push_back(AZStd::move(uniquePtr));
}
outInstances.push_back(AZStd::move(commonRootEntityOwningInstance.DetachNestedInstance(instancePtr->GetInstanceAlias())));
}
return true;
@@ -745,8 +734,20 @@ namespace AzToolsFramework
for (AZ::EntityId entityId : entityIds)
{
InstanceOptionalReference owningInstance = m_instanceEntityMapperInterface->FindOwningInstance(entityId);
// If this is the container entity, it actually represents the instance so get its owner
if (owningInstance->get().GetContainerEntityId() == entityId)
if (!owningInstance.has_value())
{
AZ_Assert(
false,
"An error occored in function EntitiesBelongToSameInstance: "
"Owning instance of entity with id '%llu' couldn't be found",
entityId);
return false;
}
// If this is a container entity, it actually represents a child instance so get its owner.
// The only exception in the level root instance. We leave it as is to streamline operations.
if (owningInstance->get().GetContainerEntityId() == entityId && !IsLevelInstanceContainerEntity(entityId))
{
owningInstance = owningInstance->get().GetParentInstance();
}
@@ -42,7 +42,7 @@ namespace AzToolsFramework
void UnregisterPrefabPublicHandlerInterface();
// PrefabPublicInterface...
PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZStd::string_view filePath) override;
PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) override;
PrefabOperationResult InstantiatePrefab(AZStd::string_view filePath, AZ::EntityId parent, AZ::Vector3 position) override;
PrefabOperationResult SavePrefab(AZ::IO::Path filePath) override;
PrefabEntityResult CreateEntity(AZ::EntityId parentId, const AZ::Vector3& position) override;
@@ -61,7 +61,7 @@ namespace AzToolsFramework
private:
PrefabOperationResult DeleteFromInstance(const EntityIdList& entityIds, bool deleteDescendants);
bool RetrieveAndSortPrefabEntitiesAndInstances(const EntityList& inputEntities, const Instance& commonRootEntityOwningInstance,
bool RetrieveAndSortPrefabEntitiesAndInstances(const EntityList& inputEntities, Instance& commonRootEntityOwningInstance,
EntityList& outEntities, AZStd::vector<AZStd::unique_ptr<Instance>>& outInstances) const;
InstanceOptionalReference GetOwnerInstanceByEntityId(AZ::EntityId entityId) const;
@@ -49,7 +49,7 @@ namespace AzToolsFramework
* @param filePath The path for the new prefab file.
* @return An outcome object; on failure, it comes with an error message detailing the cause of the error.
*/
virtual PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZStd::string_view filePath) = 0;
virtual PrefabOperationResult CreatePrefab(const AZStd::vector<AZ::EntityId>& entityIds, AZ::IO::PathView filePath) = 0;
/**
* Instantiate a prefab from a prefab file.
@@ -498,12 +498,14 @@ namespace AzToolsFramework
return false;
}
Template& sourceTemplate = sourceTemplateReference->get();
Template& targetTemplate = targetTemplateReference->get();
#if defined(AZ_ENABLE_TRACING)
Template& sourceTemplate = sourceTemplateReference->get();
AZStd::string_view instanceName(instanceIterator->name.GetString(), instanceIterator->name.GetStringLength());
const AZStd::string& targetTemplateFilePath = targetTemplate.GetFilePath().Native();
const AZStd::string& sourceTemplateFilePath = sourceTemplate.GetFilePath().Native();
#endif
LinkId newLinkId = CreateUniqueLinkId();
Link newLink(newLinkId);
@@ -731,10 +733,11 @@ namespace AzToolsFramework
}
Template& sourceTemplate = sourceTemplateReference->get();
#if defined(AZ_ENABLE_TRACING)
Template& targetTemplate = targetTemplateReference->get();
#endif
AZStd::string_view instanceName(instanceIterator->name.GetString(), instanceIterator->name.GetStringLength());
const AZStd::string& targetTemplateFilePath = targetTemplate.GetFilePath().Native();
link.SetSourceTemplateId(sourceTemplateId);
link.SetTargetTemplateId(targetTemplateId);
@@ -35,8 +35,8 @@ namespace AzToolsFramework
}
void PrefabUndoInstance::Capture(
PrefabDom& initialState,
PrefabDom& endState,
const PrefabDom& initialState,
const PrefabDom& endState,
const TemplateId& templateId)
{
m_templateId = templateId;
@@ -79,13 +79,16 @@ namespace AzToolsFramework
//generate undo/redo patches
m_instanceToTemplateInterface->GeneratePatch(m_redoPatch, initialState, endState);
m_instanceToTemplateInterface->AppendEntityAliasToPatchPaths(m_redoPatch, entityId);
m_instanceToTemplateInterface->GeneratePatch(m_undoPatch, endState, initialState);
m_instanceToTemplateInterface->AppendEntityAliasToPatchPaths(m_undoPatch, entityId);
}
void PrefabUndoEntityUpdate::Undo()
{
bool isPatchApplicationSuccessful =
m_instanceToTemplateInterface->PatchEntityInTemplate(m_undoPatch, m_entityAlias, m_templateId);
[[maybe_unused]] bool isPatchApplicationSuccessful =
m_instanceToTemplateInterface->PatchTemplate(m_undoPatch, m_templateId);
AZ_Error(
"Prefab", isPatchApplicationSuccessful,
"Applying the undo patch on the entity with alias '%s' in template with id '%llu' was unsuccessful", m_entityAlias.c_str(),
@@ -94,8 +97,9 @@ namespace AzToolsFramework
void PrefabUndoEntityUpdate::Redo()
{
bool isPatchApplicationSuccessful =
m_instanceToTemplateInterface->PatchEntityInTemplate(m_redoPatch, m_entityAlias, m_templateId);
[[maybe_unused]] bool isPatchApplicationSuccessful =
m_instanceToTemplateInterface->PatchTemplate(m_redoPatch, m_templateId);
AZ_Error(
"Prefab", isPatchApplicationSuccessful,
"Applying the redo patch on the entity with alias '%s' in template with id '%llu' was unsuccessful", m_entityAlias.c_str(),
@@ -51,8 +51,8 @@ namespace AzToolsFramework
explicit PrefabUndoInstance(const AZStd::string& undoOperationName);
void Capture(
PrefabDom& initialState,
PrefabDom& endState,
const PrefabDom& initialState,
const PrefabDom& endState,
const TemplateId& templateId);
void Undo() override;
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
#include <AzToolsFramework/Prefab/PrefabUndo.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
namespace AzToolsFramework
{
namespace Prefab
{
namespace PrefabUndoHelpers
{
void UpdatePrefabInstance(
const Instance& instance, AZStd::string_view undoMessage, const PrefabDom& instanceDomBeforeUpdate,
UndoSystem::URSequencePoint* undoBatch)
{
PrefabDom instanceDomAfterUpdate;
PrefabDomUtils::StoreInstanceInPrefabDom(instance, instanceDomAfterUpdate);
PrefabUndoInstance* state = aznew Prefab::PrefabUndoInstance(undoMessage);
state->Capture(instanceDomBeforeUpdate, instanceDomAfterUpdate, instance.GetTemplateId());
state->SetParent(undoBatch);
state->Redo();
}
}
} // namespace Prefab
} // namespace AzToolsFramework
@@ -0,0 +1,26 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
namespace AzToolsFramework
{
namespace Prefab
{
namespace PrefabUndoHelpers
{
void UpdatePrefabInstance(
const Instance& instance, AZStd::string_view undoMessage, const PrefabDom& instanceDomBeforeUpdate,
UndoSystem::URSequencePoint* undoBatch);
}
} // namespace Prefab
} // namespace AzToolsFramework
@@ -41,7 +41,7 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
}
prefabProcessorContext.ListPrefabs(
[this, &serializeContext, &prefabProcessorContext](AZStd::string_view prefabName, PrefabDom& prefab)
[this, &serializeContext, &prefabProcessorContext]([[maybe_unused]] AZStd::string_view prefabName, PrefabDom& prefab)
{
auto result = RemoveEditorInfo(prefab, serializeContext, prefabProcessorContext);
if (!result)
@@ -163,7 +163,8 @@ namespace AzToolsFramework
QMainWindow* mainWindow = nullptr;
for (QWidget* w : qApp->topLevelWidgets())
{
if (mainWindow = qobject_cast<QMainWindow*>(w))
mainWindow = qobject_cast<QMainWindow*>(w);
if (mainWindow)
{
return mainWindow;
}
@@ -2662,7 +2662,7 @@ namespace AzToolsFramework
QString cleanAssetSafeFolder(QDir::cleanPath(assetSafeFolder.c_str()));
// Compare using clean paths so slash direction does not matter.
// Note that this comparison is case sensitive because some file systems
// Lumberyard supports are case sensitive.
// Open 3D Engine supports are case sensitive.
if (cleanSaveAs.startsWith(cleanAssetSafeFolder))
{
isPathSafeForAssets = true;
@@ -4017,8 +4017,8 @@ namespace AzToolsFramework
// Detach entities action currently acts on entities and all descendants, so include those as part of the selection
AzToolsFramework::EntityIdList selectedDetachEntities(selectedTransformHierarchyEntities.begin(), selectedTransformHierarchyEntities.end());
// A selection in Lumberyard is usually singular, but a selection can have more than one entity.
// No Lumberyard systems support multiple selections, or multiple different groups of selected entities.
// A selection in Open 3D Engine is usually singular, but a selection can have more than one entity.
// No Open 3D Engine systems support multiple selections, or multiple different groups of selected entities.
QString detachEntitiesActionText(QObject::tr("Selection"));
QString detachEntitiesTooltipText;
if (selectedDetachEntities.size() == 1)
@@ -71,7 +71,7 @@ namespace AzToolsFramework
AZ_Assert(!s_perforceConn, "You may only have one Perforce component.\n");
m_shutdownThreadSignal = false;
m_waitingOnTrust = false;
m_autoChangelistDescription = "*Lumberyard Auto";
m_autoChangelistDescription = "*Open 3D Engine Auto";
m_connectionState = SourceControlState::Disabled;
m_validConnection = false;
m_testConnection = false;
@@ -24,7 +24,7 @@ namespace AzToolsFramework
{
QString ComponentTypeMimeData::GetMimeType()
{
return "application/x-amazon-lumberyard-editorcomponenttypes";
return "application/x-amazon-o3de-editorcomponenttypes";
}
AZStd::unique_ptr<QMimeData> ComponentTypeMimeData::Create(const ClassDataContainer& container)
@@ -99,7 +99,7 @@ namespace AzToolsFramework
QString ComponentMimeData::GetMimeType()
{
return "application/x-amazon-lumberyard-editorcomponentdata";
return "application/x-amazon-o3de-editorcomponentdata";
}
AZStd::unique_ptr<QMimeData> ComponentMimeData::Create(const ComponentDataContainer& components)
@@ -15,7 +15,7 @@
* Header file for the editor component base class.
* Derive from this class to create a version of a component to use in the
* editor, as opposed to the version of the component that is used during run time.
* To learn more about editor components, see the [Lumberyard Developer Guide]
* To learn more about editor components, see the [Open 3D Engine Developer Guide]
* (http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-pg-editor-components.html).
*/
@@ -52,7 +52,7 @@ namespace AzToolsFramework
* To create one or more game components to represent your editor component
* in runtime, use BuildGameEntity().
*
* To learn more about editor components, see the [Lumberyard Developer Guide]
* To learn more about editor components, see the [Open 3D Engine Developer Guide]
* (http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-pg-editor-components.html).
*/
class EditorComponentBase
@@ -408,7 +408,7 @@ namespace AzToolsFramework
QString fullLayerPath(layerFolder.filePath(myLayerFileName));
// Lumberyard will read in the layer in whatever format it's in, so there's no need to check what the save format is set to.
// Open 3D Engine will read in the layer in whatever format it's in, so there's no need to check what the save format is set to.
// The save format is also set in this object that is being loaded, so it wouldn't even be available.
m_loadedLayer = AZ::Utils::LoadObjectFromFile<EditorLayer>(fullLayerPath.toUtf8().data());
@@ -1051,7 +1051,6 @@ namespace AzToolsFramework
currentFailure));
// FileIO doesn't support removing directory, so use Qt.
// QDir::IsEmpty isn't available until a newer version fo Qt than Lumberyard is using.
if (layerTempFolder.entryInfoList(
QDir::NoDotAndDotDot | QDir::AllEntries | QDir::System | QDir::Hidden).count() == 0)
{
@@ -1485,7 +1484,7 @@ namespace AzToolsFramework
if (!newLayerEntityId.IsValid())
{
return LayerResult(LayerResultStatus::Error, "Lumberyard was unable to create a layer entity.");
return LayerResult(LayerResultStatus::Error, "Open 3D Engine was unable to create a layer entity.");
}
// If this new layer has a parent, then set its parent.
@@ -58,7 +58,7 @@ namespace AzToolsFramework
AZ::Color m_color = AZ::Color::CreateOne();
// Default to text files, so the save history is easier to understand in source control.
// This attribute only effects writing layers, and is safe to store here instead of on the component.
// When reading files off disk, Lumberyard figures out the correct format automatically.
// When reading files off disk, Open 3D Engine figures out the correct format automatically.
bool m_saveAsBinary = false;
// The layer entity needs to be invisible to all other systems, so they don't show up in the viewport.
@@ -338,7 +338,7 @@ namespace AzToolsFramework
EditorLayer* m_loadedLayer = nullptr;
AZStd::string m_layerFileName;
// Lumberyard's serialization system requires everything in the editor to have a serialized to disk counterpart.
// Open 3D Engine's serialization system requires everything in the editor to have a serialized to disk counterpart.
// Layers have their data split into two categories: Stuff that should save to the layer file, and stuff that should
// save to the layer component in the level. To allow the layer component to edit the data that goes in the layer file,
// a placeholder value is serialized. This is only used at edit time, and is copied and cleared during serialization.
@@ -13,6 +13,7 @@
#include <AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzFramework/Components/NonUniformScaleComponent.h>
#include <AzCore/Math/Transform.h>
#include <AzCore/Math/ToString.h>
namespace AzToolsFramework
@@ -44,7 +45,9 @@ namespace AzToolsFramework
->DataElement(
AZ::Edit::UIHandlers::Default, &EditorNonUniformScaleComponent::m_scale, "Non-uniform Scale",
"Non-uniform scale for this entity only (does not propagate through hierarchy)")
->Attribute(AZ::Edit::Attributes::Min, AZ::MinNonUniformScale)
->Attribute(AZ::Edit::Attributes::Min, AZ::MinTransformScale)
->Attribute(AZ::Edit::Attributes::Max, AZ::MaxTransformScale)
->Attribute(AZ::Edit::Attributes::Step, 0.1f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorNonUniformScaleComponent::OnScaleChanged)
;
}
@@ -106,13 +109,13 @@ namespace AzToolsFramework
void EditorNonUniformScaleComponent::SetScale(const AZ::Vector3& scale)
{
if (scale.GetMinElement() >= AZ::MinNonUniformScale)
if (scale.GetMinElement() >= AZ::MinTransformScale && scale.GetMaxElement() <= AZ::MaxTransformScale)
{
m_scale = scale;
}
else
{
AZ::Vector3 clampedScale = scale.GetMax(AZ::Vector3(AZ::MinNonUniformScale));
AZ::Vector3 clampedScale = scale.GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale));
AZ_Warning("Editor Non-uniform Scale Component", false, "SetScale value was clamped from %s to %s for entity %s",
AZ::ToString(scale).c_str(), AZ::ToString(clampedScale).c_str(), GetEntity()->GetName().c_str());
m_scale = clampedScale;
@@ -1276,7 +1276,6 @@ namespace AzToolsFramework
Attribute(AZ::Edit::Attributes::SliceFlags, AZ::Edit::SliceFlags::NotPushableOnSliceRoot)->
DataElement(TransformScaleHandler, &EditorTransform::m_scale, "Scale", "Local Scale")->
Attribute(AZ::Edit::Attributes::Step, 0.1f)->
Attribute(AZ::Edit::Attributes::Min, 0.01f)->
Attribute(AZ::Edit::Attributes::ReadOnly, &EditorTransform::m_locked)
;
}
@@ -12,6 +12,7 @@
#include "AzToolsFramework_precompiled.h"
#include <ToolsComponents/TransformScalePropertyHandler.h>
#include <AzCore/Math/Transform.h>
#include <AzCore/Math/Vector3.h>
namespace AzToolsFramework
@@ -36,8 +37,8 @@ namespace AzToolsFramework
AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast(&AzToolsFramework::PropertyEditorGUIMessages::RequestWrite, newCtrl);
});
newCtrl->setMinimum(0.01f);
newCtrl->setMaximum(std::numeric_limits<float>::max());
newCtrl->setMinimum(AZ::MinTransformScale);
newCtrl->setMaximum(AZ::MaxTransformScale);
return newCtrl;
}
@@ -56,6 +56,11 @@ namespace AzToolsFramework
return QPixmap();
}
bool EditorEntityUiHandlerBase::CanToggleLockVisibility(AZ::EntityId /*entityId*/) const
{
return true;
}
void EditorEntityUiHandlerBase::PaintItemBackground(QPainter* /*painter*/, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const
{
}
@@ -45,6 +45,8 @@ namespace AzToolsFramework
virtual QString GenerateItemTooltip(AZ::EntityId entityId) const;
//! Returns the item icon pixmap to display in the Outliner.
virtual QPixmap GenerateItemIcon(AZ::EntityId entityId) const;
//! Returns whether the element's lock and visibility state should be accessible in the Outliner
virtual bool CanToggleLockVisibility(AZ::EntityId entityId) const;
//! Paints the background of the item in the Outliner.
virtual void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
@@ -97,8 +97,6 @@ namespace AzToolsFramework
AzToolsFramework::Layers::EditorLayerComponentRequestBus::EventResult(
layerColor, entityId, &AzToolsFramework::Layers::EditorLayerComponentRequestBus::Events::GetLayerColor);
const QTreeView* outlinerTreeView(qobject_cast<const QTreeView*>(option.widget));
int indentation = outlinerTreeView->indentation();
bool isFirstColumn = index.column() == EntityOutlinerListModel::ColumnName;
bool hasVisibleChildren = index.data(EntityOutlinerListModel::ExpandedRole).value<bool>() && index.model()->hasChildren(index);
@@ -112,7 +112,6 @@ namespace LegacyFramework
m_applicationEntity = NULL;
m_ptrSystemEntity = NULL;
m_applicationModule[0] = 0;
m_appRoot[0] = 0;
}
HMODULE Application::GetMainModule()
@@ -490,15 +489,7 @@ namespace LegacyFramework
AZ_Assert(!m_desc.m_enableProjectManager || m_desc.m_enableGUI, "Enabling the project manager in the application settings requires enabling the GUI as well.");
// if we're a GUI APP we need the UI Framework component:
if (m_desc.m_enableGUI)
{
EnsureComponentCreated(AzToolsFramework::Framework::RTTI_Type());
}
else
{
EnsureComponentCreated(AzToolsFramework::Framework::RTTI_Type());
}
EnsureComponentCreated(AzToolsFramework::Framework::RTTI_Type());
}
//=========================================================================
@@ -16,7 +16,7 @@
#include "NewLogTabDialog.h"
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include <UI/Logging/ui_NewLogTabDialog.h>
#include <AzToolsFramework/UI/Logging/ui_NewLogTabDialog.h>
AZ_POP_DISABLE_WARNING
#include <QPushButton>
#include <QLineEdit>
@@ -97,4 +97,4 @@ namespace AzToolsFramework
} // namespace LogPanel
} // namespace AzToolsFramework
#include "UI/Logging/moc_NewLogTabDialog.cpp"
#include "UI/Logging/moc_NewLogTabDialog.cpp"
@@ -351,58 +351,68 @@ namespace AzToolsFramework
QVariant EntityOutlinerListModel::dataForVisibility(const QModelIndex& index, int role) const
{
auto id = GetEntityFromIndex(index);
auto entityId = GetEntityFromIndex(index);
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
switch (role)
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
{
switch (role)
{
case Qt::CheckStateRole:
{
return IsEntitySetToBeVisible(id) ? Qt::Checked : Qt::Unchecked;
}
{
return IsEntitySetToBeVisible(entityId) ? Qt::Checked : Qt::Unchecked;
}
case Qt::ToolTipRole:
{
return QString("Show/Hide Entity");
}
{
return QString("Show/Hide Entity");
}
case Qt::SizeHintRole:
{
return QSize(20, 20);
{
return QSize(20, 20);
}
}
return dataForAll(index, role);
}
return dataForAll(index, role);
return QVariant();
}
QVariant EntityOutlinerListModel::dataForLock(const QModelIndex& index, int role) const
{
auto id = GetEntityFromIndex(index);
auto entityId = GetEntityFromIndex(index);
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
switch (role)
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
{
switch (role)
{
case Qt::CheckStateRole:
{
bool isLocked = false;
// Lock state is tracked in 3 places:
// EditorLockComponent, EditorEntityModel, and ComponentEntityObject.
// In addition to that, entities that are in layers can have the layer's lock state override their own.
// Retrieving the lock state from the lock component is ideal for drawing the lock icon in the outliner because
// the outliner needs to show that specific entity's lock state, and not the actual final lock state including the layer behavior.
// The EditorLockComponent only knows about the specific entity's lock state and not the hierarchy.
EditorLockComponentRequestBus::EventResult(
isLocked, id, &EditorLockComponentRequests::GetLocked);
{
bool isLocked = false;
// Lock state is tracked in 3 places:
// EditorLockComponent, EditorEntityModel, and ComponentEntityObject.
// In addition to that, entities that are in layers can have the layer's lock state override their own.
// Retrieving the lock state from the lock component is ideal for drawing the lock icon in the outliner because
// the outliner needs to show that specific entity's lock state, and not the actual final lock state including the layer
// behavior. The EditorLockComponent only knows about the specific entity's lock state and not the hierarchy.
EditorLockComponentRequestBus::EventResult(isLocked, entityId, &EditorLockComponentRequests::GetLocked);
return isLocked ? Qt::Checked : Qt::Unchecked;
}
return isLocked ? Qt::Checked : Qt::Unchecked;
}
case Qt::ToolTipRole:
{
return QString("Lock/Unlock Entity (Locked means the entity cannot be moved in the viewport)");
}
{
return QString("Lock/Unlock Entity (Locked means the entity cannot be moved in the viewport)");
}
case Qt::SizeHintRole:
{
return QSize(20, 20);
{
return QSize(20, 20);
}
}
return dataForAll(index, role);
}
return dataForAll(index, role);
return QVariant();
}
QVariant EntityOutlinerListModel::dataForSortIndex(const QModelIndex& index, int role) const
@@ -429,8 +439,12 @@ namespace AzToolsFramework
if (value.canConvert<Qt::CheckState>())
{
const auto entityId = GetEntityFromIndex(index);
switch (index.column())
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
{
switch (index.column())
{
case ColumnVisibilityToggle:
ToggleEntityVisibility(entityId);
break;
@@ -438,6 +452,7 @@ namespace AzToolsFramework
case ColumnLockToggle:
ToggleEntityLockState(entityId);
break;
}
}
}
}
@@ -826,7 +841,6 @@ namespace AzToolsFramework
for (const ComponentAssetPair& pair : componentAssetPairs)
{
const AZ::TypeId& componentType = pair.first;
const AZ::Data::AssetId& assetId = pair.second;
componentsToAdd.push_back(componentType);
}
@@ -853,7 +867,6 @@ namespace AzToolsFramework
}
// Assign asset associated with each created component.
const AZ::Entity::ComponentArrayType& componentsAdded = addComponentsOutcome.GetValue()[targetEntityId].m_componentsAdded;
for (const ComponentAssetPair& pair : componentAssetPairs)
{
const AZ::TypeId& componentType = pair.first;
@@ -1978,7 +1991,8 @@ namespace AzToolsFramework
}
// Retrieve the Entity UI Handler
AZ::EntityId entityId(index.data(EntityOutlinerListModel::EntityIdRole).value<AZ::u64>());
auto firstColumnIndex = index.siblingAtColumn(0);
AZ::EntityId entityId(firstColumnIndex.data(EntityOutlinerListModel::EntityIdRole).value<AZ::u64>());
auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(entityId);
const bool isSelected = (option.state & QStyle::State_Selected);
@@ -2001,8 +2015,11 @@ namespace AzToolsFramework
case EntityOutlinerListModel::ColumnVisibilityToggle:
case EntityOutlinerListModel::ColumnLockToggle:
{
// Paint the Visibility and Lock state checkboxes
PaintCheckboxes(painter, option, index, isHovered);
if (!entityUiHandler || entityUiHandler->CanToggleLockVisibility(entityId))
{
// Paint the Visibility and Lock state checkboxes
PaintCheckboxes(painter, option, index, isHovered);
}
}
break;
case EntityOutlinerListModel::ColumnName:
@@ -49,7 +49,7 @@
#include <QTimer>
#include <QToolButton>
#include <UI/Outliner/ui_EntityOutlinerWidget.h>
#include <AzToolsFramework/UI/Outliner/ui_EntityOutlinerWidget.h>
namespace
{
@@ -184,6 +184,7 @@ namespace AzToolsFramework
m_gui->m_objectTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_gui->m_objectTree->setAutoScrollMargin(20);
m_gui->m_objectTree->setIndentation(24);
m_gui->m_objectTree->setRootIsDecorated(false);
connect(m_gui->m_objectTree, &QTreeView::customContextMenuRequested, this, &EntityOutlinerWidget::OnOpenTreeContextMenu);
// custom item delegate
@@ -804,10 +805,10 @@ namespace AzToolsFramework
addAction(m_actionToDeleteSelectionAndDescendants);
m_actionToRenameSelection = new QAction(tr("Rename"), this);
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC)
// "Alt+Return" translates to Option+Return on macOS
m_actionToRenameSelection->setShortcut(tr("Alt+Return"));
#elseif Q_OS_WIN
#elif defined(Q_OS_WIN)
m_actionToRenameSelection->setShortcut(tr("F2"));
#endif
m_actionToRenameSelection->setShortcutContext(Qt::WidgetWithChildrenShortcut);
@@ -1089,16 +1090,6 @@ namespace AzToolsFramework
setEnabled(true);
SetEntityOutlinerState(m_gui, true);
}
void EntityOutlinerWidget::SetRootEntity(AZ::EntityId rootEntityId)
{
// The proxy model needs a tick to initialize, else it will return an invalid index in mapFromSource.
QTimer::singleShot(0, this, [rootEntityId, this]() {
QModelIndex rootIndex = m_listModel->GetIndexFromEntity(rootEntityId);
QModelIndex proxyIndex = m_proxyModel->mapFromSource(rootIndex);
m_gui->m_objectTree->setRootIndex(proxyIndex);
});
}
void EntityOutlinerWidget::SetUpdatesEnabled(bool enable)
{
@@ -1114,6 +1105,12 @@ namespace AzToolsFramework
}
}
void EntityOutlinerWidget::ExpandEntityChildren(AZ::EntityId entityId)
{
QModelIndex index = GetIndexFromEntityId(entityId);
m_gui->m_objectTree->expand(index);
}
void EntityOutlinerWidget::OnEntityInfoUpdatedAddChildEnd(AZ::EntityId /*parentId*/, AZ::EntityId childId)
{
QueueContentUpdateSort(childId);
@@ -106,8 +106,8 @@ namespace AzToolsFramework
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
// EntityOutlinerWidgetInterface
void SetRootEntity(AZ::EntityId rootEntityId) override;
void SetUpdatesEnabled(bool enable) override;
void ExpandEntityChildren(AZ::EntityId entityId) override;
// Build a selection object from the given entities. Entities already in the Widget's selection buffers are ignored.
template <class EntityIdCollection>
@@ -22,8 +22,8 @@ namespace AzToolsFramework
public:
AZ_RTTI(EntityOutlinerWidgetInterface, "{30C0F252-EC84-4196-BF59-EB9E73B8ADCB}");
virtual void SetRootEntity(AZ::EntityId rootEntityId) = 0;
virtual void SetUpdatesEnabled(bool enable) = 0;
virtual void ExpandEntityChildren(AZ::EntityId entityId) = 0;
};
} // namespace AzToolsFramework
@@ -0,0 +1,78 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzToolsFramework/UI/Prefab/LevelRootUiHandler.h>
#include <AzToolsFramework/UI/Prefab/PrefabEditInterface.h>
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
#include <AzToolsFramework/UI/Outliner/EntityOutlinerListModel.hxx>
#include <QAbstractItemModel>
#include <QPainter>
#include <QPainterPath>
#include <QTreeView>
namespace AzToolsFramework
{
const QColor LevelRootUiHandler::m_levelRootBorderColor = QColor("#656565");
const QString LevelRootUiHandler::m_levelRootIconPath = QString(":/Level/level.svg");
LevelRootUiHandler::LevelRootUiHandler()
{
m_prefabEditInterface = AZ::Interface<Prefab::PrefabEditInterface>::Get();
if (m_prefabEditInterface == nullptr)
{
AZ_Assert(false, "LevelRootUiHandler - could not get PrefabEditInterface on LevelRootUiHandler construction.");
return;
}
m_prefabPublicInterface = AZ::Interface<Prefab::PrefabPublicInterface>::Get();
if (m_prefabPublicInterface == nullptr)
{
AZ_Assert(false, "LevelRootUiHandler - could not get PrefabPublicInterface on LevelRootUiHandler construction.");
return;
}
}
QPixmap LevelRootUiHandler::GenerateItemIcon(AZ::EntityId /*entityId*/) const
{
return QPixmap(m_levelRootIconPath);
}
bool LevelRootUiHandler::CanToggleLockVisibility(AZ::EntityId /*entityId*/) const
{
return false;
}
void LevelRootUiHandler::PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& /*index*/) const
{
if (!painter)
{
AZ_Warning("LevelRootUiHandler", false, "LevelRootUiHandler - painter is nullptr, can't draw Prefab outliner background.");
return;
}
QPen borderLinePen(m_levelRootBorderColor, m_levelRootBorderThickness);
QRect rect = option.rect;
rect.setLeft(rect.left() + (m_levelRootBorderThickness / 2));
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(borderLinePen);
// Draw border at the bottom
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
}
}
@@ -0,0 +1,49 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h>
namespace AzToolsFramework
{
namespace Prefab
{
class PrefabEditInterface;
class PrefabPublicInterface;
};
class LevelRootUiHandler
: public EditorEntityUiHandlerBase
{
public:
AZ_CLASS_ALLOCATOR(LevelRootUiHandler, AZ::SystemAllocator, 0);
AZ_RTTI(AzToolsFramework::LevelRootUiHandler, "{B1D3B270-CD29-4033-873A-D78E76AB24A4}", EditorEntityUiHandlerBase);
LevelRootUiHandler();
~LevelRootUiHandler() override = default;
// EditorEntityUiHandler...
QPixmap GenerateItemIcon(AZ::EntityId entityId) const override;
bool CanToggleLockVisibility(AZ::EntityId entityId) const override;
void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
private:
Prefab::PrefabEditInterface* m_prefabEditInterface = nullptr;
Prefab::PrefabPublicInterface* m_prefabPublicInterface = nullptr;
static constexpr int m_levelRootBorderThickness = 1;
static const QColor m_levelRootBorderColor;
static const QString m_levelRootIconPath;
};
} // namespace AzToolsFramework
@@ -24,6 +24,7 @@
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
#include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
#include <AzToolsFramework/ToolsComponents/EditorLayerComponentBus.h>
#include <AzToolsFramework/UI/EditorEntityUi/EditorEntityUiInterface.h>
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationInterface.h>
@@ -39,9 +40,12 @@ namespace AzToolsFramework
{
namespace Prefab
{
EditorEntityUiInterface* PrefabIntegrationManager::s_editorEntityUiInterface = nullptr;
PrefabPublicInterface* PrefabIntegrationManager::s_prefabPublicInterface = nullptr;
PrefabEditInterface* PrefabIntegrationManager::s_prefabEditInterface = nullptr;
PrefabLoaderInterface* PrefabIntegrationManager::s_prefabLoaderInterface = nullptr;
const AZStd::string PrefabIntegrationManager::s_prefabFileExtension = ".prefab";
void PrefabUserSettings::Reflect(AZ::ReflectContext* context)
@@ -79,6 +83,13 @@ namespace AzToolsFramework
return;
}
s_prefabLoaderInterface = AZ::Interface<PrefabLoaderInterface>::Get();
if (s_prefabLoaderInterface == nullptr)
{
AZ_Assert(false, "Prefab - could not get PrefabLoaderInterface on PrefabIntegrationManager construction.");
return;
}
EditorContextMenuBus::Handler::BusConnect();
PrefabInstanceContainerNotificationBus::Handler::BusConnect();
AZ::Interface<PrefabIntegrationInterface>::Register(this);
@@ -130,14 +141,14 @@ namespace AzToolsFramework
AzFramework::ApplicationRequests::Bus::BroadcastResult(
prefabWipFeaturesEnabled, &AzFramework::ApplicationRequests::ArePrefabWipFeaturesEnabled);
AzToolsFramework::EntityIdList selectedEntities;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
if (prefabWipFeaturesEnabled)
{
// Create Prefab
{
AzToolsFramework::EntityIdList selectedEntities;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
if (!selectedEntities.empty())
{
bool layerInSelection = false;
@@ -186,10 +197,6 @@ namespace AzToolsFramework
// Edit/Save Prefab
{
AzToolsFramework::EntityIdList selectedEntities;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
selectedEntities, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
if (selectedEntities.size() == 1)
{
AZ::EntityId selectedEntity = selectedEntities[0];
@@ -237,6 +244,14 @@ namespace AzToolsFramework
{
menu->addSeparator();
}
QAction* deleteAction = menu->addAction(QObject::tr("Delete"));
QObject::connect(deleteAction, &QAction::triggered, deleteAction, [this] { ContextMenu_DeleteSelected(); });
if (selectedEntities.size() == 0 ||
(selectedEntities.size() == 1 && s_prefabPublicInterface->IsLevelInstanceContainerEntity(selectedEntities[0])))
{
deleteAction->setDisabled(true);
}
}
void PrefabIntegrationManager::HandleSourceFileType(AZStd::string_view sourceFilePath, AZ::EntityId parentId, AZ::Vector3 position) const
@@ -316,14 +331,15 @@ namespace AzToolsFramework
GenerateSuggestedFilenameFromEntities(prefabRootEntities, suggestedName);
if (!QueryUserForPrefabSaveLocation(suggestedName, targetDirectory, AZ_CRC("PrefabUserSettings"), activeWindow, prefabName, prefabFilePath))
if (!QueryUserForPrefabSaveLocation(
suggestedName, targetDirectory, AZ_CRC("PrefabUserSettings"), activeWindow, prefabName, prefabFilePath))
{
// User canceled prefab creation, or error prevented continuation.
return;
}
}
auto createPrefabOutcome = s_prefabPublicInterface->CreatePrefab(selectedEntities, prefabFilePath);
auto createPrefabOutcome = s_prefabPublicInterface->CreatePrefab(selectedEntities, s_prefabLoaderInterface->GetRelativePathToProject(prefabFilePath.data()));
if (!createPrefabOutcome.IsSuccess())
{
@@ -369,6 +385,16 @@ namespace AzToolsFramework
}
}
void PrefabIntegrationManager::ContextMenu_DeleteSelected()
{
AzToolsFramework::EntityIdList selectedEntityIds;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
selectedEntityIds, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
&AzToolsFramework::ToolsApplicationRequests::DeleteEntitiesAndAllDescendants, selectedEntityIds);
}
void PrefabIntegrationManager::GenerateSuggestedFilenameFromEntities(const EntityIdList& entityIds, AZStd::string& outName)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
@@ -630,7 +656,7 @@ namespace AzToolsFramework
QString cleanAssetSafeFolder(QDir::cleanPath(assetSafeFolder.c_str()));
// Compare using clean paths so slash direction does not matter.
// Note that this comparison is case sensitive because some file systems
// Lumberyard supports are case sensitive.
// Open 3D Engine supports are case sensitive.
if (cleanSaveAs.startsWith(cleanAssetSafeFolder))
{
isPathSafeForAssets = true;
@@ -972,7 +998,14 @@ namespace AzToolsFramework
void PrefabIntegrationManager::OnPrefabComponentActivate(AZ::EntityId entityId)
{
s_editorEntityUiInterface->RegisterEntity(entityId, m_prefabUiHandler.GetHandlerId());
if (s_prefabPublicInterface->IsLevelInstanceContainerEntity(entityId))
{
s_editorEntityUiInterface->RegisterEntity(entityId, m_levelRootUiHandler.GetHandlerId());
}
else
{
s_editorEntityUiInterface->RegisterEntity(entityId, m_prefabUiHandler.GetHandlerId());
}
}
void PrefabIntegrationManager::OnPrefabComponentDeactivate(AZ::EntityId entityId)
@@ -19,6 +19,7 @@
#include <AzToolsFramework/AssetBrowser/AssetBrowserSourceDropBus.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
#include <AzToolsFramework/UI/Prefab/LevelRootUiHandler.h>
#include <AzToolsFramework/UI/Prefab/PrefabEditManager.h>
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationBus.h>
#include <AzToolsFramework/UI/Prefab/PrefabIntegrationInterface.h>
@@ -28,6 +29,9 @@ namespace AzToolsFramework
{
namespace Prefab
{
class PrefabLoaderInterface;
//! Structure for saving/retrieving user settings related to prefab workflows.
class PrefabUserSettings
: public AZ::UserSettings
@@ -77,6 +81,9 @@ namespace AzToolsFramework
// Manages the Edit Mode UI for prefabs
PrefabEditManager m_prefabEditManager;
// Used to handle the UI for the level root
LevelRootUiHandler m_levelRootUiHandler;
// Used to handle the UI for prefab entities
PrefabUiHandler m_prefabUiHandler;
@@ -85,6 +92,7 @@ namespace AzToolsFramework
static void ContextMenu_InstantiatePrefab();
static void ContextMenu_EditPrefab(AZ::EntityId containerEntity);
static void ContextMenu_SavePrefab(AZ::EntityId containerEntity);
static void ContextMenu_DeleteSelected();
// Prompt and resolve dialogs
static bool QueryUserForPrefabSaveLocation(
@@ -124,6 +132,7 @@ namespace AzToolsFramework
static EditorEntityUiInterface* s_editorEntityUiInterface;
static PrefabPublicInterface* s_prefabPublicInterface;
static PrefabEditInterface* s_prefabEditInterface;
static PrefabLoaderInterface* s_prefabLoaderInterface;
};
}
}
@@ -100,7 +100,7 @@ AZ_PUSH_DISABLE_WARNING(4244 4251 4800, "-Wunknown-warning-option") // 4244: con
#include <QTimer>
AZ_POP_DISABLE_WARNING
#include <UI/PropertyEditor/ui_EntityPropertyEditor.h>
#include <AzToolsFramework/UI/PropertyEditor/ui_EntityPropertyEditor.h>
// This has to live outside of any namespaces due to issues on Linux with calls to Q_INIT_RESOURCE if they are inside a namespace
void initEntityPropertyEditorResources()
@@ -32,7 +32,7 @@
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
#include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
#include <AzQtComponents/Components/LumberyardStylesheet.h>
#include <AzQtComponents/Components/O3DEStylesheet.h>
#include <QtWidgets/QWidget>
#include <QtGui/QIcon>
@@ -62,6 +62,7 @@ AZ_POP_DISABLE_WARNING
#include <UI/PropertyEditor/Model/AssetCompleterModel.h>
#include <UI/PropertyEditor/View/AssetCompleterListView.h>
#include <UI/PropertyEditor/ThumbnailDropDown.h>
namespace AzToolsFramework
{
@@ -95,6 +96,12 @@ namespace AzToolsFramework
m_thumbnail->setFixedSize(QSize(24, 24));
m_thumbnail->setVisible(false);
m_thumbnailDropDown = new ThumbnailDropDown(this);
m_thumbnailDropDown->setFixedSize(QSize(40, 24));
m_thumbnailDropDown->setVisible(false);
connect(m_thumbnailDropDown, &ThumbnailDropDown::clicked, this, &PropertyAssetCtrl::OnEditButtonClicked);
m_editButton = new QToolButton(this);
m_editButton->setAutoRaise(true);
m_editButton->setIcon(QIcon(":/stylesheet/img/UI20/open-in-internal-app.svg"));
@@ -104,6 +111,7 @@ namespace AzToolsFramework
connect(m_editButton, &QToolButton::clicked, this, &PropertyAssetCtrl::OnEditButtonClicked);
pLayout->addWidget(m_thumbnail);
pLayout->addWidget(m_thumbnailDropDown);
pLayout->addWidget(m_browseEdit);
pLayout->addWidget(m_editButton);
@@ -1082,8 +1090,9 @@ namespace AzToolsFramework
void PropertyAssetCtrl::UpdateThumbnail()
{
m_thumbnail->setVisible(m_showThumbnail);
m_thumbnailDropDown->setVisible(m_showThumbnailDropDown);
if (m_showThumbnail)
if (m_showThumbnail || m_showThumbnailDropDown)
{
const AZ::Data::AssetId assetID = GetCurrentAssetID();
if (assetID.IsValid())
@@ -1098,13 +1107,21 @@ namespace AzToolsFramework
if (result)
{
SharedThumbnailKey thumbnailKey = MAKE_TKEY(AzToolsFramework::AssetBrowser::ProductThumbnailKey, assetID);
m_thumbnail->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
if (m_showThumbnail)
{
m_thumbnail->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
}
if (m_showThumbnailDropDown)
{
m_thumbnailDropDown->SetThumbnailKey(thumbnailKey, Thumbnailer::ThumbnailContext::DefaultContext);
}
return;
}
}
}
m_thumbnail->ClearThumbnail();
m_thumbnailDropDown->ClearThumbnail();
}
void PropertyAssetCtrl::SetClearButtonEnabled(bool enable)
@@ -1138,6 +1155,16 @@ namespace AzToolsFramework
return m_showThumbnail;
}
void PropertyAssetCtrl::SetShowThumbnailDropDown(bool enable)
{
m_showThumbnailDropDown = enable;
}
bool PropertyAssetCtrl::GetShowThumbnailDropDown() const
{
return m_showThumbnailDropDown;
}
const AZ::Uuid& AssetPropertyHandlerDefault::GetHandledType() const
{
return AZ::GetAssetClassId();
@@ -1248,7 +1275,7 @@ namespace AzToolsFramework
GUI->SetBrowseButtonIcon(QIcon(iconPath.c_str()));
}
}
else if (attrib == AZ_CRC_CE("ShowThumbnail"))
else if (attrib == AZ_CRC_CE("Thumbnail"))
{
bool showThumbnail = false;
if (attrValue->Read<bool>(showThumbnail))
@@ -1256,6 +1283,19 @@ namespace AzToolsFramework
GUI->SetShowThumbnail(showThumbnail);
}
}
else if (attrib == AZ_CRC_CE("ThumbnailWithDropDown"))
{
PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute());
if (func)
{
GUI->SetShowThumbnailDropDown(true);
GUI->SetEditNotifyCallback(func);
}
else
{
GUI->SetEditNotifyCallback(nullptr);
}
}
}
void AssetPropertyHandlerDefault::WriteGUIValuesIntoProperty(size_t index, PropertyAssetCtrl* GUI, property_t& instance, InstanceDataNode* node)
@@ -45,6 +45,7 @@ namespace AzToolsFramework
{
class AssetCompleterModel;
class AssetCompleterListView;
class ThumbnailDropDown;
namespace Thumbnailer
{
@@ -94,6 +95,7 @@ namespace AzToolsFramework
void OnAssetIDChanged(AZ::Data::AssetId newAssetID);
protected:
ThumbnailDropDown* m_thumbnailDropDown = nullptr;
Thumbnailer::ThumbnailWidget* m_thumbnail = nullptr;
QPushButton* m_errorButton = nullptr;
QToolButton* m_editButton = nullptr;
@@ -156,6 +158,8 @@ namespace AzToolsFramework
bool m_showThumbnail = false;
bool m_showThumbnailDropDown = false;
// ! Default suffix used in the field's placeholder text when a default value is set.
const char* m_DefaultSuffix = " (default)";
@@ -205,6 +209,8 @@ namespace AzToolsFramework
void SetShowThumbnail(bool enable);
bool GetShowThumbnail() const;
void SetShowThumbnailDropDown(bool enable);
bool GetShowThumbnailDropDown() const;
void SetSelectedAssetID(const AZ::Data::AssetId& newID);
void SetCurrentAssetType(const AZ::Data::AssetType& newType);
@@ -89,7 +89,7 @@ namespace AzToolsFramework
//! When set, disables data access for this property editor.
//! This prevents any value refreshes from the inspected values from occurring as well as disabling user input.
void PreventDataAccess(bool shouldPrevent);
// LUMBERYARD_DEPRECATED(LY-120821)
// O3DE_DEPRECATED(LY-120821)
void PreventRefresh(bool shouldPrevent){PreventDataAccess(shouldPrevent);}
void SetAutoResizeLabels(bool autoResizeLabels);
@@ -0,0 +1,101 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzToolsFramework/Debug/TraceContext.h>
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // 4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer<QRawFontPrivate>' needs to have dll-interface to be used by clients of class 'QRawFont'
// 4800: 'QTextEngine *const ': forcing value to bool 'true' or 'false' (performance warning)
#include <QLabel>
#include <QHBoxLayout>
#include <QEvent>
#include <QPainter>
#include <UI/UICore/AspectRatioAwarePixmapWidget.hxx>
#include <Thumbnails/ThumbnailWidget.h>
AZ_POP_DISABLE_WARNING
#include "ThumbnailDropDown.h"
namespace AzToolsFramework
{
ThumbnailDropDown::ThumbnailDropDown(QWidget* parent)
: QWidget(parent)
{
QHBoxLayout* pLayout = new QHBoxLayout();
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setSpacing(0);
m_thumbnail = new Thumbnailer::ThumbnailWidget(this);
m_thumbnail->setFixedSize(QSize(24, 24));
m_dropDownArrow = new AspectRatioAwarePixmapWidget(this);
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0.png"));
m_dropDownArrow->setFixedSize(QSize(8, 24));
m_emptyThumbnail = new QLabel(this);
m_emptyThumbnail->setPixmap(QPixmap(":/stylesheet/img/line.png"));
m_emptyThumbnail->setFixedSize(QSize(24, 24));
pLayout->addWidget(m_emptyThumbnail);
pLayout->addWidget(m_thumbnail);
pLayout->addSpacing(4);
pLayout->addWidget(m_dropDownArrow);
pLayout->addSpacing(4);
setLayout(pLayout);
}
void ThumbnailDropDown::SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName)
{
m_emptyThumbnail->setVisible(false);
m_thumbnail->SetThumbnailKey(key, contextName);
}
void ThumbnailDropDown::ClearThumbnail()
{
m_emptyThumbnail->setVisible(true);
m_thumbnail->ClearThumbnail();
}
bool ThumbnailDropDown::event(QEvent* e)
{
if (isEnabled())
{
if (e->type() == QEvent::MouseButtonPress)
{
emit clicked();
return true; //ignore
}
}
return QWidget::event(e);
}
void ThumbnailDropDown::paintEvent(QPaintEvent* e)
{
QPainter p(this);
QRect targetRect(QPoint(), QSize(40, 24));
p.fillRect(targetRect, QColor(17, 17, 17)); // #111111
QWidget::paintEvent(e);
}
void ThumbnailDropDown::enterEvent(QEvent* e)
{
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0_highlighted.png"));
QWidget::enterEvent(e);
}
void ThumbnailDropDown::leaveEvent(QEvent* e)
{
m_dropDownArrow->setPixmap(QPixmap(":/stylesheet/img/triangle0.png"));
QWidget::leaveEvent(e);
}
}
#include "UI/PropertyEditor/moc_ThumbnailDropDown.cpp"
@@ -0,0 +1,59 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#if !defined(Q_MOC_RUN)
#include <AzCore/PlatformDef.h>
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...'
// 4800: 'uint': forcing value to bool 'true' or 'false' (performance warning)
#include <QWidget>
AZ_POP_DISABLE_WARNING
#endif
namespace AzToolsFramework
{
class AspectRatioAwarePixmapWidget;
namespace Thumbnailer
{
class ThumbnailWidget;
}
class ThumbnailDropDown : public QWidget
{
Q_OBJECT
public:
explicit ThumbnailDropDown(QWidget* parent = nullptr);
//! Call this to set what thumbnail widget will display
void SetThumbnailKey(Thumbnailer::SharedThumbnailKey key, const char* contextName = "Default");
//! Remove current thumbnail
void ClearThumbnail();
bool event(QEvent* e) override;
Q_SIGNALS:
void clicked();
protected:
void paintEvent(QPaintEvent* e) override;
void enterEvent(QEvent* e) override;
void leaveEvent(QEvent* e) override;
private:
Thumbnailer::ThumbnailWidget* m_thumbnail = nullptr;
QLabel* m_emptyThumbnail = nullptr;
AspectRatioAwarePixmapWidget* m_dropDownArrow = nullptr;
};
}
@@ -11,7 +11,7 @@
*/
#include "AzToolsFramework_precompiled.h"
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include "UI/Slice/ui_NotificationWindow.h"
#include <AzToolsFramework/UI/Slice/ui_NotificationWindow.h>
AZ_POP_DISABLE_WARNING
#include "UI/Slice/Constants.h"
@@ -14,7 +14,7 @@
#include "OverwritePromptDialog.hxx"
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include <UI/UICore/ui_OverwritePromptDialog.h>
#include <AzToolsFramework/UI/UICore/ui_OverwritePromptDialog.h>
AZ_POP_DISABLE_WARNING
namespace AzToolsFramework
@@ -54,4 +54,4 @@ namespace AzToolsFramework
}
#include "UI/UICore/moc_OverwritePromptDialog.cpp"
#include "UI/UICore/moc_OverwritePromptDialog.cpp"
@@ -18,7 +18,7 @@
#include <AzToolsFramework/UI/UICore/ProgressShield.hxx>
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QLayoutItem::align': class 'QFlags<Qt::AlignmentFlag>' needs to have dll-interface to be used by clients of class 'QLayoutItem'
#include <UI/UICore/ui_ProgressShield.h>
#include <AzToolsFramework/UI/UICore/ui_ProgressShield.h>
AZ_POP_DISABLE_WARNING
namespace AzToolsFramework
@@ -118,4 +118,4 @@ namespace AzToolsFramework
} // namespace AzToolsFramework
#include "UI/UICore/moc_ProgressShield.cpp"
#include "UI/UICore/moc_ProgressShield.cpp"
@@ -14,7 +14,7 @@
#include "SaveChangesDialog.hxx"
AZ_PUSH_DISABLE_WARNING(4244 4251, "-Wunknown-warning-option")
#include <UI/UICore/ui_SaveChangesDialog.h>
#include <AzToolsFramework/UI/UICore/ui_SaveChangesDialog.h>
AZ_POP_DISABLE_WARNING
namespace AzToolsFramework
@@ -52,4 +52,4 @@ namespace AzToolsFramework
}
}
#include "UI/UICore/moc_SaveChangesDialog.cpp"
#include "UI/UICore/moc_SaveChangesDialog.cpp"
@@ -246,7 +246,7 @@ namespace UnitTest
R"(... client unittest_workspace)" "\r\n"
R"(... status pending)" "\r\n"
R"(... changeType public)" "\r\n"
R"(... desc *Lumberyard Auto)" "\r\n"
R"(... desc *Open 3D Engine Auto)" "\r\n"
"\r\n";
}
else if (m_commandArgs.starts_with("fstat"))
@@ -65,7 +65,7 @@ namespace AzToolsFramework
if (!contextMenu.m_menu->isEmpty())
{
contextMenu.m_menu->popup(QCursor::pos());
contextMenu.m_menu->exec(QCursor::pos());
}
}
}
@@ -21,7 +21,12 @@
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Viewport/ViewportTypes.h>
class QPoint;
class QPoint; // LYN-2315 in-progress, remove this
namespace AzFramework
{
struct ScreenPoint;
}
namespace AzToolsFramework
{
@@ -235,12 +240,12 @@ namespace AzToolsFramework
/// Restores the cursor and ends locking it in place, allowing it to be moved freely.
virtual void EndCursorCapture() = 0;
/// Gets the most recent recorded cursor position in the viewport in screen space coordinates.
virtual QPoint ViewportCursorScreenPosition() = 0;
virtual AzFramework::ScreenPoint ViewportCursorScreenPosition() = 0;
/// Gets the cursor position recorded prior to the most recent cursor position.
/// Note: The cursor may be captured by the viewport, in which case this may not correspond to the last result
/// from ViewportCursorScreenPosition. This method will always return the correct position to generate a mouse
/// position delta.
virtual AZStd::optional<QPoint> PreviousViewportCursorScreenPosition() = 0;
virtual AZStd::optional<AzFramework::ScreenPoint> PreviousViewportCursorScreenPosition() = 0;
protected:
~ViewportMouseCursorRequests() = default;
@@ -202,13 +202,19 @@ namespace AzToolsFramework
return mouseInteractionEvent.m_wheelDelta;
}
/// Return Qt QPoint from an Viewport ScreenPoint.
/// Return QPoint from AzFramework::ScreenPoint.
inline QPoint QPointFromScreenPoint(const AzFramework::ScreenPoint& screenPoint)
{
return {screenPoint.m_x, screenPoint.m_y};
}
/// Map from Qt -> Lumberyard buttons.
/// Return AzFramework::ScreenPoint from QPoint.
inline AzFramework::ScreenPoint ScreenPointFromQPoint(const QPoint& qpoint)
{
return AzFramework::ScreenPoint{qpoint.x(), qpoint.y()};
}
/// Map from Qt -> Open 3D Engine buttons.>>>>>>> main
inline AZ::u32 TranslateMouseButtons(const Qt::MouseButtons buttons)
{
AZ::u32 result = 0;
@@ -218,7 +224,7 @@ namespace AzToolsFramework
return result;
}
/// Map from Qt -> Lumberyard modifiers.
/// Map from Qt -> Open 3D Engine modifiers.
inline AZ::u32 TranslateKeyboardModifiers(const Qt::KeyboardModifiers modifiers)
{
AZ::u32 result = 0;
@@ -228,13 +234,13 @@ namespace AzToolsFramework
return result;
}
/// Interface to translate Qt modifiers to Lumberyard modifiers.
/// Interface to translate Qt modifiers to Open 3D Engine modifiers.
inline KeyboardModifiers BuildKeyboardModifiers(const Qt::KeyboardModifiers modifiers)
{
return KeyboardModifiers(TranslateKeyboardModifiers(modifiers));
}
/// Interface to translate Qt buttons to Lumberyard buttons.
/// Interface to translate Qt buttons to Open 3D Engine buttons.
inline MouseButtons BuildMouseButtons(const Qt::MouseButtons buttons)
{
return MouseButtons(TranslateMouseButtons(buttons));
@@ -1603,7 +1603,7 @@ namespace AzToolsFramework
const AZ::Vector3 uniformScale = AZ::Vector3(action.m_start.m_sign * sumVectorElements(action.LocalScaleOffset()));
const AZ::Vector3 scale = (AZ::Vector3::CreateOne() +
(uniformScale / initialScale)).GetMax(AZ::Vector3(0.01f));
(uniformScale / initialScale)).GetClamp(AZ::Vector3(AZ::MinTransformScale), AZ::Vector3(AZ::MaxTransformScale));
const AZ::Transform scaleTransform = AZ::Transform::CreateScale(scale);
if (action.m_modifiers.Alt())
@@ -417,6 +417,8 @@ set(FILES
UI/PropertyEditor/GrowTextEdit.cpp
UI/PropertyEditor/MultiLineTextEditHandler.h
UI/PropertyEditor/MultiLineTextEditHandler.cpp
UI/PropertyEditor/ThumbnailDropDown.h
UI/PropertyEditor/ThumbnailDropDown.cpp
UI/Slice/SlicePushWidget.cpp
UI/Slice/SlicePushWidget.hxx
UI/Slice/SliceOverridesNotificationWindow.cpp
@@ -647,6 +649,15 @@ set(FILES
Prefab/Instance/TemplateInstanceMapperInterface.h
Prefab/Link/Link.h
Prefab/Link/Link.cpp
Prefab/PrefabPublicHandler.h
Prefab/PrefabPublicHandler.cpp
Prefab/PrefabPublicInterface.h
Prefab/PrefabUndo.h
Prefab/PrefabUndo.cpp
Prefab/PrefabUndoCache.cpp
Prefab/PrefabUndoCache.h
Prefab/PrefabUndoHelpers.cpp
Prefab/PrefabUndoHelpers.h
Prefab/Spawnable/ComponentRequirementsValidator.h
Prefab/Spawnable/ComponentRequirementsValidator.cpp
Prefab/Spawnable/EditorInfoRemover.h
@@ -672,13 +683,6 @@ set(FILES
Prefab/Spawnable/SpawnableUtils.cpp
Prefab/Template/Template.h
Prefab/Template/Template.cpp
Prefab/PrefabUndo.h
Prefab/PrefabUndo.cpp
Prefab/PrefabUndoCache.cpp
Prefab/PrefabUndoCache.h
Prefab/PrefabPublicHandler.h
Prefab/PrefabPublicHandler.cpp
Prefab/PrefabPublicInterface.h
UI/Outliner/EntityOutlinerDisplayOptionsMenu.h
UI/Outliner/EntityOutlinerDisplayOptionsMenu.cpp
UI/Outliner/EntityOutlinerTreeView.hxx
@@ -703,6 +707,8 @@ set(FILES
UI/EditorEntityUi/EditorEntityUiSystemComponent.cpp
UI/Layer/LayerUiHandler.h
UI/Layer/LayerUiHandler.cpp
UI/Prefab/LevelRootUiHandler.h
UI/Prefab/LevelRootUiHandler.cpp
UI/Prefab/PrefabEditInterface.h
UI/Prefab/PrefabEditManager.h
UI/Prefab/PrefabEditManager.cpp
@@ -196,8 +196,7 @@ namespace UnitTest
fileIO->Remove(s_catalogFile);
}
int platformCount = 0;
for (auto thisPlatform : m_testPlatforms)
for (size_t platformCount = 0; platformCount < s_totalTestPlatforms; ++platformCount)
{
// Deleting all the temporary files
for (int idx = 0; idx < s_totalAssets; idx++)
@@ -208,7 +207,6 @@ namespace UnitTest
fileIO->Remove(m_assetsPathFull[platformCount][idx].c_str());
}
}
++platformCount;
}
if (fileIO->Exists(TestSliceAssetPath))
@@ -448,7 +448,7 @@ namespace UnitTest
entity->Deactivate();
// Add placeholder component which implements component mode.
const AZ::Component* placeholder1 = entity->CreateComponent<OverrideMouseInteractionComponent>();
entity->CreateComponent<OverrideMouseInteractionComponent>();
entity->Activate();
@@ -75,7 +75,7 @@ namespace UnitTest
EntityAlias entityAlias = entityAliasRef.value();
//update template
ASSERT_TRUE(m_instanceToTemplateInterface->PatchEntityInTemplate(patch, entityAlias, templateId));
ASSERT_TRUE(m_instanceToTemplateInterface->PatchEntityInTemplate(patch, entityId));
//undo change
instanceEntityUndo.Undo();
@@ -200,7 +200,6 @@ namespace UnitTest
PrefabTestComponent* prefabTestComponent = aznew PrefabTestComponent(true);
entity->Deactivate();
entity->AddComponent(prefabTestComponent);
auto expectedComponentId = prefabTestComponent->GetId();
PrefabDom updatedDom;
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*newInstance, updatedDom));
newTemplateDom.CopyFrom(updatedDom, newTemplateDom.GetAllocator());
@@ -136,7 +136,6 @@ namespace UnitTest
builder.Add("RandomKey", this->GetValue());
AzFramework::SpawnableMetaData metaData(builder.BuildMetaData());
GetType stored{};
EXPECT_EQ(this->GetValueType(), metaData.GetType("RandomKey"));
}
@@ -570,7 +570,7 @@ namespace UnitTest
TestComponentD_V1::Reflect(m_serializeContext.get());
AZ::Entity* entity = aznew AZ::Entity();
TestComponentD_V1* component = entity->CreateComponent<TestComponentD_V1>();
entity->CreateComponent<TestComponentD_V1>();
// Supply a specific Asset Guid to help with debugging
AZ::Data::AssetId sliceAssetId = SaveAsSlice(entity, "{10000000-0000-0000-0000-000000000000}", "datapatch_base.slice");
entity = nullptr;
@@ -149,7 +149,6 @@ namespace UnitTest
});
auto clusterEntry = m_viewportManagerWrapper.GetViewportManager()->GetClusterMap().find(clusterId);
auto button = clusterEntry->second->GetButton(buttonId);
// trigger the cluster
m_viewportManagerWrapper.GetViewportManager()->RegisterClusterEventHandler(clusterId, handler);