From fa781fabc51691eff176b7edc1ffcc2a991e5327 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Wed, 14 Apr 2021 16:20:45 -0700 Subject: [PATCH 001/185] Add MultiplayerGem Editor components for Ctrl+G support --- Gems/Multiplayer/Code/CMakeLists.txt | 50 ++++++ .../Editor/MultiplayerEditorDispatcher.cpp | 21 +++ .../Editor/MultiplayerEditorDispatcher.h | 36 +++++ .../MultiplayerEditorSystemComponent.cpp | 149 ++++++++++++++++++ .../Editor/MultiplayerEditorSystemComponent.h | 75 +++++++++ .../Code/Source/MultiplayerGem.cpp | 12 +- .../Code/multiplayer_editor_files.cmake | 15 ++ .../multiplayer_editor_shared_files.cmake | 17 ++ 8 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h create mode 100644 Gems/Multiplayer/Code/multiplayer_editor_files.cmake create mode 100644 Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt index f811ac64b3..c95afbbb74 100644 --- a/Gems/Multiplayer/Code/CMakeLists.txt +++ b/Gems/Multiplayer/Code/CMakeLists.txt @@ -59,6 +59,56 @@ ly_add_target( Gem::CertificateManager ) +if(PAL_TRAIT_BUILD_HOST_TOOLS) + + ly_add_target( + NAME Multiplayer.Editor.Static STATIC + NAMESPACE Gem + FILES_CMAKE + multiplayer_editor_files.cmake + COMPILE_DEFINITIONS + PUBLIC + MULTIPLAYER_EDITOR + INCLUDE_DIRECTORIES + PRIVATE + . + Source + ${pal_source_dir} + PUBLIC + Include + BUILD_DEPENDENCIES + PUBLIC + Legacy::CryCommon + Legacy::Editor.Headers + AZ::AzCore + AZ::AzFramework + AZ::AzNetworking + AZ::AzToolsFramework + AZ::GFxFramework + Gem::Multiplayer.Static + ) + + ly_add_target( + NAME Multiplayer.Editor GEM_MODULE + NAMESPACE Gem + FILES_CMAKE + multiplayer_editor_shared_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + . + Source + ${pal_source_dir} + PUBLIC + Include + BUILD_DEPENDENCIES + PRIVATE + Gem::Multiplayer.Editor.Static + RUNTIME_DEPENDENCIES + Gem::LmbrCentral.Editor + ) + +endif() + ################################################################################ # Tests ################################################################################ diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp new file mode 100644 index 0000000000..470aa61cd0 --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp @@ -0,0 +1,21 @@ +/* + * 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 + +namespace Multiplayer +{ + MultiplayerEditorDispatcher::MultiplayerEditorDispatcher() + { + ; + } +} diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h new file mode 100644 index 0000000000..c1058dc8a0 --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h @@ -0,0 +1,36 @@ +/* +* 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 + +#include +#include +#include +#include + +#include + + +namespace Multiplayer +{ + //! MultiplayerEditorDispatcher is responsible for dispatching delta from the Editor to an Editor launched local server + class MultiplayerEditorDispatcher final + { + public: + MultiplayerEditorDispatcher(); + ~MultiplayerEditorDispatcher() = default; + + private: + }; +} diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp new file mode 100644 index 0000000000..0227d8b159 --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp @@ -0,0 +1,149 @@ +/* + * 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 +#include +#include +#include +#include +#include + +namespace Multiplayer +{ + using namespace AzNetworking; + + AZ_CVAR(bool, editorsv_enabled, true, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, + "Whether Editor launching a local server to connect to is supported"); + AZ_CVAR(AZ::CVarFixedString, editorsv_process, "", nullptr, AZ::ConsoleFunctorFlags::DontReplicate, + "The server executable that should be run. Empty to use the current project's ServerLauncher"); + + void MultiplayerEditorSystemComponent::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Version(1); + } + } + + void MultiplayerEditorSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) + { + required.push_back(AZ_CRC_CE("MultiplayerService")); + } + + void MultiplayerEditorSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + provided.push_back(AZ_CRC_CE("MultiplayerEditorService")); + } + + void MultiplayerEditorSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) + { + incompatible.push_back(AZ_CRC_CE("MultiplayerEditorService")); + } + + MultiplayerEditorSystemComponent::MultiplayerEditorSystemComponent() + { + ; + } + + void MultiplayerEditorSystemComponent::Activate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusConnect(); + } + + void MultiplayerEditorSystemComponent::Deactivate() + { + AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect(); + } + + void MultiplayerEditorSystemComponent::NotifyRegisterViews() + { + m_editor = nullptr; + AzToolsFramework::EditorRequests::Bus::BroadcastResult(m_editor, &AzToolsFramework::EditorRequests::GetEditor); + m_editor->RegisterNotifyListener(this); + } + + void MultiplayerEditorSystemComponent::OnEditorNotifyEvent(EEditorNotifyEvent event) + { + switch (event) + { + case eNotify_OnBeginGameMode: + { + AZ::TickBus::Handler::BusConnect(); + + if (editorsv_enabled) + { + // Assemble the server's path + AZ::CVarFixedString serverProcess = editorsv_process; + if (serverProcess.empty()) + { + // If enabled but no process name is supplied, try this project's ServerLauncher + serverProcess = AZ::Utils::GetProjectName() + ".ServerLauncher"; + } + + AZ::IO::FixedMaxPathString serverPath = AZ::Utils::GetExecutableDirectory(); + if (!serverProcess.contains(AZ_TRAIT_OS_PATH_SEPARATOR)) + { + // If only the process name is specified, append that as well + serverPath.append(AZ_TRAIT_OS_PATH_SEPARATOR + serverProcess); + } + else + { + // If any path was already specified, then simply assign + serverPath = serverProcess; + } + + if (!serverProcess.ends_with(AZ_TRAIT_OS_EXECUTABLE_EXTENSION)) + { + // Add this platform's exe extension if it's not specified + serverPath.append(AZ_TRAIT_OS_EXECUTABLE_EXTENSION); + } + + // Start the configured server if it's available + AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo; + processLaunchInfo.m_commandlineParameters = + AZStd::string::format("\"%s\"", serverPath.c_str()); + processLaunchInfo.m_showWindow = true; + processLaunchInfo.m_processPriority = AzFramework::ProcessPriority::PROCESSPRIORITY_NORMAL; + + m_serverProcess = AzFramework::ProcessWatcher::LaunchProcess( + processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE); + } + break; + } + case eNotify_OnQuit: + m_editor->UnregisterNotifyListener(this); + m_editor = nullptr; + // Fall through here as the cleanup steps in EndGameMode are good sanity + case eNotify_OnEndGameMode: + AZ::TickBus::Handler::BusDisconnect(); + // Kill the configured server if it's active + if (m_serverProcess) + { + m_serverProcess->TerminateProcess(0); + m_serverProcess = nullptr; + } + break; + } + } + + void MultiplayerEditorSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) + { + + } + + int MultiplayerEditorSystemComponent::GetTickOrder() + { + // Tick immediately after the network system component + return AZ::TICK_PLACEMENT + 1; + } +} diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h new file mode 100644 index 0000000000..8c18a2e57a --- /dev/null +++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h @@ -0,0 +1,75 @@ +/* +* 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 + +#include +#include +#include +#include + +#include +#include + + +namespace AzNetworking +{ + class INetworkInterface; +} + +namespace Multiplayer +{ + //! Multiplayer system component wraps the bridging logic between the game and transport layer. + class MultiplayerEditorSystemComponent final + : public AZ::Component + , private AZ::TickBus::Handler + , private AzToolsFramework::EditorEvents::Bus::Handler + , private IEditorNotifyListener + { + public: + AZ_COMPONENT(MultiplayerEditorSystemComponent, "{9F335CC0-5574-4AD3-A2D8-2FAEF356946C}"); + + static void Reflect(AZ::ReflectContext* context); + static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); + static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); + + MultiplayerEditorSystemComponent(); + ~MultiplayerEditorSystemComponent() override = default; + + //! AZ::Component overrides. + //! @{ + void Activate() override; + void Deactivate() override; + //! @} + + //! EditorEvents::Bus::Handler overrides. + //! @{ + void NotifyRegisterViews() override; + //! @} + + private: + + //! AZ::TickBus::Handler overrides. + //! @{ + void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; + int GetTickOrder() override; + //! @} + //! + void OnEditorNotifyEvent(EEditorNotifyEvent event) override; + + IEditor* m_editor = nullptr; + AzFramework::ProcessWatcher* m_serverProcess = nullptr; + }; +} diff --git a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp index 80f1635bdc..424cb5b14f 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp @@ -15,6 +15,10 @@ #include #include +#ifdef MULTIPLAYER_EDITOR + #include +#endif + namespace Multiplayer { MultiplayerModule::MultiplayerModule() @@ -23,6 +27,9 @@ namespace Multiplayer m_descriptors.insert(m_descriptors.end(), { AzNetworking::NetworkingSystemComponent::CreateDescriptor(), MultiplayerSystemComponent::CreateDescriptor(), +#ifdef MULTIPLAYER_EDITOR + MultiplayerEditorSystemComponent::CreateDescriptor(), +#endif }); } @@ -32,8 +39,11 @@ namespace Multiplayer { azrtti_typeid(), azrtti_typeid(), +#ifdef MULTIPLAYER_EDITOR + azrtti_typeid(), +#endif }; } } -AZ_DECLARE_MODULE_CLASS(Gem_Multiplayer2, Multiplayer::MultiplayerModule); +AZ_DECLARE_MODULE_CLASS(Gem_Multiplayer, Multiplayer::MultiplayerModule); diff --git a/Gems/Multiplayer/Code/multiplayer_editor_files.cmake b/Gems/Multiplayer/Code/multiplayer_editor_files.cmake new file mode 100644 index 0000000000..ce3e3227e0 --- /dev/null +++ b/Gems/Multiplayer/Code/multiplayer_editor_files.cmake @@ -0,0 +1,15 @@ +# +# 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. +# + +set(FILES + Source/Editor/MultiplayerEditorDispatcher.cpp + Source/Editor/MultiplayerEditorDispatcher.h +) diff --git a/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake b/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake new file mode 100644 index 0000000000..e0c50f864e --- /dev/null +++ b/Gems/Multiplayer/Code/multiplayer_editor_shared_files.cmake @@ -0,0 +1,17 @@ +# +# 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. +# + +set(FILES + Source/MultiplayerGem.cpp + Source/MultiplayerGem.h + Source/Editor/MultiplayerEditorSystemComponent.cpp + Source/Editor/MultiplayerEditorSystemComponent.h +) From 2309c06709856f0b47e8f2b7e15c905a4ab18a0c Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 15 Apr 2021 14:37:15 -0700 Subject: [PATCH 002/185] Fix merge error in MP Gem Module --- Gems/Multiplayer/Code/Source/MultiplayerGem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp index 13dcf47d04..da199670ea 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerGem.cpp @@ -36,7 +36,6 @@ namespace Multiplayer }); CreateComponentDescriptors(m_descriptors); - }); } AZ::ComponentTypeList MultiplayerModule::GetRequiredSystemComponents() const From 969f94ffb5f675cf4ed047b05e8e3675035b8a74 Mon Sep 17 00:00:00 2001 From: hasareej Date: Fri, 16 Apr 2021 10:27:13 +0100 Subject: [PATCH 003/185] Initial pass of ViewportUiSwitcher. --- .../EditorTransformComponentSelection.cpp | 67 ++++++++++ .../EditorTransformComponentSelection.h | 9 ++ .../AzToolsFramework/ViewportUi/Button.cpp | 7 + .../AzToolsFramework/ViewportUi/Button.h | 2 + .../AzToolsFramework/ViewportUi/Cluster.cpp | 14 +- .../AzToolsFramework/ViewportUi/Cluster.h | 2 +- .../ViewportUi/ViewportUiDisplay.cpp | 46 +++++++ .../ViewportUi/ViewportUiDisplay.h | 6 + .../ViewportUi/ViewportUiManager.cpp | 38 ++++++ .../ViewportUi/ViewportUiManager.h | 5 + .../ViewportUi/ViewportUiRequestBus.h | 7 + .../ViewportUi/ViewportUiSwitcher.cpp | 125 ++++++++++++++++++ .../ViewportUi/ViewportUiSwitcher.h | 41 ++++++ .../aztoolsframework_files.cmake | 2 + Editor/Icons/Switcher/BoxShape.svg | 15 +++ Editor/Icons/Switcher/PhysXCollider.svg | 15 +++ Editor/Icons/Switcher/Transform.svg | 15 +++ 17 files changed, 413 insertions(+), 3 deletions(-) create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ViewportUiSwitcher.cpp create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ViewportUiSwitcher.h create mode 100644 Editor/Icons/Switcher/BoxShape.svg create mode 100644 Editor/Icons/Switcher/PhysXCollider.svg create mode 100644 Editor/Icons/Switcher/Transform.svg diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index 27222e9aac..3d4ed6ee0b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -440,6 +440,13 @@ namespace AzToolsFramework &ViewportUi::ViewportUiRequestBus::Events::RemoveCluster, clusterId); } + + static void RemoveTestSwitcher(const ViewportUi::ClusterId clusterId) + { + ViewportUi::ViewportUiRequestBus::Event( + ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::RemoveCluster, + clusterId); + } static void SetViewportUiClusterVisible(ViewportUi::ClusterId clusterId, bool visible) { @@ -468,6 +475,18 @@ namespace AzToolsFramework return buttonId; } + static ViewportUi::ButtonId RegisterSwitcherButton( + ViewportUi::ClusterId clusterId, const char* iconName, const char* buttonName) + { + ViewportUi::ButtonId buttonId; + ViewportUi::ViewportUiRequestBus::EventResult( + buttonId, ViewportUi::DefaultViewportId, + &ViewportUi::ViewportUiRequestBus::Events::CreateSwitcherButton, clusterId, + AZStd::string::format("Editor/Icons/Switcher/%s.svg", iconName), buttonName); + + return buttonId; + } + // return either center or entity pivot static AZ::Vector3 CalculatePivotTranslation( const AZ::EntityId entityId, const EditorTransformComponentSelectionRequests::Pivot pivot) @@ -1028,6 +1047,8 @@ namespace AzToolsFramework RegisterActions(); SetupBoxSelect(); RefreshSelectedEntityIdsAndRegenerateManipulators(); + + CreateTestSwitcher(); } EditorTransformComponentSelection::~EditorTransformComponentSelection() @@ -1038,6 +1059,8 @@ namespace AzToolsFramework DestroyTransformModeSelectionCluster(m_transformModeClusterId); UnregisterActions(); + RemoveTestSwitcher(m_testSwitcherId); + m_pivotOverrideFrame.Reset(); EditorManipulatorCommandUndoRedoRequestBus::Handler::BusDisconnect(); @@ -2561,6 +2584,50 @@ namespace AzToolsFramework m_transformModeSelectionHandler); } + void EditorTransformComponentSelection::CreateTestSwitcher() + { + // Create test switcher + // & Set Current Active Mode + ViewportUi::ViewportUiRequestBus::EventResult( + m_testSwitcherId, ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::CreateSwitcher, + ViewportUi::ButtonId(1)); + + // create and register the buttons + m_boxShapeButtonId = RegisterSwitcherButton(m_testSwitcherId, "BoxShape", "Box Shape"); + m_physxColliderButtonId = RegisterSwitcherButton(m_testSwitcherId, "PhysXCollider", "PhysX Collider"); + m_transformButtonId = RegisterSwitcherButton(m_testSwitcherId, "Transform", "Transform"); + + // Change current active button for now + const auto onButtonClicked = [this](ViewportUi::ButtonId buttonId) { + if (buttonId == m_boxShapeButtonId) + { + ViewportUi::ViewportUiRequestBus::Event( + ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::SetSwitcherActiveButton, m_testSwitcherId, + m_boxShapeButtonId); + AZ_Printf("ViewportUi", "Box Shape"); + } + else if (buttonId == m_physxColliderButtonId) + { + ViewportUi::ViewportUiRequestBus::Event( + ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::SetSwitcherActiveButton, m_testSwitcherId, + m_physxColliderButtonId); + AZ_Printf("ViewportUi", "PhysXCollider"); + } + else if (buttonId == m_transformButtonId) + { + ViewportUi::ViewportUiRequestBus::Event( + ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::SetSwitcherActiveButton, m_testSwitcherId, + m_transformButtonId); + AZ_Printf("ViewportUi", "Transform"); + } + }; + + m_testSwitcherHandler = AZ::Event::Handler(onButtonClicked); + ViewportUi::ViewportUiRequestBus::Event( + ViewportUi::DefaultViewportId, &ViewportUi::ViewportUiRequestBus::Events::RegisterClusterEventHandler, m_testSwitcherId, + m_testSwitcherHandler); + } + EditorTransformComponentSelectionRequests::Mode EditorTransformComponentSelection::GetTransformMode() { return m_mode; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h index 99265313fe..9a66ad042f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h @@ -281,6 +281,15 @@ namespace AzToolsFramework ViewportUi::ButtonId m_rotateButtonId; ///< Id of the Viewport UI button for rotate mode. ViewportUi::ButtonId m_scaleButtonId; ///< Id of the Viewport UI button for scale mode. AZ::Event::Handler m_transformModeSelectionHandler; ///< Event handler for the Viewport UI cluster. + + //! Create the Viewport UI Switcher. TEST + void CreateTestSwitcher(); + + ViewportUi::ClusterId m_testSwitcherId; + ViewportUi::ButtonId m_boxShapeButtonId; + ViewportUi::ButtonId m_physxColliderButtonId; + ViewportUi::ButtonId m_transformButtonId; + AZ::Event::Handler m_testSwitcherHandler; }; /// The ETCS (EntityTransformComponentSelection) namespace contains functions and data used exclusively by diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.cpp index 701344db18..6218826f35 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.cpp @@ -22,4 +22,11 @@ namespace AzToolsFramework::ViewportUi::Internal , m_buttonId(buttonId) { } + + Button::Button(AZStd::string icon, AZStd::string name, ButtonId buttonId) + : m_icon(AZStd::move(icon)) + , m_name(AZStd::move(name)) + , m_buttonId(buttonId) + { + } } // namespace AzToolsFramework::ViewportUi::Internal diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.h index 8ff98abc5d..3b77f6bd4a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Button.h @@ -28,9 +28,11 @@ namespace AzToolsFramework::ViewportUi::Internal }; explicit Button(AZStd::string icon, ButtonId buttonId); + Button(AZStd::string icon, AZStd::string name, ButtonId buttonId); ~Button() = default; AZStd::string m_icon; //!< The icon for this button, string path to an image. + AZStd::string m_name; //!< The icon for this button, string path to an image. State m_state = State::Deselected; ButtonId m_buttonId; }; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Cluster.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Cluster.cpp index 2de6836aa5..baefeac986 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Cluster.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/Cluster.cpp @@ -13,6 +13,9 @@ #include #include +#pragma optimize("", off) +#pragma inline_depth(0) + namespace AzToolsFramework::ViewportUi::Internal { Cluster::Cluster() @@ -53,11 +56,18 @@ namespace AzToolsFramework::ViewportUi::Internal } } - ButtonId Cluster::AddButton(const AZStd::string& icon) + ButtonId Cluster::AddButton(const AZStd::string& icon, const AZStd::string& name) { auto buttonId = ButtonId(m_buttons.size() + 1); - m_buttons.insert({buttonId, AZStd::make_unique