From b9dd7a1ecd34b9a9e8ce9204f299086fc6e79cc0 Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Thu, 17 Jun 2021 16:16:38 -0700 Subject: [PATCH 1/6] Updating IsNetEntityRole helper methods for more clarity. Also added tooltip scripting and comments for code --- .../Editor/Translation/scriptcanvas_en_us.ts | 19 ++++++++ .../Components/MultiplayerComponent.h | 8 ++-- .../Multiplayer/Components/NetBindComponent.h | 21 +++++++-- .../Components/MultiplayerComponent.cpp | 16 +++---- .../Components/MultiplayerController.cpp | 4 +- .../Source/Components/NetBindComponent.cpp | 43 ++++++++++--------- .../NetworkEntity/NetworkEntityManager.cpp | 2 +- 7 files changed, 74 insertions(+), 39 deletions(-) diff --git a/Assets/Editor/Translation/scriptcanvas_en_us.ts b/Assets/Editor/Translation/scriptcanvas_en_us.ts index a7d29e2dbc..5cafabaf60 100644 --- a/Assets/Editor/Translation/scriptcanvas_en_us.ts +++ b/Assets/Editor/Translation/scriptcanvas_en_us.ts @@ -14679,6 +14679,25 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro + + Method: NetBindComponent + + NETBINDCOMPONENT_ISNETENTITYROLEAUTHORITY_TOOLTIP + Returns true if this network entity is an authoritative proxy on a server (full authority); otherwise false. + + + NETBINDCOMPONENT_ISNETENTITYROLEAUTONOMOUS_TOOLTIP + Returns true if this network entity is an autonomous proxy on a client (can execute local prediction) or if this network entity is an authoritative proxy on a server but has autonomous privileges (ie: a host who is also a player); otherwise false. + + + NETBINDCOMPONENT_ISNETENTITYROLECLIENT_TOOLTIP + Returns true if this network entity is a simulated proxy on a client; otherwise false. + + + NETBINDCOMPONENT_ISNETENTITYROLESERVER_TOOLTIP + Returns true if this network entity is a simulated proxy on a server (ie: a different server may own this entity, but the entity has been replicated to this server; otherwise false. + + Method: Math diff --git a/Gems/Multiplayer/Code/Include/Multiplayer/Components/MultiplayerComponent.h b/Gems/Multiplayer/Code/Include/Multiplayer/Components/MultiplayerComponent.h index 19689171c5..9f2f9f4804 100644 --- a/Gems/Multiplayer/Code/Include/Multiplayer/Components/MultiplayerComponent.h +++ b/Gems/Multiplayer/Code/Include/Multiplayer/Components/MultiplayerComponent.h @@ -63,10 +63,10 @@ namespace Multiplayer //! @} NetEntityId GetNetEntityId() const; - bool IsAuthority() const; - bool IsAutonomous() const; - bool IsServer() const; - bool IsClient() const; + bool IsNetEntityRoleAuthority() const; + bool IsNetEntityRoleAutonomous() const; + bool IsNetEntityRoleServer() const; + bool IsNetEntityRoleClient() const; ConstNetworkEntityHandle GetEntityHandle() const; NetworkEntityHandle GetEntityHandle(); void MarkDirty(); diff --git a/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetBindComponent.h b/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetBindComponent.h index 7d9b7d4086..dd4b9588e4 100644 --- a/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetBindComponent.h +++ b/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetBindComponent.h @@ -64,10 +64,23 @@ namespace Multiplayer //! @} NetEntityRole GetNetEntityRole() const; - bool IsAuthority() const; - bool IsAutonomous() const; - bool IsServer() const; - bool IsClient() const; + + //! IsNetEntityRoleAuthority + //! @return true if this network entity is an authoritative proxy on a server (full authority); otherwise false. + bool IsNetEntityRoleAuthority() const; + + //! IsNetEntityRoleAutonomous + //! @return true if this network entity is an autonomous proxy on a client (can execute local prediction) or if this network entity is an authoritative proxy on a server but has autonomous privileges (ie: a host who is also a player); otherwise false. + bool IsNetEntityRoleAutonomous() const; + + //! IsNetEntityRoleServer + //! @return true if this network entity is a simulated proxy on a server (ie: a different server may have authority for this entity, but the entity has been replicated on this server; otherwise false. + bool IsNetEntityRoleServer() const; + + //! IsNetEntityRoleClient + //! @return true if this network entity is a simulated proxy on a client; otherwise false. + bool IsNetEntityRoleClient() const; + bool HasController() const; NetEntityId GetNetEntityId() const; const PrefabEntityId& GetPrefabEntityId() const; diff --git a/Gems/Multiplayer/Code/Source/Components/MultiplayerComponent.cpp b/Gems/Multiplayer/Code/Source/Components/MultiplayerComponent.cpp index 8542288b23..2ad883c7e7 100644 --- a/Gems/Multiplayer/Code/Source/Components/MultiplayerComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/MultiplayerComponent.cpp @@ -46,24 +46,24 @@ namespace Multiplayer return m_netBindComponent ? m_netBindComponent->GetNetEntityId() : InvalidNetEntityId; } - bool MultiplayerComponent::IsAuthority() const + bool MultiplayerComponent::IsNetEntityRoleAuthority() const { - return m_netBindComponent ? m_netBindComponent->IsAuthority() : false; + return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleAuthority() : false; } - bool MultiplayerComponent::IsAutonomous() const + bool MultiplayerComponent::IsNetEntityRoleAutonomous() const { - return m_netBindComponent ? m_netBindComponent->IsAutonomous() : false; + return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleAutonomous() : false; } - bool MultiplayerComponent::IsServer() const + bool MultiplayerComponent::IsNetEntityRoleServer() const { - return m_netBindComponent ? m_netBindComponent->IsServer() : false; + return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleServer() : false; } - bool MultiplayerComponent::IsClient() const + bool MultiplayerComponent::IsNetEntityRoleClient() const { - return m_netBindComponent ? m_netBindComponent->IsClient() : false; + return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleClient() : false; } ConstNetworkEntityHandle MultiplayerComponent::GetEntityHandle() const diff --git a/Gems/Multiplayer/Code/Source/Components/MultiplayerController.cpp b/Gems/Multiplayer/Code/Source/Components/MultiplayerController.cpp index b0bafccf79..071dfd4ee2 100644 --- a/Gems/Multiplayer/Code/Source/Components/MultiplayerController.cpp +++ b/Gems/Multiplayer/Code/Source/Components/MultiplayerController.cpp @@ -29,12 +29,12 @@ namespace Multiplayer bool MultiplayerController::IsAuthority() const { - return GetNetBindComponent() ? GetNetBindComponent()->IsAuthority() : false; + return GetNetBindComponent() ? GetNetBindComponent()->IsNetEntityRoleAuthority() : false; } bool MultiplayerController::IsAutonomous() const { - return GetNetBindComponent() ? GetNetBindComponent()->IsAutonomous() : false; + return GetNetBindComponent() ? GetNetBindComponent()->IsNetEntityRoleAutonomous() : false; } AZ::Entity* MultiplayerController::GetEntity() const diff --git a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp index 0847d42dd6..d5e83e5751 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp @@ -54,69 +54,72 @@ namespace Multiplayer ->Attribute(AZ::Script::Attributes::Module, "multiplayer") ->Attribute(AZ::Script::Attributes::Category, "Multiplayer") - ->Method("IsAuthority", [](AZ::EntityId id) -> bool { + ->Method("IsNetEntityRoleAuthority", [](AZ::EntityId id) -> bool { AZ::Entity* entity = AZ::Interface::Get()->FindEntity(id); if (!entity) { - AZ_Warning( "NetBindComponent", false, "NetBindComponent IsAuthority failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) + AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleAuthority failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) return false; } NetBindComponent* netBindComponent = entity-> FindComponent(); if (!netBindComponent) { - AZ_Warning( "NetBindComponent", false, "NetBindComponent IsAuthority failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) + AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleAuthority failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) return false; } - return netBindComponent->IsAuthority(); + return netBindComponent->IsNetEntityRoleAuthority(); }) - ->Method("IsAutonomous", [](AZ::EntityId id) -> bool { + + ->Method("IsNetEntityRoleAutonomous", [](AZ::EntityId id) -> bool { AZ::Entity* entity = AZ::Interface::Get()->FindEntity(id); if (!entity) { - AZ_Warning( "NetBindComponent", false, "NetBindComponent IsAutonomous failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) + AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleAutonomous failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) return false; } NetBindComponent* netBindComponent = entity->FindComponent(); if (!netBindComponent) { - AZ_Warning("NetBindComponent", false, "NetBindComponent IsAutonomous failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) + AZ_Warning("NetBindComponent", false, "NetBindComponent IsNetEntityRoleAutonomous failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) return false; } - return netBindComponent->IsAutonomous(); + return netBindComponent->IsNetEntityRoleAutonomous(); }) - ->Method("IsClient", [](AZ::EntityId id) -> bool { + + ->Method("IsNetEntityRoleClient", [](AZ::EntityId id) -> bool { AZ::Entity* entity = AZ::Interface::Get()->FindEntity(id); if (!entity) { - AZ_Warning( "NetBindComponent", false, "NetBindComponent IsClient failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) + AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleClient failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) return false; } NetBindComponent* netBindComponent = entity->FindComponent(); if (!netBindComponent) { - AZ_Warning("NetBindComponent", false, "NetBindComponent IsClient failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) + AZ_Warning("NetBindComponent", false, "NetBindComponent IsNetEntityRoleClient failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) return false; } - return netBindComponent->IsClient(); + return netBindComponent->IsNetEntityRoleClient(); }) - ->Method("IsServer", [](AZ::EntityId id) -> bool { + + ->Method("IsNetEntityRoleServer", [](AZ::EntityId id) -> bool { AZ::Entity* entity = AZ::Interface::Get()->FindEntity(id); if (!entity) { - AZ_Warning( "NetBindComponent", false, "NetBindComponent IsServer failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) + AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleServer failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) return false; } NetBindComponent* netBindComponent = entity->FindComponent(); if (!netBindComponent) { - AZ_Warning("NetBindComponent", false, "NetBindComponent IsServer failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) + AZ_Warning("NetBindComponent", false, "NetBindComponent IsNetEntityRoleServer failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) return false; } - return netBindComponent->IsServer(); + return netBindComponent->IsNetEntityRoleServer(); }) ; } @@ -179,23 +182,23 @@ namespace Multiplayer return m_netEntityRole; } - bool NetBindComponent::IsAuthority() const + bool NetBindComponent::IsNetEntityRoleAuthority() const { return (m_netEntityRole == NetEntityRole::Authority); } - bool NetBindComponent::IsAutonomous() const + bool NetBindComponent::IsNetEntityRoleAutonomous() const { return (m_netEntityRole == NetEntityRole::Autonomous) || (m_netEntityRole == NetEntityRole::Authority) && m_allowAutonomy; } - bool NetBindComponent::IsServer() const + bool NetBindComponent::IsNetEntityRoleServer() const { return (m_netEntityRole == NetEntityRole::Server); } - bool NetBindComponent::IsClient() const + bool NetBindComponent::IsNetEntityRoleClient() const { return (m_netEntityRole == NetEntityRole::Client); } diff --git a/Gems/Multiplayer/Code/Source/NetworkEntity/NetworkEntityManager.cpp b/Gems/Multiplayer/Code/Source/NetworkEntity/NetworkEntityManager.cpp index b0f1b221e8..3405abdc57 100644 --- a/Gems/Multiplayer/Code/Source/NetworkEntity/NetworkEntityManager.cpp +++ b/Gems/Multiplayer/Code/Source/NetworkEntity/NetworkEntityManager.cpp @@ -96,7 +96,7 @@ namespace Multiplayer { AZ_Assert(entityHandle.GetNetBindComponent(), "No NetBindComponent found on networked entity"); [[maybe_unused]] const bool isClientOnlyEntity = false;// (ServerIdFromEntityId(it->first) == InvalidHostId); - AZ_Assert(entityHandle.GetNetBindComponent()->IsAuthority() || isClientOnlyEntity, "Trying to delete a proxy entity, this will lead to issues deserializing entity updates"); + AZ_Assert(entityHandle.GetNetBindComponent()->IsNetEntityRoleAuthority() || isClientOnlyEntity, "Trying to delete a proxy entity, this will lead to issues deserializing entity updates"); } m_removeList.push_back(entityHandle.GetNetEntityId()); m_removeEntitiesEvent.Enqueue(AZ::TimeMs{ 0 }); From 526a0f128906741fc8bf188c53ff86370c728de9 Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Sun, 20 Jun 2021 20:51:59 -0700 Subject: [PATCH 2/6] Fix for Jenkins Validation: removing tabs and removing unwanted spaces. --- .../Code/Source/Components/NetBindComponent.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp index d5e83e5751..352bc92d1c 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp @@ -70,7 +70,7 @@ namespace Multiplayer } return netBindComponent->IsNetEntityRoleAuthority(); }) - + ->Method("IsNetEntityRoleAutonomous", [](AZ::EntityId id) -> bool { AZ::Entity* entity = AZ::Interface::Get()->FindEntity(id); if (!entity) @@ -87,7 +87,7 @@ namespace Multiplayer } return netBindComponent->IsNetEntityRoleAutonomous(); }) - + ->Method("IsNetEntityRoleClient", [](AZ::EntityId id) -> bool { AZ::Entity* entity = AZ::Interface::Get()->FindEntity(id); if (!entity) @@ -104,8 +104,8 @@ namespace Multiplayer } return netBindComponent->IsNetEntityRoleClient(); }) - - ->Method("IsNetEntityRoleServer", [](AZ::EntityId id) -> bool { + + ->Method("IsNetEntityRoleServer", [](AZ::EntityId id) -> bool { AZ::Entity* entity = AZ::Interface::Get()->FindEntity(id); if (!entity) { From 772a75b5bcd5e5af5949325f86942b36ba28cf14 Mon Sep 17 00:00:00 2001 From: greerdv Date: Mon, 21 Jun 2021 11:12:50 +0100 Subject: [PATCH 3/6] exposing non-uniform scale component id as a behavior constant for hydra --- .../ToolsComponents/EditorNonUniformScaleComponent.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp index f72de82f36..4cd18cbc91 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorNonUniformScaleComponent.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,13 @@ namespace AzToolsFramework ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly); } } + + if (auto behaviorContext = azrtti_cast(context)) + { + behaviorContext->ConstantProperty("EditorNonUniformScaleComponentTypeId", BehaviorConstant(EditorNonUniformScaleComponent::RTTI_Type())) + ->Attribute(AZ::Script::Attributes::Module, "editor") + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation); + } } void EditorNonUniformScaleComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent) From 5e4f021d556995389d2ac3b7ea676ebe7c1daa11 Mon Sep 17 00:00:00 2001 From: John Jones-Steele Date: Mon, 21 Jun 2021 15:28:41 +0100 Subject: [PATCH 4/6] Cherry picked from development --- .../AzQtComponents/Components/Style.cpp | 25 ++++++++++++++++++- .../Images/Notifications/link.svg | 4 +-- .../Private/Editor/UI/AWSCoreEditorMenu.h | 1 + .../Source/Editor/UI/AWSCoreEditorMenu.cpp | 16 ++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp index 0f58f06420..0d770d2d8e 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp @@ -493,7 +493,30 @@ namespace AzQtComponents } } break; - } + case CE_MenuItem: + { + const QMenu* menu = qobject_cast(widget); + QAction* action = menu->activeAction(); + if (action) + { + QMenu* subMenu = action->menu(); + if (subMenu) + { + QVariant noHover = subMenu->property("noHover"); + if (noHover.isValid() && noHover.toBool()) + { + // First draw as standard to get the correct hover background for the complete control. + QProxyStyle::drawControl(element, option, painter, widget); + // Now draw the icon as non-hovered so control behaves as designed. + QStyleOptionMenuItem myOpt = *qstyleoption_cast(option); + myOpt.state &= ~QStyle::State_Selected; + return QProxyStyle::drawControl(element, &myOpt, painter, widget); + } + } + } + } + break; + } return QProxyStyle::drawControl(element, option, painter, widget); } diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg b/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg index dfd21d157f..6f5608c092 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg +++ b/Code/Framework/AzQtComponents/AzQtComponents/Images/Notifications/link.svg @@ -1,4 +1,4 @@ - - + + diff --git a/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h b/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h index c892f86b66..ab03223323 100644 --- a/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h +++ b/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h @@ -46,6 +46,7 @@ namespace AWSCore void InitializeAWSDocActions(); void InitializeAWSGlobalDocsSubMenu(); void InitializeAWSFeatureGemActions(); + void AddSpaceForIcon(QMenu* menu); // AWSCoreEditorRequestBus interface implementation void SetAWSClientAuthEnabled() override; diff --git a/Gems/AWSCore/Code/Source/Editor/UI/AWSCoreEditorMenu.cpp b/Gems/AWSCore/Code/Source/Editor/UI/AWSCoreEditorMenu.cpp index c319788547..a592c7417a 100644 --- a/Gems/AWSCore/Code/Source/Editor/UI/AWSCoreEditorMenu.cpp +++ b/Gems/AWSCore/Code/Source/Editor/UI/AWSCoreEditorMenu.cpp @@ -35,6 +35,8 @@ namespace AWSCore { + static constexpr int IconSize = 16; + AWSCoreEditorMenu::AWSCoreEditorMenu(const QString& text) : QMenu(text) , m_resourceMappingToolWatcher(nullptr) @@ -43,6 +45,7 @@ namespace AWSCore InitializeResourceMappingToolAction(); this->addSeparator(); InitializeAWSFeatureGemActions(); + AddSpaceForIcon(this); AWSCoreEditorRequestBus::Handler::BusConnect(); } @@ -136,6 +139,8 @@ namespace AWSCore globalDocsMenu->addAction(AddExternalLinkAction(AWSAndScriptCanvasActionText, AWSAndScriptCanvasUrl, ":/Notifications/link.svg")); globalDocsMenu->addAction(AddExternalLinkAction(AWSAndComponentsActionText, AWSAndComponentsUrl, ":/Notifications/link.svg")); globalDocsMenu->addAction(AddExternalLinkAction(CallAWSResourcesActionText, CallAWSResourcesUrl, ":/Notifications/link.svg")); + + AddSpaceForIcon(globalDocsMenu); } void AWSCoreEditorMenu::InitializeAWSFeatureGemActions() @@ -170,6 +175,8 @@ namespace AWSCore AWSClientAuthPlatformSpecificActionText, AWSClientAuthPlatformSpecificUrl, ":/Notifications/link.svg")); subMenu->addAction(AddExternalLinkAction( AWSClientAuthAPIReferenceActionText, AWSClientAuthAPIReferenceUrl, ":/Notifications/link.svg")); + + AddSpaceForIcon(subMenu); } void AWSCoreEditorMenu::SetAWSMetricsEnabled() @@ -198,6 +205,7 @@ namespace AWSCore QDesktopServices::openUrl(QUrl::fromLocalFile(configFilePath.c_str())); }); subMenu->addAction(settingsAction); + AddSpaceForIcon(subMenu); } QMenu* AWSCoreEditorMenu::SetAWSFeatureSubMenu(const AZStd::string& menuText) @@ -209,6 +217,7 @@ namespace AWSCore { QMenu* subMenu = new QMenu(QObject::tr(menuText.c_str())); subMenu->setIcon(QIcon(QString(":/Notifications/checkmark.svg"))); + subMenu->setProperty("noHover", true); this->insertMenu(*itr, subMenu); this->removeAction(*itr); return subMenu; @@ -216,4 +225,11 @@ namespace AWSCore } return nullptr; } + + void AWSCoreEditorMenu::AddSpaceForIcon(QMenu* menu) + { + QSize size = menu->sizeHint(); + size.setWidth(size.width() + IconSize); + menu->setFixedSize(size); + } } // namespace AWSCore From 9f934a6f63e6fb880b26e995e5c976d0c1ca72bf Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Mon, 21 Jun 2021 16:25:45 +0100 Subject: [PATCH 5/6] add Draw Helpers changed notification + physx draw helpers listens to it (#1456) --- .../Viewport/ViewportMessages.h | 13 ++++ Code/Sandbox/Editor/ViewportTitleDlg.cpp | 8 +- Gems/PhysX/Code/Editor/DebugDraw.cpp | 78 ++++++++++++++++--- Gems/PhysX/Code/Editor/DebugDraw.h | 20 ++++- 4 files changed, 104 insertions(+), 15 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h index 85250f2a32..b4d0342c44 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h @@ -210,6 +210,19 @@ namespace AzToolsFramework //! Type to inherit to implement ViewportInteractionRequests. using ViewportInteractionRequestBus = AZ::EBus; + //! An interface to notify when changes to viewport settings have happened. + class ViewportSettingNotifications + { + public: + virtual void OnGridSnappingChanged([[maybe_unused]] bool enabled) {} + virtual void OnDrawHelpersChanged([[maybe_unused]] bool enabled) {} + + protected: + ViewportSettingNotifications() = default; + }; + + using ViewportSettingsNotificationBus = AZ::EBus; + //! Requests to freeze the Viewport Input //! Added to prevent a bug with the legacy CryEngine Viewport code that would //! keep doing raycast tests even when no level is loaded, causing a crash. diff --git a/Code/Sandbox/Editor/ViewportTitleDlg.cpp b/Code/Sandbox/Editor/ViewportTitleDlg.cpp index dc4815eb6a..491d31a2ff 100644 --- a/Code/Sandbox/Editor/ViewportTitleDlg.cpp +++ b/Code/Sandbox/Editor/ViewportTitleDlg.cpp @@ -45,6 +45,7 @@ #include #include +#include AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include "ui_ViewportTitleDlg.h" @@ -57,13 +58,16 @@ inline namespace Helpers { void ToggleHelpers() { - GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers()); + const bool newValue = !GetIEditor()->GetDisplaySettings()->IsDisplayHelpers(); + GetIEditor()->GetDisplaySettings()->DisplayHelpers(newValue); GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate); - if (GetIEditor()->GetDisplaySettings()->IsDisplayHelpers() == false) + if (newValue == false) { GetIEditor()->GetObjectManager()->SendEvent(EVENT_HIDE_HELPER); } + AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Broadcast( + &AzToolsFramework::ViewportInteraction::ViewportSettingNotifications::OnDrawHelpersChanged, newValue); } bool IsHelpersShown() diff --git a/Gems/PhysX/Code/Editor/DebugDraw.cpp b/Gems/PhysX/Code/Editor/DebugDraw.cpp index 829b776e28..1f1c24b9ad 100644 --- a/Gems/PhysX/Code/Editor/DebugDraw.cpp +++ b/Gems/PhysX/Code/Editor/DebugDraw.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,15 @@ namespace PhysX return false; } + bool IsDrawColliderReadOnly() + { + bool helpersVisible = false; + AzToolsFramework::EditorRequestBus::BroadcastResult(helpersVisible, + &AzToolsFramework::EditorRequests::DisplayHelpersVisible); + // if helpers are visible, draw colliders is NOT read only and can be changed. + return !helpersVisible; + } + static void BuildAABBVerts(const AZ::Aabb& aabb, AZStd::vector& verts, AZStd::vector& points, @@ -145,28 +155,42 @@ namespace PhysX "PhysX Collider Debug Draw", "Manages global and per-collider debug draw settings and logic") ->DataElement(AZ::Edit::UIHandlers::CheckBox, &Collider::m_locallyEnabled, "Draw collider", "Shows the geometry for the collider in the viewport") - ->Attribute(AZ::Edit::Attributes::CheckboxTooltip, - "If set, the geometry of this collider is visible in the viewport") - ->Attribute(AZ::Edit::Attributes::Visibility, - VisibilityFunc{ []() { return IsGlobalColliderDebugCheck(GlobalCollisionDebugState::Manual); } }) + ->Attribute(AZ::Edit::Attributes::CheckboxTooltip, + "If set, the geometry of this collider is visible in the viewport. 'Draw Helpers' needs to be enabled to use.") + ->Attribute(AZ::Edit::Attributes::Visibility, + VisibilityFunc{ []() { return IsGlobalColliderDebugCheck(GlobalCollisionDebugState::Manual); } }) + ->Attribute(AZ::Edit::Attributes::ReadOnly, &IsDrawColliderReadOnly) ->DataElement(AZ::Edit::UIHandlers::Button, &Collider::m_globalButtonState, "Draw collider", "Shows the geometry for the collider in the viewport") - ->Attribute(AZ::Edit::Attributes::ButtonText, "Global override") - ->Attribute(AZ::Edit::Attributes::ButtonTooltip, - "A global setting is overriding this property (to disable the override, " - "set the Global Collision Debug setting to \"Set manually\" in the PhysX Configuration)") - ->Attribute(AZ::Edit::Attributes::Visibility, - VisibilityFunc{ []() { return !IsGlobalColliderDebugCheck(GlobalCollisionDebugState::Manual); } }) - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &OpenPhysXSettingsWindow) + ->Attribute(AZ::Edit::Attributes::ButtonText, "Global override") + ->Attribute(AZ::Edit::Attributes::ButtonTooltip, + "A global setting is overriding this property (to disable the override, " + "set the Global Collision Debug setting to \"Set manually\" in the PhysX Configuration)." + "'Draw Helpers' needs to be enabled to use.") + ->Attribute(AZ::Edit::Attributes::Visibility, + VisibilityFunc{ []() { return !IsGlobalColliderDebugCheck(GlobalCollisionDebugState::Manual); } }) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &OpenPhysXSettingsWindow) + ->Attribute(AZ::Edit::Attributes::ReadOnly, &IsDrawColliderReadOnly) ; } } } + Collider::Collider() + : m_debugDisplayDataChangedEvent( + [this]([[maybe_unused]] const PhysX::Debug::DebugDisplayData& data) + { + this->RefreshTreeHelper(); + }) + { + + } + void Collider::Connect(AZ::EntityId entityId) { m_entityId = entityId; AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(m_entityId); + AzToolsFramework::EntitySelectionEvents::Bus::Handler::BusConnect(m_entityId); } void Collider::SetDisplayCallback(const DisplayCallback* callback) @@ -176,6 +200,11 @@ namespace PhysX void Collider::Disconnect() { + if (AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusIsConnected()) + { + AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusDisconnect(); + } + AzToolsFramework::EntitySelectionEvents::Bus::Handler::BusDisconnect(); AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect(); m_displayCallback = nullptr; m_entityId = AZ::EntityId(); @@ -731,6 +760,33 @@ namespace PhysX } } + void Collider::OnDrawHelpersChanged([[maybe_unused]] bool enabled) + { + RefreshTreeHelper(); + } + + void Collider::OnSelected() + { + AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusConnect( + AzFramework::g_defaultSceneEntityDebugDisplayId); + if (auto* physXDebug = AZ::Interface::Get()) + { + physXDebug->RegisterDebugDisplayDataChangedEvent(m_debugDisplayDataChangedEvent); + } + } + + void Collider::OnDeselected() + { + AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusDisconnect(); + m_debugDisplayDataChangedEvent.Disconnect(); + } + + void Collider::RefreshTreeHelper() + { + AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast( + &AzToolsFramework::ToolsApplicationEvents::Bus::Events::InvalidatePropertyDisplay, AzToolsFramework::Refresh_AttributesAndValues); + } + AZStd::string Collider::GetEntityName() const { AZStd::string entityName; diff --git a/Gems/PhysX/Code/Editor/DebugDraw.h b/Gems/PhysX/Code/Editor/DebugDraw.h index c43634717a..34b3b57667 100644 --- a/Gems/PhysX/Code/Editor/DebugDraw.h +++ b/Gems/PhysX/Code/Editor/DebugDraw.h @@ -15,8 +15,11 @@ #include #include #include +#include +#include #include #include +#include namespace PhysX { @@ -40,13 +43,15 @@ namespace PhysX class Collider : protected AzFramework::EntityDebugDisplayEventBus::Handler + , protected AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler + , protected AzToolsFramework::EntitySelectionEvents::Bus::Handler { public: AZ_CLASS_ALLOCATOR(Collider, AZ::SystemAllocator, 0); AZ_RTTI(Collider, "{7DE9CA01-DF1E-4D72-BBF4-76C9136BE6A2}"); static void Reflect(AZ::ReflectContext* context); - Collider() = default; + Collider(); void Connect(AZ::EntityId entityId); void SetDisplayCallback(const DisplayCallback* callback); @@ -109,11 +114,20 @@ namespace PhysX const AZStd::vector& GetIndices(AZ::u32 geomIndex) const; protected: - // AzFramework::EntityDebugDisplayEventBus + // AzFramework::EntityDebugDisplayEventBus overrides ... void DisplayEntityViewport( const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override; + // AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler overrides ... + void OnDrawHelpersChanged(bool enabled) override; + + // AzToolsFramework::EntitySelectionEvents::Bus::Handler overrides ... + void OnSelected() override; + void OnDeselected() override; + + void RefreshTreeHelper(); + // Internal mesh drawing subroutines void DrawTriangleMesh( AzFramework::DebugDisplayRequests& debugDisplay, const Physics::ColliderConfiguration& colliderConfig, AZ::u32 geomIndex, @@ -143,6 +157,8 @@ namespace PhysX }; mutable AZStd::vector m_geometry; + + PhysX::Debug::DebugDisplayDataChangedEvent::Handler m_debugDisplayDataChangedEvent; }; } // namespace DebugDraw } // namespace PhysX From 22ff37ecda23c8c845ee4583132ffd84b517fd29 Mon Sep 17 00:00:00 2001 From: Eric Phister <52085794+amzn-phist@users.noreply.github.com> Date: Mon, 21 Jun 2021 11:18:03 -0500 Subject: [PATCH 6/6] Fixes issue with ACE displaying only banks (#1427) Updates to some AzCore functions a while ago made some path functions strip off a trailing slash, which caused bad paths to be used when loading middleware data. Updated the code to use better path APIs. --- .../Code/Source/Editor/AudioSystemEditor_wwise.cpp | 8 ++++---- .../Code/Source/Editor/AudioSystemEditor_wwise.h | 2 +- .../Code/Source/Editor/AudioWwiseLoader.cpp | 12 ++++++------ .../Code/Include/Editor/IAudioSystemEditor.h | 3 ++- .../Code/Source/Editor/AudioControlsEditorWindow.cpp | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.cpp b/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.cpp index c9ab5a135e..b21c008353 100644 --- a/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.cpp +++ b/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -540,11 +541,10 @@ namespace AudioControls } //-------------------------------------------------------------------------------------------// - AZStd::string CAudioSystemEditor_wwise::GetDataPath() const + AZ::IO::FixedMaxPath CAudioSystemEditor_wwise::GetDataPath() const { - AZStd::string path(Path::GetEditingGameDataFolder()); - AZ::StringFunc::Path::Join(path.c_str(), "sounds/wwise_project/", path); - return path; + auto projectPath = AZ::IO::FixedMaxPath{ AZ::Utils::GetProjectPath() }; + return (projectPath / "sounds" / "wwise_project"); } } // namespace AudioControls diff --git a/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.h b/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.h index ee7b54217d..e2a9fdf5d7 100644 --- a/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.h +++ b/Gems/AudioEngineWwise/Code/Source/Editor/AudioSystemEditor_wwise.h @@ -86,7 +86,7 @@ namespace AudioControls const AZStd::string_view GetTypeIcon(TImplControlType type) const override; const AZStd::string_view GetTypeIconSelected(TImplControlType type) const override; AZStd::string GetName() const override; - AZStd::string GetDataPath() const; + AZ::IO::FixedMaxPath GetDataPath() const override; void DataSaved() override {} void ConnectionRemoved(IAudioSystemControl* control) override; ////////////////////////////////////////////////////////// diff --git a/Gems/AudioEngineWwise/Code/Source/Editor/AudioWwiseLoader.cpp b/Gems/AudioEngineWwise/Code/Source/Editor/AudioWwiseLoader.cpp index 074e25d39a..3f2aac2b98 100644 --- a/Gems/AudioEngineWwise/Code/Source/Editor/AudioWwiseLoader.cpp +++ b/Gems/AudioEngineWwise/Code/Source/Editor/AudioWwiseLoader.cpp @@ -54,12 +54,12 @@ namespace AudioControls void CAudioWwiseLoader::Load(CAudioSystemEditor_wwise* audioSystemImpl) { m_audioSystemImpl = audioSystemImpl; - const AZStd::string wwiseProjectFullPath(m_audioSystemImpl->GetDataPath()); - LoadControlsInFolder(wwiseProjectFullPath + WwiseStrings::GameParametersFolder); - LoadControlsInFolder(wwiseProjectFullPath + WwiseStrings::GameStatesFolder); - LoadControlsInFolder(wwiseProjectFullPath + WwiseStrings::SwitchesFolder); - LoadControlsInFolder(wwiseProjectFullPath + WwiseStrings::EventsFolder); - LoadControlsInFolder(wwiseProjectFullPath + WwiseStrings::EnvironmentsFolder); + const AZ::IO::FixedMaxPath wwiseProjectFullPath{ m_audioSystemImpl->GetDataPath() }; + LoadControlsInFolder(AZ::IO::FixedMaxPath{ wwiseProjectFullPath / WwiseStrings::GameParametersFolder }.Native()); + LoadControlsInFolder(AZ::IO::FixedMaxPath{ wwiseProjectFullPath / WwiseStrings::GameStatesFolder }.Native()); + LoadControlsInFolder(AZ::IO::FixedMaxPath{ wwiseProjectFullPath / WwiseStrings::SwitchesFolder }.Native()); + LoadControlsInFolder(AZ::IO::FixedMaxPath{ wwiseProjectFullPath / WwiseStrings::EventsFolder }.Native()); + LoadControlsInFolder(AZ::IO::FixedMaxPath{ wwiseProjectFullPath / WwiseStrings::EnvironmentsFolder }.Native()); LoadSoundBanks(Audio::Wwise::GetBanksRootPath(), "", false); } diff --git a/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h b/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h index ac2bc8c0b8..0ccd1390af 100644 --- a/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h +++ b/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h @@ -14,6 +14,7 @@ #pragma once #include +#include #include #include @@ -151,7 +152,7 @@ namespace AudioControls //! Gets the folder where the implementation specific controls data are stored. //! This is used by the ACE to update if controls are changed while the editor is open. //! @return String with the path to the folder where the implementation specific controls are stored. - virtual AZStd::string GetDataPath() const = 0; + virtual AZ::IO::FixedMaxPath GetDataPath() const = 0; //! Informs the plugin that the ACE has saved the data in case it needs to do any clean up. virtual void DataSaved() = 0; diff --git a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp index 7e3528362e..68d5a30af9 100644 --- a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp +++ b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp @@ -218,7 +218,7 @@ namespace AudioControls IAudioSystemEditor* pAudioSystemImpl = CAudioControlsEditorPlugin::GetAudioSystemEditorImpl(); if (pAudioSystemImpl) { - StartWatchingFolder(pAudioSystemImpl->GetDataPath()); + StartWatchingFolder(pAudioSystemImpl->GetDataPath().LexicallyNormal().Native()); m_pMiddlewareDockWidget->setWindowTitle(QString(pAudioSystemImpl->GetName().c_str()) + " Controls"); } }