Merge branch 'development' of https://github.com/o3de/o3de into feat/add-cursor-wrap-mode-viewport
This commit is contained in:
+5
@@ -68,6 +68,11 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<const StringFilter> AssetBrowserFilterModel::GetStringFilter() const
|
||||
{
|
||||
return m_stringFilter;
|
||||
}
|
||||
|
||||
bool AssetBrowserFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
//get the source idx, if invalid early out
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ namespace AzToolsFramework
|
||||
// AssetBrowserComponentNotificationBus
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void OnAssetBrowserComponentReady() override;
|
||||
|
||||
QSharedPointer<const StringFilter> GetStringFilter() const;
|
||||
Q_SIGNALS:
|
||||
void filterChanged();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -70,7 +70,7 @@ namespace AzToolsFramework
|
||||
//Asset source name match filter
|
||||
FilterConstType m_filter;
|
||||
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...'
|
||||
QWeakPointer<const StringFilter> m_stringFilter;
|
||||
QSharedPointer<const StringFilter> m_stringFilter;
|
||||
QWeakPointer<const CompositeFilter> m_assetTypeFilter;
|
||||
QCollator m_collator; // cache the collator as its somewhat expensive to constantly create and destroy one.
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/ProductAssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
|
||||
|
||||
#include <QMimeData>
|
||||
AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 'QRegularExpression::d': class 'QExplicitlySharedDataPointer<QRegularExpressionPrivate>' needs to have dll-interface to be used by clients of class 'QRegularExpression'
|
||||
@@ -268,6 +269,21 @@ namespace AzToolsFramework
|
||||
m_rootEntry = rootEntry;
|
||||
}
|
||||
|
||||
AssetBrowserFilterModel* AssetBrowserModel::GetFilterModel()
|
||||
{
|
||||
return m_filterModel;
|
||||
}
|
||||
|
||||
const AssetBrowserFilterModel* AssetBrowserModel::GetFilterModel() const
|
||||
{
|
||||
return m_filterModel;
|
||||
}
|
||||
|
||||
void AssetBrowser::AssetBrowserModel::SetFilterModel(AssetBrowserFilterModel* filterModel)
|
||||
{
|
||||
m_filterModel = filterModel;
|
||||
}
|
||||
|
||||
QModelIndex AssetBrowserModel::parent(const QModelIndex& child) const
|
||||
{
|
||||
if (!child.isValid())
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace AzToolsFramework
|
||||
class AssetBrowserEntry;
|
||||
class RootAssetBrowserEntry;
|
||||
class AssetEntryChangeset;
|
||||
class AssetBrowserFilterModel;
|
||||
|
||||
class AssetBrowserModel
|
||||
: public QAbstractItemModel
|
||||
@@ -75,7 +76,7 @@ namespace AzToolsFramework
|
||||
void EndAddEntry(AssetBrowserEntry* parent) override;
|
||||
void BeginRemoveEntry(AssetBrowserEntry* entry) override;
|
||||
void EndRemoveEntry() override;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// TickBus
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -84,10 +85,16 @@ namespace AzToolsFramework
|
||||
AZStd::shared_ptr<RootAssetBrowserEntry> GetRootEntry() const;
|
||||
void SetRootEntry(AZStd::shared_ptr<RootAssetBrowserEntry> rootEntry);
|
||||
|
||||
AssetBrowserFilterModel* GetFilterModel();
|
||||
const AssetBrowserFilterModel* GetFilterModel() const;
|
||||
void SetFilterModel(AssetBrowserFilterModel* filterModel);
|
||||
|
||||
static void SourceIndexesToAssetIds(const QModelIndexList& indexes, AZStd::vector<AZ::Data::AssetId>& assetIds);
|
||||
static void SourceIndexesToAssetDatabaseEntries(const QModelIndexList& indexes, AZStd::vector<AssetBrowserEntry*>& entries);
|
||||
|
||||
private:
|
||||
//Non owning pointer
|
||||
AssetBrowserFilterModel* m_filterModel = nullptr;
|
||||
AZStd::shared_ptr<RootAssetBrowserEntry> m_rootEntry;
|
||||
bool m_loaded;
|
||||
bool m_addingEntry;
|
||||
|
||||
-1
@@ -43,7 +43,6 @@ namespace AzToolsFramework
|
||||
{
|
||||
friend class AssetBrowserModel;
|
||||
friend class AssetBrowserFilterModel;
|
||||
friend class AssetBrowserEntry;
|
||||
friend class RootAssetBrowserEntry;
|
||||
friend class FolderAssetBrowserEntry;
|
||||
friend class SourceAssetBrowserEntry;
|
||||
|
||||
@@ -229,6 +229,11 @@ namespace AzToolsFramework
|
||||
Q_EMIT updatedSignal();
|
||||
}
|
||||
|
||||
QString StringFilter::GetFilterString() const
|
||||
{
|
||||
return m_filterString;
|
||||
}
|
||||
|
||||
QString StringFilter::GetNameInternal() const
|
||||
{
|
||||
return m_filterString;
|
||||
|
||||
@@ -106,6 +106,7 @@ namespace AzToolsFramework
|
||||
~StringFilter() override = default;
|
||||
|
||||
void SetFilterString(const QString& filterString);
|
||||
QString GetFilterString() const;
|
||||
|
||||
protected:
|
||||
QString GetNameInternal() const override;
|
||||
|
||||
+1
@@ -66,6 +66,7 @@ namespace AzToolsFramework
|
||||
m_tableModel = qobject_cast<AssetBrowserTableModel*>(model);
|
||||
AZ_Assert(m_tableModel, "Expecting AssetBrowserTableModel");
|
||||
m_sourceFilterModel = qobject_cast<AssetBrowserFilterModel*>(m_tableModel->sourceModel());
|
||||
m_delegate->Init();
|
||||
AzQtComponents::TableView::setModel(model);
|
||||
connect(m_tableModel, &AssetBrowserTableModel::layoutChanged, this, &AssetBrowserTableView::layoutChangedSlot);
|
||||
|
||||
|
||||
+9
-2
@@ -230,7 +230,10 @@ namespace AzToolsFramework
|
||||
{
|
||||
QModelIndex curIndex = selectedIndexes[0];
|
||||
m_expandToEntriesByDefault = true;
|
||||
m_treeStateSaver->ApplySnapshot();
|
||||
if (m_treeStateSaver)
|
||||
{
|
||||
m_treeStateSaver->ApplySnapshot();
|
||||
}
|
||||
|
||||
setCurrentIndex(curIndex);
|
||||
scrollTo(curIndex);
|
||||
@@ -240,8 +243,12 @@ namespace AzToolsFramework
|
||||
|
||||
// Flag our default expansion state so that we expand down to source entries after filtering
|
||||
m_expandToEntriesByDefault = hasFilter;
|
||||
|
||||
// Then ask our state saver to apply its current snapshot again, falling back on asking us if entries should be expanded or not
|
||||
m_treeStateSaver->ApplySnapshot();
|
||||
if (m_treeStateSaver)
|
||||
{
|
||||
m_treeStateSaver->ApplySnapshot();
|
||||
}
|
||||
|
||||
// If we're filtering for a valid entry, select the first valid entry
|
||||
if (hasFilter && selectFirstValidEntry)
|
||||
|
||||
+24
-4
@@ -9,12 +9,16 @@
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Views/EntryDelegate.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzQtComponents/Components/StyledBusyLabel.h>
|
||||
#include <AzToolsFramework/Editor/RichTextHighlighter.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTextDocument>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // 4251: class 'QScopedPointer<QBrushData,QBrushDataPointerDeleter>' needs to have dll-interface to be used by clients of class 'QBrush'
|
||||
// 4800: 'uint': forcing value to bool 'true' or 'false' (performance warning)
|
||||
#include <QAbstractItemView>
|
||||
@@ -160,13 +164,20 @@ namespace AzToolsFramework
|
||||
LoadBranchPixMaps();
|
||||
}
|
||||
|
||||
void SearchEntryDelegate::Init()
|
||||
{
|
||||
AssetBrowserModel* assetBrowserModel;
|
||||
AssetBrowserComponentRequestBus::BroadcastResult(assetBrowserModel, &AssetBrowserComponentRequests::GetAssetBrowserModel);
|
||||
AZ_Assert(assetBrowserModel, "Failed to get filebrowser model");
|
||||
m_assetBrowserFilerModel = assetBrowserModel->GetFilterModel();
|
||||
}
|
||||
|
||||
void SearchEntryDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
auto data = index.data(AssetBrowserModel::Roles::EntryRole);
|
||||
if (data.canConvert<const AssetBrowserEntry*>())
|
||||
{
|
||||
bool isEnabled = (option.state & QStyle::State_Enabled) != 0;
|
||||
bool isSelected = (option.state & QStyle::State_Selected) != 0;
|
||||
|
||||
QStyle* style = option.widget ? option.widget->style() : QApplication::style();
|
||||
|
||||
@@ -265,13 +276,22 @@ namespace AzToolsFramework
|
||||
remainingRect.adjust(thumbX, 0, 0, 0); // bump it to the right by the size of the thumbnail
|
||||
remainingRect.adjust(EntrySpacingLeftPixels, 0, 0, 0); // bump it to the right by the spacing.
|
||||
}
|
||||
|
||||
QString displayString = index.column() == aznumeric_cast<int>(AssetBrowserEntry::Column::Name)
|
||||
? qvariant_cast<QString>(entry->data(aznumeric_cast<int>(AssetBrowserEntry::Column::Name)))
|
||||
: qvariant_cast<QString>(entry->data(aznumeric_cast<int>(AssetBrowserEntry::Column::Path)));
|
||||
|
||||
style->drawItemText(
|
||||
painter, remainingRect, option.displayAlignment, actualPalette, isEnabled, displayString,
|
||||
isSelected ? QPalette::HighlightedText : QPalette::Text);
|
||||
QStyleOptionViewItem optionV4{ option };
|
||||
initStyleOption(&optionV4, index);
|
||||
optionV4.state &= ~(QStyle::State_HasFocus | QStyle::State_Selected);
|
||||
|
||||
if (m_assetBrowserFilerModel && m_assetBrowserFilerModel->GetStringFilter()
|
||||
&& !m_assetBrowserFilerModel->GetStringFilter()->GetFilterString().isEmpty())
|
||||
{
|
||||
displayString = RichTextHighlighter::HighlightText(displayString, m_assetBrowserFilerModel->GetStringFilter()->GetFilterString());
|
||||
}
|
||||
|
||||
RichTextHighlighter::PaintHighlightedRichText(displayString, painter, optionV4, remainingRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace AzToolsFramework
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SearchEntryDelegate(QWidget* parent = nullptr);
|
||||
|
||||
void Init();
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
|
||||
private:
|
||||
@@ -78,6 +78,7 @@ namespace AzToolsFramework
|
||||
void DrawBranchPixMap(EntryBranchType branchType, QPainter* painter, const QPoint& point, const QSize& size) const;
|
||||
|
||||
private:
|
||||
AssetBrowserFilterModel* m_assetBrowserFilerModel;
|
||||
QMap<EntryBranchType, QPixmap> m_branchIcons;
|
||||
};
|
||||
} // namespace AssetBrowser
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "RichTextHighlighter.h"
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
|
||||
QString RichTextHighlighter::HighlightText(const QString& displayString, const QString& matchingSubstring)
|
||||
{
|
||||
QString highlightedString = displayString;
|
||||
int highlightTextIndex = 0;
|
||||
do
|
||||
{
|
||||
highlightTextIndex = highlightedString.lastIndexOf(matchingSubstring, highlightTextIndex - 1, Qt::CaseInsensitive);
|
||||
if (highlightTextIndex >= 0)
|
||||
{
|
||||
const QString backgroundColor{ "#707070" };
|
||||
highlightedString.insert(static_cast<int>(highlightTextIndex + matchingSubstring.length()), "</span>");
|
||||
highlightedString.insert(highlightTextIndex, "<span style=\"background-color: " + backgroundColor + "\">");
|
||||
}
|
||||
} while (highlightTextIndex > 0);
|
||||
|
||||
return highlightedString;
|
||||
}
|
||||
|
||||
void RichTextHighlighter::PaintHighlightedRichText(const QString& highlightedString,QPainter* painter, QStyleOptionViewItem option, QRect availableRect, QPoint offset /* = QPoint()*/)
|
||||
{
|
||||
// Now we setup a Text Document so it can draw the rich text
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
QTextDocument textDoc;
|
||||
textDoc.setDefaultFont(option.font);
|
||||
if (option.state & QStyle::State_Enabled)
|
||||
{
|
||||
textDoc.setDefaultStyleSheet("body {color: white}");
|
||||
}
|
||||
else
|
||||
{
|
||||
textDoc.setDefaultStyleSheet("body {color: #7C7C7C}");
|
||||
}
|
||||
textDoc.setHtml("<body>" + highlightedString + "</body>");
|
||||
painter->translate(availableRect.topLeft() + offset);
|
||||
textDoc.setTextWidth(availableRect.width());
|
||||
textDoc.drawContents(painter, QRectF(0, 0, availableRect.width(), availableRect.height()));
|
||||
painter->restore();
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/base.h>
|
||||
#include <QString>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QTextDocument>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800,"-Wunknown-warning-option") // 4251: class 'QScopedPointer<QBrushData,QBrushDataPointerDeleter>' needs to have dll-interface to be used
|
||||
// by clients of class 'QBrush' 4800: 'uint': forcing value to bool 'true' or 'false' (performance warning)
|
||||
#include <QPainter>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! @class RichTextHighlighter
|
||||
//! @brief Highlights a given string given a matching substring.
|
||||
class RichTextHighlighter
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(RichTextHighlighter, AZ::SystemAllocator, 0);
|
||||
RichTextHighlighter() = delete;
|
||||
|
||||
static QString HighlightText(const QString& displayString, const QString& matchingSubstring);
|
||||
static void PaintHighlightedRichText(const QString& highlightedString,QPainter* painter, QStyleOptionViewItem option,
|
||||
QRect availableRect, QPoint offset = QPoint());
|
||||
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
@@ -201,11 +201,8 @@ namespace AzToolsFramework
|
||||
//! Fired after the EditorEntityContext fails to export the root level slice to the game stream
|
||||
virtual void OnSaveStreamForGameFailure(AZStd::string_view /*failureString*/) {}
|
||||
|
||||
//! Fired when the user triggers a clone of ComponentEntity object(s), before operation begins
|
||||
virtual void OnEntitiesAboutToBeCloned() {}
|
||||
|
||||
//! Fires when the user triggers a clone of ComponentEntity object(s)), after operation completes
|
||||
virtual void OnEntitiesCloned() {}
|
||||
//! Preserve entity order when re-parenting entities
|
||||
virtual void SetForceAddEntitiesToBackFlag(bool /*forceAddToBack*/) {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
+18
-2
@@ -226,7 +226,15 @@ namespace AzToolsFramework
|
||||
AZ::EntityId EditorEntityContextComponent::CreateNewEditorEntity(const char* name)
|
||||
{
|
||||
AZ::Entity* entity = CreateEntity(name);
|
||||
FinalizeEditorEntity(entity);
|
||||
AZ_Assert(entity != nullptr, "Entity with name %s couldn't be created.", name);
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
FinalizeEditorEntity(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
|
||||
}
|
||||
return entity->GetId();
|
||||
}
|
||||
|
||||
@@ -253,8 +261,16 @@ namespace AzToolsFramework
|
||||
return AZ::EntityId();
|
||||
}
|
||||
entity = aznew AZ::Entity(entityId, name);
|
||||
AZ_Assert(entity != nullptr, "Entity with name %s couldn't be created.", name);
|
||||
AddEntity(entity);
|
||||
FinalizeEditorEntity(entity);
|
||||
if (m_isLegacySliceService)
|
||||
{
|
||||
FinalizeEditorEntity(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEditorEntityCreated, entity->GetId());
|
||||
}
|
||||
|
||||
return entity->GetId();
|
||||
}
|
||||
|
||||
@@ -1157,7 +1157,7 @@ namespace AzToolsFramework
|
||||
|
||||
bool CloneInstantiatedEntities(const EntityIdSet& entitiesToClone, EntityIdSet& clonedEntities)
|
||||
{
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEntitiesAboutToBeCloned);
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::SetForceAddEntitiesToBackFlag, true);
|
||||
ScopedUndoBatch undoBatch("Clone Selection");
|
||||
|
||||
// Track the mapping of source to cloned entity. This both helps make sure that an entity is not accidentally
|
||||
@@ -1199,7 +1199,7 @@ namespace AzToolsFramework
|
||||
// Also replace the selection with the entities that have been cloned.
|
||||
Internal::UpdateUndoStackAndSelectClonedEntities(allEntityClonesContainer.m_entities, undoBatch);
|
||||
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnEntitiesCloned);
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::SetForceAddEntitiesToBackFlag, false);
|
||||
|
||||
for (const AZ::Entity* entity : allEntityClonesContainer.m_entities)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return entity->FindComponent<ComponentType>();
|
||||
return entity->template FindComponent<ComponentType>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -643,14 +643,9 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
void EditorEntityModel::OnEntitiesAboutToBeCloned()
|
||||
void EditorEntityModel::SetForceAddEntitiesToBackFlag(bool forceAddToBack)
|
||||
{
|
||||
m_forceAddToBack = true;
|
||||
}
|
||||
|
||||
void EditorEntityModel::OnEntitiesCloned()
|
||||
{
|
||||
m_forceAddToBack = false;
|
||||
m_forceAddToBack = forceAddToBack;
|
||||
}
|
||||
|
||||
void EditorEntityModel::ChildEntityOrderArrayUpdated()
|
||||
|
||||
@@ -94,9 +94,7 @@ namespace AzToolsFramework
|
||||
void OnEntityStreamLoadBegin() override;
|
||||
void OnEntityStreamLoadSuccess() override;
|
||||
void OnEntityStreamLoadFailed() override;
|
||||
void OnEntitiesAboutToBeCloned() override;
|
||||
void OnEntitiesCloned() override;
|
||||
|
||||
void SetForceAddEntitiesToBackFlag(bool forceAddToBack) override;
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// AzFramework::EntityContextEventBus::Handler
|
||||
|
||||
+6
-2
@@ -349,8 +349,12 @@ namespace AzToolsFramework
|
||||
instanceToParentUnder = *m_rootInstance;
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<Prefab::Instance> instantiatedPrefabInstance =
|
||||
m_prefabSystemComponent->InstantiatePrefab(filePath, instanceToParentUnder);
|
||||
AZStd::unique_ptr<Prefab::Instance> instantiatedPrefabInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
filePath, instanceToParentUnder,
|
||||
[this](const EntityList& entities)
|
||||
{
|
||||
HandleEntitiesAdded(entities);
|
||||
});
|
||||
|
||||
if (instantiatedPrefabInstance)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/JSON/writer.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <AzCore/Utils/TypeHash.h>
|
||||
#include <AzCore/std/sort.h>
|
||||
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/ContainerEntity/ContainerEntityInterface.h>
|
||||
@@ -83,6 +84,20 @@ namespace AzToolsFramework
|
||||
return AZ::Failure(findCommonRootOutcome.TakeError());
|
||||
}
|
||||
|
||||
// order entities by their respective position within Entity Outliner
|
||||
EditorEntitySortRequestBus::Event(
|
||||
commonRootEntityId,
|
||||
[&topLevelEntities](EditorEntitySortRequestBus::Events* sortRequests)
|
||||
{
|
||||
AZStd::sort(
|
||||
topLevelEntities.begin(), topLevelEntities.end(),
|
||||
[&sortRequests](AZ::Entity* entity1, AZ::Entity* entity2)
|
||||
{
|
||||
return sortRequests->GetChildEntityIndex(entity1->GetId()) <
|
||||
sortRequests->GetChildEntityIndex(entity2->GetId());
|
||||
});
|
||||
});
|
||||
|
||||
AZ::EntityId containerEntityId;
|
||||
|
||||
InstanceOptionalReference instanceToCreate;
|
||||
@@ -153,8 +168,6 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
// Create the Prefab
|
||||
AZ_Assert(filePath.IsAbsolute(), "CreatePrefabInMemory requires an absolute file path.");
|
||||
|
||||
instanceToCreate = prefabEditorEntityOwnershipInterface->CreatePrefab(
|
||||
entities, AZStd::move(instancePtrs), m_prefabLoaderInterface->GenerateRelativePath(filePath),
|
||||
commonRootEntityOwningInstance);
|
||||
@@ -172,6 +185,7 @@ namespace AzToolsFramework
|
||||
|
||||
// Parent the non-container top level entities to the container entity.
|
||||
// Parenting the top level container entities will be done during the creation of links.
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::SetForceAddEntitiesToBackFlag, true);
|
||||
for (AZ::Entity* topLevelEntity : topLevelEntities)
|
||||
{
|
||||
if (!IsInstanceContainerEntity(topLevelEntity->GetId()))
|
||||
@@ -179,6 +193,7 @@ namespace AzToolsFramework
|
||||
AZ::TransformBus::Event(topLevelEntity->GetId(), &AZ::TransformBus::Events::SetParent, containerEntityId);
|
||||
}
|
||||
}
|
||||
EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::SetForceAddEntitiesToBackFlag, false);
|
||||
|
||||
// Update the template of the instance since the entities are modified since the template creation.
|
||||
Prefab::PrefabDom serializedInstance;
|
||||
@@ -279,6 +294,8 @@ namespace AzToolsFramework
|
||||
|
||||
CreatePrefabResult PrefabPublicHandler::CreatePrefabInDisk(const EntityIdList& entityIds, AZ::IO::PathView filePath)
|
||||
{
|
||||
AZ_Assert(filePath.IsAbsolute(), "CreatePrefabInDisk requires an absolute file path.");
|
||||
|
||||
auto result = CreatePrefabInMemory(entityIds, filePath);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(
|
||||
AZ::IO::PathView filePath, InstanceOptionalReference parent)
|
||||
AZ::IO::PathView filePath, InstanceOptionalReference parent, const InstantiatedEntitiesCallback& instantiatedEntitiesCallback)
|
||||
{
|
||||
// Retrieve the template id for the source prefab filepath
|
||||
Prefab::TemplateId templateId = GetTemplateIdFromFilePath(filePath);
|
||||
@@ -297,11 +297,11 @@ namespace AzToolsFramework
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return InstantiatePrefab(templateId, parent);
|
||||
return InstantiatePrefab(templateId, parent, instantiatedEntitiesCallback);
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(
|
||||
TemplateId templateId, InstanceOptionalReference parent)
|
||||
TemplateId templateId, InstanceOptionalReference parent, const InstantiatedEntitiesCallback& instantiatedEntitiesCallback)
|
||||
{
|
||||
TemplateReference instantiatingTemplate = FindTemplate(templateId);
|
||||
|
||||
@@ -324,8 +324,10 @@ namespace AzToolsFramework
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, newEntities);
|
||||
if (instantiatedEntitiesCallback)
|
||||
{
|
||||
instantiatedEntitiesCallback(newEntities);
|
||||
}
|
||||
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
@@ -124,19 +124,25 @@ namespace AzToolsFramework
|
||||
* Generates a new Prefab Instance based on the Template whose source is stored in filepath.
|
||||
* @param filePath The path to the prefab source file containing the template being instantiated.
|
||||
* @param parent Reference of the target instance the instantiated instance will be placed under.
|
||||
* @param instantiatedEntitiesCallback An optional callback that can be used to modify the instantiated entities.
|
||||
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
|
||||
*/
|
||||
AZStd::unique_ptr<Instance> InstantiatePrefab(
|
||||
AZ::IO::PathView filePath, InstanceOptionalReference parent = AZStd::nullopt) override;
|
||||
AZ::IO::PathView filePath,
|
||||
InstanceOptionalReference parent = AZStd::nullopt,
|
||||
const InstantiatedEntitiesCallback& instantiatedEntitiesCallback = {}) override;
|
||||
|
||||
/**
|
||||
* Generates a new Prefab Instance based on the Template referenced by templateId.
|
||||
* @param templateId The id of the template being instantiated.
|
||||
* @param parent Reference of the target instance the instantiated instance will be placed under.
|
||||
* @param instantiatedEntitiesCallback An optional callback that can be used to modify the instantiated entities.
|
||||
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
|
||||
*/
|
||||
AZStd::unique_ptr<Instance> InstantiatePrefab(
|
||||
TemplateId templateId, InstanceOptionalReference parent = AZStd::nullopt) override;
|
||||
TemplateId templateId,
|
||||
InstanceOptionalReference parent = AZStd::nullopt,
|
||||
const InstantiatedEntitiesCallback& instantiatedEntitiesCallback = {}) override;
|
||||
|
||||
/**
|
||||
* Add a new Link into Prefab System Component and create a unique id for it.
|
||||
|
||||
+9
-2
@@ -27,6 +27,9 @@ namespace AzToolsFramework
|
||||
class PrefabSystemComponentInterface
|
||||
{
|
||||
public:
|
||||
|
||||
using InstantiatedEntitiesCallback = AZStd::function<void(AZStd::vector<AZ::Entity*>&)>;
|
||||
|
||||
AZ_RTTI(PrefabSystemComponentInterface, "{8E95A029-67F9-4F74-895F-DDBFE29516A0}");
|
||||
|
||||
virtual TemplateReference FindTemplate(TemplateId id) = 0;
|
||||
@@ -70,9 +73,13 @@ namespace AzToolsFramework
|
||||
virtual void PropagateTemplateChanges(TemplateId templateId, InstanceOptionalConstReference instanceToExclude = AZStd::nullopt) = 0;
|
||||
|
||||
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(
|
||||
AZ::IO::PathView filePath, InstanceOptionalReference parent = AZStd::nullopt) = 0;
|
||||
AZ::IO::PathView filePath,
|
||||
InstanceOptionalReference parent = AZStd::nullopt,
|
||||
const InstantiatedEntitiesCallback& instantiatedEntitiesCallback = {}) = 0;
|
||||
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(
|
||||
TemplateId templateId, InstanceOptionalReference parent = AZStd::nullopt) = 0;
|
||||
TemplateId templateId,
|
||||
InstanceOptionalReference parent = AZStd::nullopt,
|
||||
const InstantiatedEntitiesCallback& instantiatedEntitiesCallback = {}) = 0;
|
||||
virtual AZStd::unique_ptr<Instance> CreatePrefab(const AZStd::vector<AZ::Entity*>& entities,
|
||||
AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume, AZ::IO::PathView filePath,
|
||||
AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr, InstanceOptionalReference parent = AZStd::nullopt,
|
||||
|
||||
+1
@@ -64,6 +64,7 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
|
||||
AZStd::move(uniqueName), context.GetSourceUuid(), AZStd::move(serializer));
|
||||
AZ_Assert(spawnable, "Failed to create a new spawnable.");
|
||||
|
||||
object.GetReferencedAssets() = prefab.GetReferencedAssets();
|
||||
Instance& instance = prefab.GetInstance();
|
||||
// Resolve entity aliases that store PrefabDOM information to use the spawnable instead. This is done before the entities are
|
||||
// moved from the instance as they'd otherwise can't be found.
|
||||
|
||||
+11
-1
@@ -124,12 +124,22 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
|
||||
return *m_instance;
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& PrefabDocument::GetReferencedAssets()
|
||||
{
|
||||
return m_referencedAssets;
|
||||
}
|
||||
|
||||
const AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& PrefabDocument::GetReferencedAssets() const
|
||||
{
|
||||
return m_referencedAssets;
|
||||
}
|
||||
|
||||
bool PrefabDocument::ConstructInstanceFromPrefabDom(const PrefabDom& prefab)
|
||||
{
|
||||
using namespace AzToolsFramework::Prefab;
|
||||
|
||||
m_instance->Reset();
|
||||
if (PrefabDomUtils::LoadInstanceFromPrefabDom(*m_instance, prefab, PrefabDomUtils::LoadFlags::AssignRandomEntityId))
|
||||
if (PrefabDomUtils::LoadInstanceFromPrefabDom(*m_instance, prefab, m_referencedAssets, PrefabDomUtils::LoadFlags::AssignRandomEntityId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,12 +53,16 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
|
||||
AzToolsFramework::Prefab::Instance& GetInstance();
|
||||
const AzToolsFramework::Prefab::Instance& GetInstance() const;
|
||||
|
||||
AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& GetReferencedAssets();
|
||||
const AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>& GetReferencedAssets() const;
|
||||
|
||||
private:
|
||||
bool ConstructInstanceFromPrefabDom(const PrefabDom& prefab);
|
||||
|
||||
mutable PrefabDom m_dom;
|
||||
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> m_instance;
|
||||
AZStd::string m_name;
|
||||
AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>> m_referencedAssets;
|
||||
mutable bool m_isDirty{ false };
|
||||
};
|
||||
} // namespace AzToolsFramework::Prefab::PrefabConversionUtils
|
||||
|
||||
@@ -3460,7 +3460,7 @@ namespace AzToolsFramework
|
||||
static const AZ::u32 kPixelIndentationPerLevel = GetSliceHierarchyMenuIdentationPerLevel();
|
||||
|
||||
// Any asset that acts as a valid target for all selected slice-instance-owned entities can be shown.
|
||||
QMenu* quickPushMenu = quickPushMenu = new QMenu(parent);
|
||||
QMenu* quickPushMenu = new QMenu(parent);
|
||||
|
||||
bool setupMenu = false;
|
||||
if (pushableChangesAvailable)
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace AZStd
|
||||
};
|
||||
|
||||
template <>
|
||||
struct AZStd::equal_to<AzToolsFramework::Thumbnailer::SharedThumbnailKey>
|
||||
struct equal_to<AzToolsFramework::Thumbnailer::SharedThumbnailKey>
|
||||
{
|
||||
AZ_FORCE_INLINE bool operator()(const AzToolsFramework::Thumbnailer::SharedThumbnailKey& left, const AzToolsFramework::Thumbnailer::SharedThumbnailKey& right) const
|
||||
{
|
||||
|
||||
+4
-26
@@ -66,6 +66,7 @@
|
||||
#include <AzToolsFramework/UI/Outliner/EntityOutlinerTreeView.hxx>
|
||||
#include <AzToolsFramework/UI/Outliner/EntityOutlinerCacheBus.h>
|
||||
#include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
|
||||
#include <AzToolsFramework/Editor/RichTextHighlighter.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// EntityOutlinerListModel
|
||||
@@ -259,17 +260,7 @@ namespace AzToolsFramework
|
||||
if (s_paintingName && !m_filterString.empty())
|
||||
{
|
||||
// highlight characters in filter
|
||||
int highlightTextIndex = 0;
|
||||
do
|
||||
{
|
||||
highlightTextIndex = label.lastIndexOf(QString(m_filterString.c_str()), highlightTextIndex - 1, Qt::CaseInsensitive);
|
||||
if (highlightTextIndex >= 0)
|
||||
{
|
||||
const QString BACKGROUND_COLOR{ "#707070" };
|
||||
label.insert(highlightTextIndex + static_cast<int>(m_filterString.length()), "</span>");
|
||||
label.insert(highlightTextIndex, "<span style=\"background-color: " + BACKGROUND_COLOR + "\">");
|
||||
}
|
||||
} while(highlightTextIndex > 0);
|
||||
label = AzToolsFramework::RichTextHighlighter::HighlightText(label, m_filterString.c_str());
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@@ -2375,23 +2366,10 @@ namespace AzToolsFramework
|
||||
optionV4.text.clear();
|
||||
optionV4.widget->style()->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter);
|
||||
|
||||
// Now we setup a Text Document so it can draw the rich text
|
||||
QTextDocument textDoc;
|
||||
textDoc.setDefaultFont(optionV4.font);
|
||||
if (option.state & QStyle::State_Enabled)
|
||||
{
|
||||
textDoc.setDefaultStyleSheet("body {color: white}");
|
||||
}
|
||||
else
|
||||
{
|
||||
textDoc.setDefaultStyleSheet("body {color: #7C7C7C}");
|
||||
}
|
||||
textDoc.setHtml("<body>" + entityNameRichText + "</body>");
|
||||
painter->translate(textRect.topLeft());
|
||||
textDoc.setTextWidth(textRect.width());
|
||||
textDoc.drawContents(painter, QRectF(0, 0, textRect.width(), textRect.height()));
|
||||
AzToolsFramework::RichTextHighlighter::PaintHighlightedRichText(entityNameRichText, painter, optionV4, textRect);
|
||||
|
||||
painter->restore();
|
||||
|
||||
EntityOutlinerListModel::s_paintingName = false;
|
||||
}
|
||||
|
||||
|
||||
+12
-30
@@ -14,6 +14,7 @@
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyQTConstants.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/QtWidgetLimits.h>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QLocale>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -92,25 +93,11 @@ namespace AzToolsFramework
|
||||
{
|
||||
toolTipString += "\n";
|
||||
}
|
||||
toolTipString += "[";
|
||||
if (propertyControl->minimum() <= aznumeric_cast<AZ::s64>(QtWidgetLimits<T>::Min()))
|
||||
{
|
||||
toolTipString += "-" + QObject::tr(PropertyQTConstant_InfinityString);
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTipString += QString::number(propertyControl->minimum());
|
||||
}
|
||||
toolTipString += ", ";
|
||||
if (propertyControl->maximum() >= aznumeric_cast<AZ::s64>(QtWidgetLimits<T>::Max()))
|
||||
{
|
||||
toolTipString += QObject::tr(PropertyQTConstant_InfinityString);
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTipString += QString::number(propertyControl->maximum());
|
||||
}
|
||||
toolTipString += "]";
|
||||
|
||||
const QString minString = QLocale().toString(propertyControl->minimum());
|
||||
const QString maxString = QLocale().toString(propertyControl->maximum());
|
||||
toolTipString += QString("[%1, %2]").arg(minString).arg(maxString);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -128,16 +115,11 @@ namespace AzToolsFramework
|
||||
{
|
||||
toolTipString += "\n";
|
||||
}
|
||||
toolTipString += "[" + QString::number(propertyControl->minimum()) + ", ";
|
||||
if (propertyControl->maximum() >= aznumeric_cast<AZ::s64>(QtWidgetLimits<T>::Max()))
|
||||
{
|
||||
toolTipString += QObject::tr(PropertyQTConstant_InfinityString);
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTipString += QString::number(propertyControl->maximum());
|
||||
}
|
||||
toolTipString += "]";
|
||||
|
||||
const QString minString = QLocale().toString(propertyControl->minimum());
|
||||
const QString maxString = QLocale().toString(propertyControl->maximum());
|
||||
toolTipString += QString("[%1, %2]").arg(minString).arg(maxString);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -196,7 +178,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_WarningOnce("AzToolsFramework", false, "Property %s: 'Min' attribute from property '%s' into widget", debugName);
|
||||
AZ_WarningOnce("AzToolsFramework", false, "Failed to read 'Min' attribute from property '%s' into widget", debugName);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ::Edit::Attributes::Max)
|
||||
|
||||
@@ -123,6 +123,8 @@ set(FILES
|
||||
ContainerEntity/ContainerEntitySystemComponent.h
|
||||
Editor/EditorContextMenuBus.h
|
||||
Editor/EditorSettingsAPIBus.h
|
||||
Editor/RichTextHighlighter.h
|
||||
Editor/RichTextHighlighter.cpp
|
||||
Entity/EditorEntityStartStatus.h
|
||||
Entity/EditorEntityAPIBus.h
|
||||
Entity/EditorEntityContextComponent.cpp
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
@@ -170,7 +170,14 @@ namespace UnitTest
|
||||
m_instanceUpdateExecutorInterface->UpdateTemplateInstancesInQueue();
|
||||
|
||||
//instantiate a new nested instance
|
||||
nestedInstance = m_prefabSystemComponent->InstantiatePrefab(nestedTemplateId);
|
||||
nestedInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
nestedTemplateId, AZStd::nullopt,
|
||||
[](const AzToolsFramework::EntityList& entities)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, entities);
|
||||
});
|
||||
|
||||
nestedContainerEntityId = nestedInstance->GetContainerEntityId();
|
||||
AZ::ComponentApplicationBus::BroadcastResult(nestedContainerEntity, &AZ::ComponentApplicationBus::Events::FindEntity, nestedContainerEntityId);
|
||||
ASSERT_TRUE(nestedContainerEntity);
|
||||
@@ -198,7 +205,13 @@ namespace UnitTest
|
||||
|
||||
LinkId linkId = undoInstanceLinkNode.GetLinkId();
|
||||
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(rootTemplateId);
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
rootTemplateId, AZStd::nullopt,
|
||||
[](const AzToolsFramework::EntityList& entities)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, entities);
|
||||
});
|
||||
aliases = rootInstance->GetNestedInstanceAliases(nestedTemplateId);
|
||||
|
||||
//verify the link was created
|
||||
@@ -228,7 +241,13 @@ namespace UnitTest
|
||||
m_instanceUpdateExecutorInterface->UpdateTemplateInstancesInQueue();
|
||||
|
||||
//verify the update worked
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(rootTemplateId);
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
rootTemplateId, AZStd::nullopt,
|
||||
[](const AzToolsFramework::EntityList& entities)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, entities);
|
||||
});
|
||||
aliases = rootInstance->GetNestedInstanceAliases(nestedTemplateId);
|
||||
nestedInstanceRef = rootInstance->FindNestedInstance(aliases[0]);
|
||||
nestedContainerEntityId = nestedInstanceRef->get().GetContainerEntityId();
|
||||
@@ -244,7 +263,13 @@ namespace UnitTest
|
||||
m_instanceUpdateExecutorInterface->UpdateTemplateInstancesInQueue();
|
||||
|
||||
//verify the undo update worked
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(rootTemplateId);
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
rootTemplateId, AZStd::nullopt,
|
||||
[](const AzToolsFramework::EntityList& entities)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, entities);
|
||||
});
|
||||
aliases = rootInstance->GetNestedInstanceAliases(nestedTemplateId);
|
||||
nestedInstanceRef = rootInstance->FindNestedInstance(aliases[0]);
|
||||
nestedContainerEntityId = nestedInstanceRef->get().GetContainerEntityId();
|
||||
@@ -259,7 +284,13 @@ namespace UnitTest
|
||||
undoLinkUpdateNode.Redo();
|
||||
m_instanceUpdateExecutorInterface->UpdateTemplateInstancesInQueue();
|
||||
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(rootTemplateId);
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
rootTemplateId, AZStd::nullopt,
|
||||
[](const AzToolsFramework::EntityList& entities)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, entities);
|
||||
});
|
||||
aliases = rootInstance->GetNestedInstanceAliases(nestedTemplateId);
|
||||
nestedInstanceRef = rootInstance->FindNestedInstance(aliases[0]);
|
||||
nestedContainerEntityId = nestedInstanceRef->get().GetContainerEntityId();
|
||||
@@ -287,7 +318,13 @@ namespace UnitTest
|
||||
m_instanceUpdateExecutorInterface->UpdateTemplateInstancesInQueue();
|
||||
|
||||
//verify the update worked
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(rootTemplateId);
|
||||
rootInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
rootTemplateId, AZStd::nullopt,
|
||||
[](const AzToolsFramework::EntityList& entities)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, entities);
|
||||
});
|
||||
aliases = rootInstance->GetNestedInstanceAliases(nestedTemplateId);
|
||||
nestedInstanceRef = rootInstance->FindNestedInstance(aliases[0]);
|
||||
nestedContainerEntityId = nestedInstanceRef->get().GetContainerEntityId();
|
||||
|
||||
@@ -79,7 +79,14 @@ namespace UnitTest
|
||||
|
||||
// verify template updated correctly
|
||||
//instantiate second instance for checking if propogation works
|
||||
AZStd::unique_ptr<Instance> secondInstance = m_prefabSystemComponent->InstantiatePrefab(templateId);
|
||||
AZStd::unique_ptr<Instance> secondInstance = m_prefabSystemComponent->InstantiatePrefab(
|
||||
templateId, AZStd::nullopt,
|
||||
[](const AzToolsFramework::EntityList& entities)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorEntityContextRequests::HandleEntitiesAdded, entities);
|
||||
});
|
||||
|
||||
ASSERT_TRUE(secondInstance);
|
||||
|
||||
ValidateInstanceEntitiesActive(*secondInstance);
|
||||
|
||||
@@ -83,18 +83,6 @@ namespace UnitTest
|
||||
widget->setMaximum(widget->maximum() - 1);
|
||||
}
|
||||
|
||||
static std::string GetToolTipStringAtLimits()
|
||||
{
|
||||
if constexpr (std::is_signed<ValueType>::value)
|
||||
{
|
||||
return "[-INF, INF]";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "[0, INF]";
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyCtrlHandlersCreated()
|
||||
{
|
||||
using ::testing::Ne;
|
||||
@@ -125,11 +113,13 @@ namespace UnitTest
|
||||
auto& widget = m_widget;
|
||||
auto& handler = m_handler;
|
||||
QString tooltip;
|
||||
std::string expected;
|
||||
|
||||
// Retrieve the tooltip string for this widget
|
||||
auto success = handler->ModifyTooltip(widget, tooltip);
|
||||
expected = GetToolTipStringAtLimits();
|
||||
|
||||
const QString minString = QLocale().toString(widget->minimum());
|
||||
const QString maxString = QLocale().toString(widget->maximum());
|
||||
const AZStd::string expected = AZStd::string::format("[%s, %s]", minString.toStdString().c_str(), maxString.toStdString().c_str());
|
||||
|
||||
// Expect the operation to be successful and a valid limit tooltip string generated
|
||||
EXPECT_TRUE(success);
|
||||
@@ -142,18 +132,21 @@ namespace UnitTest
|
||||
auto& widget = m_widget;
|
||||
auto& handler = m_handler;
|
||||
QString tooltip;
|
||||
std::stringstream expected;
|
||||
|
||||
// That is not at the extremeties of the type range limit
|
||||
SetWidgetRangeToNonExtremeties(widget);
|
||||
|
||||
// Retrieve the tooltip string for this widget
|
||||
auto success = handler->ModifyTooltip(widget, tooltip);
|
||||
expected << "[" << widget->minimum() << ", " << widget->maximum() << "]";
|
||||
|
||||
const QString minString = QLocale().toString(widget->minimum());
|
||||
const QString maxString = QLocale().toString(widget->maximum());
|
||||
|
||||
const AZStd::string expected = AZStd::string::format("[%s, %s]", minString.toStdString().c_str(), maxString.toStdString().c_str());
|
||||
|
||||
// Expect the operation to be successful and a valid less than limit tooltip string generated
|
||||
EXPECT_TRUE(success);
|
||||
EXPECT_STREQ(tooltip.toStdString().c_str(), expected.str().c_str());
|
||||
EXPECT_STREQ(tooltip.toStdString().c_str(), expected.c_str());
|
||||
}
|
||||
|
||||
void EmitWidgetValueChanged()
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace UnitTest
|
||||
QString testString = "0" + QString(testLocale.decimalPoint()) + "9999999";
|
||||
QString value = setupTruncationTest(testString);
|
||||
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "999";
|
||||
testString = "1" + QString(testLocale.decimalPoint()) + "0";
|
||||
EXPECT_TRUE(value == testString);
|
||||
}
|
||||
|
||||
@@ -295,19 +295,19 @@ namespace UnitTest
|
||||
QString testString = "0" + QString(testLocale.decimalPoint()) + "12395";
|
||||
QString value = setupTruncationTest(testString);
|
||||
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "123";
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "124";
|
||||
EXPECT_TRUE(value == testString);
|
||||
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "94496";
|
||||
value = setupTruncationTest(testString);
|
||||
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "944";
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "945";
|
||||
EXPECT_TRUE(value == testString);
|
||||
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "0009999";
|
||||
value = setupTruncationTest(testString);
|
||||
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "0";
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "001";
|
||||
EXPECT_TRUE(value == testString);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user