From 326dcc3d1003c25cfc839933d369630056ba3b6d Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 3 Jun 2021 12:45:18 -0500 Subject: [PATCH 01/37] ToolsApplication constructor Signed-off-by: Dayo Lawal --- .../AzQtComponents/AzQtComponents/azqtcomponents_files.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index cd00aff988..adce70523c 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -7,6 +7,8 @@ set(FILES AzQtComponentsAPI.h + Application/ToolsApplication.cpp + Application/ToolsApplication.h Buses/DragAndDrop.h Buses/ShortcutDispatch.h DragAndDrop/MainWindowDragAndDrop.h From 975be6a480babde30e7ef83adee4d0d7c0ccf7dd Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Wed, 9 Jun 2021 15:19:41 -0500 Subject: [PATCH 02/37] MaterialEditor inheriting from ToolsApplication Signed-off-by: Dayo Lawal --- .../Application/ToolsApplication.cpp | 174 ++++++++++++++++++ .../Application/ToolsApplication.h | 84 +++++++++ .../Code/Source/MaterialEditorApplication.cpp | 2 +- .../Code/Source/MaterialEditorApplication.h | 5 +- .../Tools/MaterialEditor/Code/Source/main.cpp | 2 +- 5 files changed, 264 insertions(+), 3 deletions(-) create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp new file mode 100644 index 0000000000..d077fbe211 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp @@ -0,0 +1,174 @@ +/* + * 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 // This should be the first include to make sure Windows.h is defined with NOMINMAX + +namespace AzQtComponents +{ + /* + AZStd::string_view GetBuildTargetName() + { +#if !defined(LY_CMAKE_TARGET) +#error "LY_CMAKE_TARGET must be defined in order to add this source file to a CMake executable target" +#endif + return AZStd::string_view { LY_CMAKE_TARGET }; + } + */ + + class ToolsApplication::Impl + : private AZ::Debug::TraceMessageBus::Handler + , public AzFramework::Application + { + friend class ToolsApplication; + + public: + Impl(ToolsApplication* app) : m_app(app) + { + + } + ToolsApplication* m_app; + + bool OnOutput(const char* window, const char* message) override; + + protected: + struct LogMessage + { + AZStd::string window; + AZStd::string message; + }; + + AZStd::vector m_startupLogSink; + AZStd::unique_ptr m_logFile; + + }; + + ToolsApplication::ToolsApplication(int& argc, char** argv) + : QApplication(argc, argv) + , m_impl(new Impl(this)) + { + /* + QApplication::setOrganizationName("Amazon"); + QApplication::setOrganizationDomain("amazon.com"); + QApplication::setApplicationName("O3DEToolsApplication"); + + AzQtComponents::PrepareQtPaths(); + + QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); + + // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays + // on Windows 10 + + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); + QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); + AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware); + */ + + //m_impl->AZ::Debug::TraceMessageBus::Handler::BusConnect(); + + } + + ToolsApplication::~ToolsApplication() + { + //m_impl->AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); + } + + + bool ToolsApplication::Impl::OnOutput(const char* window, const char* message) + { + // Suppress spam from the Source Control system + constexpr char sourceControlWindow[] = "Source Control"; + + if (0 == strncmp(window, sourceControlWindow, AZ_ARRAY_SIZE(sourceControlWindow))) + { + return true; + } + + if (m_logFile) + { + m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message); + } + else + { + m_startupLogSink.push_back({ window, message }); + } + return false; + } + + /* + bool ToolsApplication::AddDockWidget(const AZStd::string& name, QWidget* widget, uint32_t area, uint32_t orientation) + { + auto dockWidgetItr = m_dockWidgets.find(name); + if (dockWidgetItr != m_dockWidgets.end() || !widget) + { + return false; + } + + auto dockWidget = new AzQtComponents::StyledDockWidget(name.c_str()); + dockWidget->setObjectName(QString("%1_DockWidget").arg(name.c_str())); + dockWidget->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + widget->setObjectName(name.c_str()); + widget->setParent(dockWidget); + widget->setMinimumSize(QSize(300, 300)); + dockWidget->setWidget(widget); + //QMainWindow::addDockWidget(aznumeric_cast(area), dockWidget); + //QMainWindow::resizeDocks({ dockWidget }, { 400 }, aznumeric_cast(orientation)); + m_dockWidgets[name] = dockWidget; + return true; + } + + void ToolsApplication::RemoveDockWidget(const AZStd::string& name) + { + auto dockWidgetItr = m_dockWidgets.find(name); + if (dockWidgetItr != m_dockWidgets.end()) + { + delete dockWidgetItr->second; + m_dockWidgets.erase(dockWidgetItr); + } + } + + void ToolsApplication::SetDockWidgetVisible(const AZStd::string& name, bool visible) + { + auto dockWidgetItr = m_dockWidgets.find(name); + if (dockWidgetItr != m_dockWidgets.end()) + { + dockWidgetItr->second->setVisible(visible); + } + } + + bool ToolsApplication::IsDockWidgetVisible(const AZStd::string& name) const + { + auto dockWidgetItr = m_dockWidgets.find(name); + if (dockWidgetItr != m_dockWidgets.end()) + { + return dockWidgetItr->second->isVisible(); + } + return false; + } + + AZStd::vector ToolsApplication::GetDockWidgetNames() const + { + AZStd::vector names; + names.reserve(m_dockWidgets.size()); + for (const auto& dockWidgetPair : m_dockWidgets) + { + names.push_back(dockWidgetPair.first); + } + return names; + } + */ + +} // namespace AzQtComponents + diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h new file mode 100644 index 0000000000..a25507a14e --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h @@ -0,0 +1,84 @@ +/* + * 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 +#include +#include +#include +#include + + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace AzQtComponents +{ + class AZ_QT_COMPONENTS_API ToolsApplication + : public QApplication + { + public: + ToolsApplication(int& argc, char** argv); + ~ToolsApplication(); + + private: + AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING + class Impl; + AZStd::unique_ptr m_impl; + AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING + + //QTimer m_timer; + //void Tick(float deltaOverride = -1.f) override; + + + /* + bool AddDockWidget(const AZStd::string& name, QWidget* widget, uint32_t area, uint32_t orientation); + void RemoveDockWidget(const AZStd::string& name); + void SetDockWidgetVisible(const AZStd::string& name, bool visible); + bool IsDockWidgetVisible(const AZStd::string& name) const; + AZStd::vector GetDockWidgetNames() const; + + AZStd::unordered_map m_dockWidgets; + */ + }; +} // namespace AzQtComponents + + diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index a5435106c6..73bede14a5 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -72,7 +72,7 @@ namespace MaterialEditor MaterialEditorApplication::MaterialEditorApplication(int* argc, char*** argv) : Application(argc, argv) - , QApplication(*argc, *argv) + , ToolsApplication(*argc, *argv) { AZ::Debug::TraceMessageBus::Handler::BusConnect(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index 4d23cc640f..b7b3e13cca 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -21,6 +21,8 @@ #include #include +#include + #include #include @@ -30,13 +32,14 @@ namespace MaterialEditor class MaterialEditorApplication : public AzFramework::Application - , public QApplication + //, public QApplication , private AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler , private MaterialEditorWindowNotificationBus::Handler , private AzFramework::AssetSystemStatusBus::Handler , private AZ::UserSettingsOwnerRequestBus::Handler , private AZ::Debug::TraceMessageBus::Handler , private AzToolsFramework::EditorPythonConsoleNotificationBus::Handler + , public AzQtComponents::ToolsApplication { public: AZ_TYPE_INFO(MaterialEditor::MaterialEditorApplication, "{30F90CA5-1253-49B5-8143-19CEE37E22BB}"); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp index d1b937fde0..3ea7d37175 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char** argv) QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware); - + //*/ MaterialEditor::MaterialEditorApplication app(&argc, &argv); auto globalEventFilter = new AzQtComponents::GlobalEventFilter(&app); From d3d9b600f964fe1c0be71f36776ccecd6c69b0b0 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Wed, 9 Jun 2021 20:09:34 -0500 Subject: [PATCH 03/37] AzQtApplication Signed-off-by: Dayo Lawal --- .../Application/ToolsApplication.cpp | 34 +++++++++++-------- .../Application/ToolsApplication.h | 6 ++-- .../Code/Source/MaterialEditorApplication.cpp | 6 ++-- .../Code/Source/MaterialEditorApplication.h | 3 +- .../ShaderManagementConsoleApplication.cpp | 2 +- .../ShaderManagementConsoleApplication.h | 4 ++- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp index d077fbe211..f01e642770 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp @@ -26,18 +26,18 @@ namespace AzQtComponents } */ - class ToolsApplication::Impl + class AzQtApplication::Impl : private AZ::Debug::TraceMessageBus::Handler - , public AzFramework::Application + //, public AzFramework::Application { - friend class ToolsApplication; + friend class AzQtApplication; public: - Impl(ToolsApplication* app) : m_app(app) + Impl(AzQtApplication* app) : m_app(app) { } - ToolsApplication* m_app; + AzQtApplication* m_app; bool OnOutput(const char* window, const char* message) override; @@ -53,14 +53,18 @@ namespace AzQtComponents }; - ToolsApplication::ToolsApplication(int& argc, char** argv) + AzQtApplication::AzQtApplication(int& argc, char** argv) : QApplication(argc, argv) , m_impl(new Impl(this)) { - /* - QApplication::setOrganizationName("Amazon"); - QApplication::setOrganizationDomain("amazon.com"); - QApplication::setApplicationName("O3DEToolsApplication"); + + // Use a common Qt settings path for applications that don't register their own application name + if (QApplication::applicationName().isEmpty()) + { + QApplication::setOrganizationName("Amazon"); + QApplication::setOrganizationDomain("amazon.com"); + QApplication::setApplicationName("O3DEToolsApplication"); + } AzQtComponents::PrepareQtPaths(); @@ -74,19 +78,19 @@ namespace AzQtComponents QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware); - */ + - //m_impl->AZ::Debug::TraceMessageBus::Handler::BusConnect(); + m_impl->AZ::Debug::TraceMessageBus::Handler::BusConnect(); } - ToolsApplication::~ToolsApplication() + AzQtApplication::~AzQtApplication() { - //m_impl->AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); + m_impl->AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); } - bool ToolsApplication::Impl::OnOutput(const char* window, const char* message) + bool AzQtApplication::Impl::OnOutput(const char* window, const char* message) { // Suppress spam from the Source Control system constexpr char sourceControlWindow[] = "Source Control"; diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h index a25507a14e..40ea888887 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h @@ -52,12 +52,12 @@ namespace AzQtComponents { - class AZ_QT_COMPONENTS_API ToolsApplication + class AZ_QT_COMPONENTS_API AzQtApplication : public QApplication { public: - ToolsApplication(int& argc, char** argv); - ~ToolsApplication(); + AzQtApplication(int& argc, char** argv); + ~AzQtApplication(); private: AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 73bede14a5..cd9f2c9cfd 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -72,9 +72,9 @@ namespace MaterialEditor MaterialEditorApplication::MaterialEditorApplication(int* argc, char*** argv) : Application(argc, argv) - , ToolsApplication(*argc, *argv) + , AzQtApplication(*argc, *argv) { - AZ::Debug::TraceMessageBus::Handler::BusConnect(); + //AZ::Debug::TraceMessageBus::Handler::BusConnect(); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization( *AZ::SettingsRegistry::Get(), GetBuildTargetName()); @@ -88,7 +88,7 @@ namespace MaterialEditor MaterialEditorApplication::~MaterialEditorApplication() { - AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusDisconnect(); + //AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusDisconnect(); AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusDisconnect(); MaterialEditorWindowNotificationBus::Handler::BusDisconnect(); AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index b7b3e13cca..8b674b154e 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -32,14 +32,13 @@ namespace MaterialEditor class MaterialEditorApplication : public AzFramework::Application - //, public QApplication + , public AzQtComponents::AzQtApplication , private AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler , private MaterialEditorWindowNotificationBus::Handler , private AzFramework::AssetSystemStatusBus::Handler , private AZ::UserSettingsOwnerRequestBus::Handler , private AZ::Debug::TraceMessageBus::Handler , private AzToolsFramework::EditorPythonConsoleNotificationBus::Handler - , public AzQtComponents::ToolsApplication { public: AZ_TYPE_INFO(MaterialEditor::MaterialEditorApplication, "{30F90CA5-1253-49B5-8143-19CEE37E22BB}"); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp index 770dd67116..538d351237 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp @@ -68,7 +68,7 @@ namespace ShaderManagementConsole ShaderManagementConsoleApplication::ShaderManagementConsoleApplication(int* argc, char*** argv) : Application(argc, argv) - , QApplication(*argc, *argv) + , AzQtApplication(*argc, *argv) { // The settings registry has been created at this point, so add the CMake target AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization( diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h index 4ac0549076..fe66292b8d 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h @@ -22,6 +22,8 @@ #include #include +#include + #include #include @@ -29,7 +31,7 @@ namespace ShaderManagementConsole { class ShaderManagementConsoleApplication : public AzFramework::Application - , public QApplication + , public AzQtComponents::AzQtApplication , private AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler , private ShaderManagementConsoleWindowNotificationBus::Handler , private AzFramework::AssetSystemStatusBus::Handler From 5872138671f19383f90b4442328670eb1795d514 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 10 Jun 2021 14:31:28 -0500 Subject: [PATCH 04/37] AzQtApplication 2 Signed-off-by: Dayo Lawal --- .../Application/{ToolsApplication.cpp => AzQtApplication.cpp} | 2 +- .../Application/{ToolsApplication.h => AzQtApplication.h} | 0 .../MaterialEditor/Code/Source/MaterialEditorApplication.h | 2 +- .../Code/Source/ShaderManagementConsoleApplication.h | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename Code/Framework/AzQtComponents/AzQtComponents/Application/{ToolsApplication.cpp => AzQtApplication.cpp} (99%) rename Code/Framework/AzQtComponents/AzQtComponents/Application/{ToolsApplication.h => AzQtApplication.h} (100%) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp similarity index 99% rename from Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp rename to Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index f01e642770..651a8f0430 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -10,7 +10,7 @@ * */ -#include +#include #include // This should be the first include to make sure Windows.h is defined with NOMINMAX diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h similarity index 100% rename from Code/Framework/AzQtComponents/AzQtComponents/Application/ToolsApplication.h rename to Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index 8b674b154e..4f5085c91e 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h index fe66292b8d..72dd689d56 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include From 290567cfd726fa46fadf2e150284a5d2fa2fc89f Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 10 Jun 2021 14:53:47 -0500 Subject: [PATCH 05/37] Fixed cmake, AzQtApplication working with other tools Signed-off-by: Dayo Lawal --- .../AzQtComponents/AzQtComponents/azqtcomponents_files.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index adce70523c..bcfbb84778 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -7,8 +7,8 @@ set(FILES AzQtComponentsAPI.h - Application/ToolsApplication.cpp - Application/ToolsApplication.h + Application/AzQtApplication.cpp + Application/AzQtApplication.h Buses/DragAndDrop.h Buses/ShortcutDispatch.h DragAndDrop/MainWindowDragAndDrop.h From 1cadf34dc3bdc07ee7f2a6c774730a35dcccc375 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 10 Jun 2021 15:28:16 -0500 Subject: [PATCH 06/37] Removing commenting and unnecessary header files Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 75 ------------------- .../Application/AzQtApplication.h | 14 ---- .../Code/Source/MaterialEditorApplication.cpp | 3 - .../Code/Source/MaterialEditorApplication.h | 2 - .../ShaderManagementConsoleApplication.h | 2 - 5 files changed, 96 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 651a8f0430..1e3e559675 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -16,19 +16,8 @@ namespace AzQtComponents { - /* - AZStd::string_view GetBuildTargetName() - { -#if !defined(LY_CMAKE_TARGET) -#error "LY_CMAKE_TARGET must be defined in order to add this source file to a CMake executable target" -#endif - return AZStd::string_view { LY_CMAKE_TARGET }; - } - */ - class AzQtApplication::Impl : private AZ::Debug::TraceMessageBus::Handler - //, public AzFramework::Application { friend class AzQtApplication; @@ -57,7 +46,6 @@ namespace AzQtComponents : QApplication(argc, argv) , m_impl(new Impl(this)) { - // Use a common Qt settings path for applications that don't register their own application name if (QApplication::applicationName().isEmpty()) { @@ -110,69 +98,6 @@ namespace AzQtComponents } return false; } - - /* - bool ToolsApplication::AddDockWidget(const AZStd::string& name, QWidget* widget, uint32_t area, uint32_t orientation) - { - auto dockWidgetItr = m_dockWidgets.find(name); - if (dockWidgetItr != m_dockWidgets.end() || !widget) - { - return false; - } - - auto dockWidget = new AzQtComponents::StyledDockWidget(name.c_str()); - dockWidget->setObjectName(QString("%1_DockWidget").arg(name.c_str())); - dockWidget->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); - widget->setObjectName(name.c_str()); - widget->setParent(dockWidget); - widget->setMinimumSize(QSize(300, 300)); - dockWidget->setWidget(widget); - //QMainWindow::addDockWidget(aznumeric_cast(area), dockWidget); - //QMainWindow::resizeDocks({ dockWidget }, { 400 }, aznumeric_cast(orientation)); - m_dockWidgets[name] = dockWidget; - return true; - } - - void ToolsApplication::RemoveDockWidget(const AZStd::string& name) - { - auto dockWidgetItr = m_dockWidgets.find(name); - if (dockWidgetItr != m_dockWidgets.end()) - { - delete dockWidgetItr->second; - m_dockWidgets.erase(dockWidgetItr); - } - } - - void ToolsApplication::SetDockWidgetVisible(const AZStd::string& name, bool visible) - { - auto dockWidgetItr = m_dockWidgets.find(name); - if (dockWidgetItr != m_dockWidgets.end()) - { - dockWidgetItr->second->setVisible(visible); - } - } - - bool ToolsApplication::IsDockWidgetVisible(const AZStd::string& name) const - { - auto dockWidgetItr = m_dockWidgets.find(name); - if (dockWidgetItr != m_dockWidgets.end()) - { - return dockWidgetItr->second->isVisible(); - } - return false; - } - - AZStd::vector ToolsApplication::GetDockWidgetNames() const - { - AZStd::vector names; - names.reserve(m_dockWidgets.size()); - for (const auto& dockWidgetPair : m_dockWidgets) - { - names.push_back(dockWidgetPair.first); - } - return names; - } - */ } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 40ea888887..c5d205bbec 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -64,20 +64,6 @@ namespace AzQtComponents class Impl; AZStd::unique_ptr m_impl; AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - - //QTimer m_timer; - //void Tick(float deltaOverride = -1.f) override; - - - /* - bool AddDockWidget(const AZStd::string& name, QWidget* widget, uint32_t area, uint32_t orientation); - void RemoveDockWidget(const AZStd::string& name); - void SetDockWidgetVisible(const AZStd::string& name, bool visible); - bool IsDockWidgetVisible(const AZStd::string& name) const; - AZStd::vector GetDockWidgetNames() const; - - AZStd::unordered_map m_dockWidgets; - */ }; } // namespace AzQtComponents diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index cd9f2c9cfd..5681f45feb 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -74,8 +74,6 @@ namespace MaterialEditor : Application(argc, argv) , AzQtApplication(*argc, *argv) { - //AZ::Debug::TraceMessageBus::Handler::BusConnect(); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization( *AZ::SettingsRegistry::Get(), GetBuildTargetName()); @@ -88,7 +86,6 @@ namespace MaterialEditor MaterialEditorApplication::~MaterialEditorApplication() { - //AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusDisconnect(); AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusDisconnect(); MaterialEditorWindowNotificationBus::Handler::BusDisconnect(); AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index 4f5085c91e..a3767a58fb 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -22,8 +22,6 @@ #include #include - -#include #include namespace MaterialEditor diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h index 72dd689d56..2139db45a2 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h @@ -23,8 +23,6 @@ #include #include - -#include #include namespace ShaderManagementConsole From 31a2ccb041b99dba77187372c0cf4c3226394bf3 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 15 Jun 2021 12:40:54 -0500 Subject: [PATCH 07/37] Addressing change requests for pull request Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 16 +++---- .../Application/AzQtApplication.h | 45 ++++++------------- .../Code/Source/MaterialEditorApplication.cpp | 20 +-------- .../Code/Source/MaterialEditorApplication.h | 7 --- 4 files changed, 20 insertions(+), 68 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 1e3e559675..6b01954b23 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -28,15 +28,12 @@ namespace AzQtComponents } AzQtApplication* m_app; - bool OnOutput(const char* window, const char* message) override; + ////////////////////////////////////////////////////////////////////////// + // AZ::Debug::TraceMessageBus::Handler overrides... + bool OnOutput(const char* window, const char* message) override; + ////////////////////////////////////////////////////////////////////////// protected: - struct LogMessage - { - AZStd::string window; - AZStd::string message; - }; - AZStd::vector m_startupLogSink; AZStd::unique_ptr m_logFile; @@ -58,8 +55,8 @@ namespace AzQtComponents QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); - // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays - // on Windows 10 + // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays + // on Windows 10 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); @@ -69,7 +66,6 @@ namespace AzQtComponents m_impl->AZ::Debug::TraceMessageBus::Handler::BusConnect(); - } AzQtApplication::~AzQtApplication() diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index c5d205bbec..426f4cd78c 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -14,41 +14,13 @@ #pragma once #include -#include -#include #include - -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include - -#include #include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include namespace AzQtComponents { @@ -58,13 +30,22 @@ namespace AzQtComponents public: AzQtApplication(int& argc, char** argv); ~AzQtApplication(); - + + private: AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING class Impl; AZStd::unique_ptr m_impl; AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING }; + + class LogMessage + { + public: + AZStd::string window; + AZStd::string message; + }; } // namespace AzQtComponents + diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 5681f45feb..14661b442b 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -88,7 +88,7 @@ namespace MaterialEditor { AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusDisconnect(); MaterialEditorWindowNotificationBus::Handler::BusDisconnect(); - AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); + AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusDisconnect(); } void MaterialEditorApplication::CreateReflectionManager() @@ -281,24 +281,6 @@ namespace MaterialEditor } } - bool MaterialEditorApplication::OnOutput(const char* window, const char* message) - { - // Suppress spam from the Source Control system - if (0 == strncmp(window, AzToolsFramework::SCC_WINDOW, AZ_ARRAY_SIZE(AzToolsFramework::SCC_WINDOW))) - { - return true; - } - - if (m_logFile) - { - m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message); - } - else - { - m_startupLogSink.push_back({ window, message }); - } - return false; - } void MaterialEditorApplication::ProcessCommandLine(const AZ::CommandLine& commandLine) { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index a3767a58fb..337bef47ec 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -96,11 +96,6 @@ namespace MaterialEditor void SaveSettings() override; ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // AZ::Debug::TraceMessageBus::Handler overrides... - bool OnOutput(const char* window, const char* message) override; - ////////////////////////////////////////////////////////////////////////// - void CompileCriticalAssets(); void ProcessCommandLine(const AZ::CommandLine& commandLine); @@ -121,8 +116,6 @@ namespace MaterialEditor AZStd::string message; }; - AZStd::vector m_startupLogSink; - AZStd::unique_ptr m_logFile; //! Local user settings are used to store material browser tree expansion state AZ::UserSettingsProvider m_localUserSettings; From e45028c9d88d3c4c845c6cd44e1696527f5b2456 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 15 Jun 2021 15:12:41 -0500 Subject: [PATCH 08/37] Fixing MaterialEditorApplication Signed-off-by: Dayo Lawal --- .../MaterialEditor/Code/Source/MaterialEditorApplication.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index 337bef47ec..e309a56304 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -116,6 +116,8 @@ namespace MaterialEditor AZStd::string message; }; + AZStd::vector m_startupLogSink; + AZStd::unique_ptr m_logFile; //! Local user settings are used to store material browser tree expansion state AZ::UserSettingsProvider m_localUserSettings; From 60c89d28ccca75f80ea2aea680c7ad1f7c95df4e Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 15 Jun 2021 16:49:31 -0500 Subject: [PATCH 09/37] New class: AzQtTraceLogger Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 56 +------------------ .../Application/AzQtApplication.h | 17 ++---- .../Application/AzQtTraceLogger.cpp | 38 +++++++++++++ .../Application/AzQtTraceLogger.h | 49 ++++++++++++++++ 4 files changed, 93 insertions(+), 67 deletions(-) create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 6b01954b23..ff0154f5e9 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -16,32 +16,10 @@ namespace AzQtComponents { - class AzQtApplication::Impl - : private AZ::Debug::TraceMessageBus::Handler - { - friend class AzQtApplication; - - public: - Impl(AzQtApplication* app) : m_app(app) - { - - } - AzQtApplication* m_app; - - ////////////////////////////////////////////////////////////////////////// - // AZ::Debug::TraceMessageBus::Handler overrides... - bool OnOutput(const char* window, const char* message) override; - ////////////////////////////////////////////////////////////////////////// - - protected: - AZStd::vector m_startupLogSink; - AZStd::unique_ptr m_logFile; - - }; AzQtApplication::AzQtApplication(int& argc, char** argv) : QApplication(argc, argv) - , m_impl(new Impl(this)) + , m_impl(new AzQtTraceLogger) { // Use a common Qt settings path for applications that don't register their own application name if (QApplication::applicationName().isEmpty()) @@ -56,43 +34,13 @@ namespace AzQtComponents QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays - // on Windows 10 + // on Windows 10 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware); - - - m_impl->AZ::Debug::TraceMessageBus::Handler::BusConnect(); - } - - AzQtApplication::~AzQtApplication() - { - m_impl->AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); - } - - - bool AzQtApplication::Impl::OnOutput(const char* window, const char* message) - { - // Suppress spam from the Source Control system - constexpr char sourceControlWindow[] = "Source Control"; - - if (0 == strncmp(window, sourceControlWindow, AZ_ARRAY_SIZE(sourceControlWindow))) - { - return true; - } - - if (m_logFile) - { - m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message); - } - else - { - m_startupLogSink.push_back({ window, message }); - } - return false; } } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 426f4cd78c..cf180ff1cc 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -10,7 +10,6 @@ * */ - #pragma once #include @@ -20,6 +19,7 @@ #include #include #include +#include namespace AzQtComponents @@ -28,23 +28,14 @@ namespace AzQtComponents : public QApplication { public: - AzQtApplication(int& argc, char** argv); - ~AzQtApplication(); - - + AzQtApplication(int& argc, char** argv); private: AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - class Impl; - AZStd::unique_ptr m_impl; + AZStd::unique_ptr m_impl; AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING }; - class LogMessage - { - public: - AZStd::string window; - AZStd::string message; - }; + } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp new file mode 100644 index 0000000000..2e943083b3 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp @@ -0,0 +1,38 @@ +/* + * 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 AzQtComponents +{ + bool AzQtTraceLogger::OnOutput(const char* window, const char* message) + { + // Suppress spam from the Source Control system + constexpr char sourceControlWindow[] = "Source Control"; + + if (0 == strncmp(window, sourceControlWindow, AZ_ARRAY_SIZE(sourceControlWindow))) + { + return true; + } + + if (m_logFile) + { + m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message); + } + else + { + m_startupLogSink.push_back({ window, message }); + } + return false; + } +} // namespace AzQtComponents + diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h new file mode 100644 index 0000000000..f94ce5c809 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h @@ -0,0 +1,49 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + +#pragma once + +#include +#include + +namespace AzQtComponents +{ + class AzQtTraceLogger : private AZ::Debug::TraceMessageBus::Handler + { + public: + AzQtTraceLogger() + { + AZ::Debug::TraceMessageBus::Handler::BusConnect(); + } + ~AzQtTraceLogger() + { + AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); + } + + protected: + ////////////////////////////////////////////////////////////////////////// + // AZ::Debug::TraceMessageBus::Handler overrides... + bool OnOutput(const char* window, const char* message) override; + ////////////////////////////////////////////////////////////////////////// + + struct LogMessage + { + public: + AZStd::string window; + AZStd::string message; + }; + AZStd::vector m_startupLogSink; + AZStd::unique_ptr m_logFile; + }; + +} + From 96153aa8d769d91f703563a43fa89ae645b6b64b Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Wed, 16 Jun 2021 12:17:59 -0500 Subject: [PATCH 10/37] On output change Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtTraceLogger.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp index 2e943083b3..46e8ba8782 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp @@ -16,14 +16,6 @@ namespace AzQtComponents { bool AzQtTraceLogger::OnOutput(const char* window, const char* message) { - // Suppress spam from the Source Control system - constexpr char sourceControlWindow[] = "Source Control"; - - if (0 == strncmp(window, sourceControlWindow, AZ_ARRAY_SIZE(sourceControlWindow))) - { - return true; - } - if (m_logFile) { m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message); From 81c3414cd1617425a3d1f2dd797bb6a1c4feb48f Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Wed, 16 Jun 2021 13:36:02 -0500 Subject: [PATCH 11/37] Adding back OnOutput to MaterialEditor for override Signed-off-by: Dayo Lawal --- .../Code/Source/MaterialEditorApplication.cpp | 18 ++++++++++++++++++ .../Code/Source/MaterialEditorApplication.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 14661b442b..f6be1d9d5a 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -281,6 +281,24 @@ namespace MaterialEditor } } + bool MaterialEditorApplication::OnOutput(const char* window, const char* message) + { + // Suppress spam from the Source Control system + if (0 == strncmp(window, AzToolsFramework::SCC_WINDOW, AZ_ARRAY_SIZE(AzToolsFramework::SCC_WINDOW))) + { + return true; + } + + if (m_logFile) + { + m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message); + } + else + { + m_startupLogSink.push_back({ window, message }); + } + return false; + } void MaterialEditorApplication::ProcessCommandLine(const AZ::CommandLine& commandLine) { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index e309a56304..f6ad0010d8 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -96,6 +96,11 @@ namespace MaterialEditor void SaveSettings() override; ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // AZ::Debug::TraceMessageBus::Handler overrides... + bool OnOutput(const char* window, const char* message) override; + ////////////////////////////////////////////////////////////////////////// + void CompileCriticalAssets(); void ProcessCommandLine(const AZ::CommandLine& commandLine); From ecede42501072134bd87157a1f18f937d8e0f1c2 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 17 Jun 2021 13:31:19 -0500 Subject: [PATCH 12/37] Fixing logging and cleaning up AzQtApplication Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 3 +- .../Application/AzQtApplication.h | 13 ++--- .../Application/AzQtTraceLogger.cpp | 49 +++++++++++++++++++ .../Application/AzQtTraceLogger.h | 12 ++--- .../Code/Source/MaterialEditorApplication.h | 2 +- 5 files changed, 60 insertions(+), 19 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index ff0154f5e9..67c72f6e5d 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -13,13 +13,14 @@ #include #include // This should be the first include to make sure Windows.h is defined with NOMINMAX +#include namespace AzQtComponents { AzQtApplication::AzQtApplication(int& argc, char** argv) : QApplication(argc, argv) - , m_impl(new AzQtTraceLogger) + , m_traceLogger(new AzQtTraceLogger) { // Use a common Qt settings path for applications that don't register their own application name if (QApplication::applicationName().isEmpty()) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index cf180ff1cc..32221836c1 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -14,13 +14,8 @@ #include -#include -#include -#include -#include -#include #include - +#include namespace AzQtComponents { @@ -28,14 +23,14 @@ namespace AzQtComponents : public QApplication { public: - AzQtApplication(int& argc, char** argv); + AzQtApplication(int& argc, char** argv); + private: AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - AZStd::unique_ptr m_impl; + AZStd::unique_ptr m_traceLogger; AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING }; - } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp index 46e8ba8782..f5fddf3689 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp @@ -12,8 +12,21 @@ #include +#include +#include + namespace AzQtComponents { + AzQtTraceLogger::AzQtTraceLogger() + { + AZ::Debug::TraceMessageBus::Handler::BusConnect(); + } + + AzQtTraceLogger::~AzQtTraceLogger() + { + AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); + } + bool AzQtTraceLogger::OnOutput(const char* window, const char* message) { if (m_logFile) @@ -26,5 +39,41 @@ namespace AzQtComponents } return false; } + + void AzQtTraceLogger::WriteStartupLog() + { + using namespace AzFramework; + + AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); + AZ_Assert(fileIO != nullptr, "FileIO should be running at this point"); + + // There is no log system online so we have to create your own log file. + char resolveBuffer[AZ_MAX_PATH_LEN] = { 0 }; + fileIO->ResolvePath("@user@", resolveBuffer, AZ_MAX_PATH_LEN); + + // Note: @log@ hasn't been set at this point + AZStd::string logDirectory; + StringFunc::Path::Join(resolveBuffer, "log", logDirectory); + fileIO->SetAlias("@log@", logDirectory.c_str()); + + fileIO->CreatePath("@root@"); + fileIO->CreatePath("@user@"); + fileIO->CreatePath("@log@"); + + AZStd::string logPath; + StringFunc::Path::Join(logDirectory.c_str(), "MaterialEditor.log", logPath); + + m_logFile.reset(aznew LogFile(logPath.c_str())); + if (m_logFile) + { + m_logFile->SetMachineReadable(false); + for (const LogMessage& message : m_startupLogSink) + { + m_logFile->AppendLog(LogFile::SEV_NORMAL, message.window.c_str(), message.message.c_str()); + } + m_startupLogSink = {}; + m_logFile->FlushLog(); + } + } } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h index f94ce5c809..505da253c5 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h @@ -20,14 +20,8 @@ namespace AzQtComponents class AzQtTraceLogger : private AZ::Debug::TraceMessageBus::Handler { public: - AzQtTraceLogger() - { - AZ::Debug::TraceMessageBus::Handler::BusConnect(); - } - ~AzQtTraceLogger() - { - AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); - } + AzQtTraceLogger(); + ~AzQtTraceLogger(); protected: ////////////////////////////////////////////////////////////////////////// @@ -35,6 +29,8 @@ namespace AzQtComponents bool OnOutput(const char* window, const char* message) override; ////////////////////////////////////////////////////////////////////////// + void WriteStartupLog(); + struct LogMessage { public: diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index f6ad0010d8..f5431ddd96 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -99,7 +99,7 @@ namespace MaterialEditor ////////////////////////////////////////////////////////////////////////// // AZ::Debug::TraceMessageBus::Handler overrides... bool OnOutput(const char* window, const char* message) override; - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// void CompileCriticalAssets(); From f93018507793be0e3246448a6cb51eb10e9f71b8 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 17 Jun 2021 15:44:48 -0500 Subject: [PATCH 13/37] WriteStartupLog() implemented in base class (unresolved external) Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtApplication.cpp | 7 ++++++- .../AzQtComponents/Application/AzQtApplication.h | 3 ++- .../AzQtComponents/Application/AzQtTraceLogger.cpp | 4 ++-- .../AzQtComponents/Application/AzQtTraceLogger.h | 5 ++--- .../Code/Source/MaterialEditorApplication.cpp | 2 +- .../Code/Source/ShaderManagementConsoleApplication.cpp | 2 ++ .../Tools/ShaderManagementConsole/Code/Source/main.cpp | 4 ++++ 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 67c72f6e5d..0102bb62d1 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -34,7 +34,12 @@ namespace AzQtComponents QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); - // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays + + } + + void AzQtApplication::setDpiScaling() + { + // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays // on Windows 10 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 32221836c1..0a7bfc8d27 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -24,8 +24,9 @@ namespace AzQtComponents { public: AzQtApplication(int& argc, char** argv); + void static setDpiScaling(); - private: + protected: AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING AZStd::unique_ptr m_traceLogger; AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp index f5fddf3689..da6254f018 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp @@ -40,7 +40,7 @@ namespace AzQtComponents return false; } - void AzQtTraceLogger::WriteStartupLog() + void AzQtTraceLogger::WriteStartupLog(char name[]) { using namespace AzFramework; @@ -61,7 +61,7 @@ namespace AzQtComponents fileIO->CreatePath("@log@"); AZStd::string logPath; - StringFunc::Path::Join(logDirectory.c_str(), "MaterialEditor.log", logPath); + StringFunc::Path::Join(logDirectory.c_str(), name, logPath); m_logFile.reset(aznew LogFile(logPath.c_str())); if (m_logFile) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h index 505da253c5..29dfd6b32a 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h @@ -23,14 +23,14 @@ namespace AzQtComponents AzQtTraceLogger(); ~AzQtTraceLogger(); + void WriteStartupLog(char name[]); + protected: ////////////////////////////////////////////////////////////////////////// // AZ::Debug::TraceMessageBus::Handler overrides... bool OnOutput(const char* window, const char* message) override; ////////////////////////////////////////////////////////////////////////// - void WriteStartupLog(); - struct LogMessage { public: @@ -40,6 +40,5 @@ namespace AzQtComponents AZStd::vector m_startupLogSink; AZStd::unique_ptr m_logFile; }; - } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index f6be1d9d5a..2cc2bb852e 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -476,7 +476,7 @@ namespace MaterialEditor return; } - WriteStartupLog(); + m_traceLogger->WriteStartupLog("MaterialEditor.log"); if (!LaunchDiscoveryService()) { diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp index 538d351237..e59bbde17d 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp @@ -39,6 +39,8 @@ #include #include +#include + AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT #include #include diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp index d3130cd28a..ed5537e93d 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -39,7 +40,10 @@ int main(int argc, char** argv) QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::PerScreenDpiAware); + AzQtComponents::AzQtApplication::setDpiScaling(); + ShaderManagementConsole::ShaderManagementConsoleApplication app(&argc, &argv); + AZ::IO::FixedMaxPath engineRootPath; if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr) { From df18e53ab4c988887f8b591a99c9a8e8fa75d38b Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Mon, 21 Jun 2021 10:48:51 -0500 Subject: [PATCH 14/37] WriteStartupLog() not implemented Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 3 +- .../Application/AzQtTraceLogger.cpp | 51 ++++++++++++++++--- .../Application/AzQtTraceLogger.h | 25 +++------ .../AzQtComponents/azqtcomponents_files.cmake | 2 + .../Code/Source/MaterialEditorApplication.cpp | 7 +-- .../Code/Source/MaterialEditorApplication.h | 2 + 6 files changed, 59 insertions(+), 31 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 0102bb62d1..b8bfc7a5d5 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -33,8 +33,7 @@ namespace AzQtComponents AzQtComponents::PrepareQtPaths(); QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); - - + } void AzQtApplication::setDpiScaling() diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp index da6254f018..3883669e6e 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp @@ -12,22 +12,58 @@ #include -#include #include +#include +#include + namespace AzQtComponents { - AzQtTraceLogger::AzQtTraceLogger() + class AzQtTraceLogger::Impl : public AZ::Debug::TraceMessageBus::Handler + { + public: + void WriteStartupLog(char name[]); + + Impl() + { + AZ::Debug::TraceMessageBus::Handler::BusConnect(); + } + ~Impl() + { + AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); + } + + protected: + ////////////////////////////////////////////////////////////////////////// + // AZ::Debug::TraceMessageBus::Handler overrides... + bool OnOutput(const char* window, const char* message) override; + ////////////////////////////////////////////////////////////////////////// + + struct LogMessage + { + public: + AZStd::string window; + AZStd::string message; + }; + AZStd::vector m_startupLogSink; + AZStd::unique_ptr m_logFile; + }; + + AzQtTraceLogger::AzQtTraceLogger() + : m_impl(new Impl) { - AZ::Debug::TraceMessageBus::Handler::BusConnect(); } AzQtTraceLogger::~AzQtTraceLogger() { - AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); } - - bool AzQtTraceLogger::OnOutput(const char* window, const char* message) + + void AzQtTraceLogger::WriteStartupLog(char name[]) + { + m_impl->WriteStartupLog(name); + } + + bool AzQtTraceLogger::Impl::OnOutput(const char* window, const char* message) { if (m_logFile) { @@ -40,7 +76,7 @@ namespace AzQtComponents return false; } - void AzQtTraceLogger::WriteStartupLog(char name[]) + void AzQtTraceLogger::Impl::WriteStartupLog(char name[]) { using namespace AzFramework; @@ -76,4 +112,3 @@ namespace AzQtComponents } } } // namespace AzQtComponents - diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h index 29dfd6b32a..2207cfce4f 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h @@ -12,33 +12,22 @@ #pragma once -#include #include +#include namespace AzQtComponents { - class AzQtTraceLogger : private AZ::Debug::TraceMessageBus::Handler + class AZ_QT_COMPONENTS_API AzQtTraceLogger { public: AzQtTraceLogger(); ~AzQtTraceLogger(); - void WriteStartupLog(char name[]); protected: - ////////////////////////////////////////////////////////////////////////// - // AZ::Debug::TraceMessageBus::Handler overrides... - bool OnOutput(const char* window, const char* message) override; - ////////////////////////////////////////////////////////////////////////// - - struct LogMessage - { - public: - AZStd::string window; - AZStd::string message; - }; - AZStd::vector m_startupLogSink; - AZStd::unique_ptr m_logFile; + class Impl; + AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING + AZStd::unique_ptr m_impl; + AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING }; -} - +} // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index bcfbb84778..c9a025d472 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -9,6 +9,8 @@ set(FILES AzQtComponentsAPI.h Application/AzQtApplication.cpp Application/AzQtApplication.h + Application/AzQtTraceLogger.cpp + Application/AzQtTraceLogger.h Buses/DragAndDrop.h Buses/ShortcutDispatch.h DragAndDrop/MainWindowDragAndDrop.h diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 2cc2bb852e..e20274da81 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -352,7 +352,7 @@ namespace MaterialEditor ExitMainLoop(); } } - + ///* void MaterialEditorApplication::WriteStartupLog() { using namespace AzFramework; @@ -388,7 +388,7 @@ namespace MaterialEditor m_logFile->FlushLog(); } } - + //*/ void MaterialEditorApplication::LoadSettings() { AZ::SerializeContext* context = nullptr; @@ -476,7 +476,8 @@ namespace MaterialEditor return; } - m_traceLogger->WriteStartupLog("MaterialEditor.log"); + //m_traceLogger->WriteStartupLog("MaterialEditor.log"); + WriteStartupLog(); if (!LaunchDiscoveryService()) { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index f5431ddd96..5d689a67ec 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -22,6 +22,8 @@ #include #include +#include + #include namespace MaterialEditor From b365f8bddf5f1cb173f47eac2fcde0affe3ced4a Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Mon, 21 Jun 2021 18:01:16 -0500 Subject: [PATCH 15/37] Fixing problem with FileIO (exception in Environment.h) Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtTraceLogger.cpp | 10 ++++++---- .../Code/Source/MaterialEditorApplication.cpp | 8 ++++---- .../Code/Source/MaterialEditorApplication.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp index 3883669e6e..6084d555e7 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp @@ -16,7 +16,6 @@ #include #include - namespace AzQtComponents { class AzQtTraceLogger::Impl : public AZ::Debug::TraceMessageBus::Handler @@ -78,11 +77,13 @@ namespace AzQtComponents void AzQtTraceLogger::Impl::WriteStartupLog(char name[]) { - using namespace AzFramework; - + std::string temp = name; + + //using namespace AzFramework; + ///* AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); AZ_Assert(fileIO != nullptr, "FileIO should be running at this point"); - + /* // There is no log system online so we have to create your own log file. char resolveBuffer[AZ_MAX_PATH_LEN] = { 0 }; fileIO->ResolvePath("@user@", resolveBuffer, AZ_MAX_PATH_LEN); @@ -110,5 +111,6 @@ namespace AzQtComponents m_startupLogSink = {}; m_logFile->FlushLog(); } + */ } } // namespace AzQtComponents diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index e20274da81..75875d07de 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -352,7 +352,7 @@ namespace MaterialEditor ExitMainLoop(); } } - ///* + /* void MaterialEditorApplication::WriteStartupLog() { using namespace AzFramework; @@ -388,7 +388,7 @@ namespace MaterialEditor m_logFile->FlushLog(); } } - //*/ + */ void MaterialEditorApplication::LoadSettings() { AZ::SerializeContext* context = nullptr; @@ -476,8 +476,8 @@ namespace MaterialEditor return; } - //m_traceLogger->WriteStartupLog("MaterialEditor.log"); - WriteStartupLog(); + m_traceLogger->WriteStartupLog("MaterialEditor.log"); + //WriteStartupLog(); if (!LaunchDiscoveryService()) { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index 5d689a67ec..8b49f017c0 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -106,7 +106,7 @@ namespace MaterialEditor void CompileCriticalAssets(); void ProcessCommandLine(const AZ::CommandLine& commandLine); - void WriteStartupLog(); + //void WriteStartupLog(); void LoadSettings(); void UnloadSettings(); From 6f44393f3a1693fd5b8044dca6deb2a43155d434 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 22 Jun 2021 14:31:39 -0500 Subject: [PATCH 16/37] Moved logging to AzToolsFramework, working with MatEditor and SMC Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 1 - .../Application/AzQtApplication.h | 4 -- .../AzQtComponents/azqtcomponents_files.cmake | 2 - .../Logger}/AzQtTraceLogger.cpp | 61 ++++--------------- .../Logger}/AzQtTraceLogger.h | 25 +++++--- .../aztoolsframework_files.cmake | 2 + .../Code/Source/MaterialEditorApplication.cpp | 39 +----------- .../Code/Source/MaterialEditorApplication.h | 6 +- .../ShaderManagementConsoleApplication.cpp | 4 +- .../ShaderManagementConsoleApplication.h | 4 ++ 10 files changed, 41 insertions(+), 107 deletions(-) rename Code/Framework/{AzQtComponents/AzQtComponents/Application => AzToolsFramework/AzToolsFramework/Logger}/AzQtTraceLogger.cpp (62%) rename Code/Framework/{AzQtComponents/AzQtComponents/Application => AzToolsFramework/AzToolsFramework/Logger}/AzQtTraceLogger.h (50%) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index b8bfc7a5d5..73c7fe7aba 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -20,7 +20,6 @@ namespace AzQtComponents AzQtApplication::AzQtApplication(int& argc, char** argv) : QApplication(argc, argv) - , m_traceLogger(new AzQtTraceLogger) { // Use a common Qt settings path for applications that don't register their own application name if (QApplication::applicationName().isEmpty()) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 0a7bfc8d27..37d33468b5 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -14,7 +14,6 @@ #include -#include #include namespace AzQtComponents @@ -27,9 +26,6 @@ namespace AzQtComponents void static setDpiScaling(); protected: - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - AZStd::unique_ptr m_traceLogger; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING }; } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index c9a025d472..bcfbb84778 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -9,8 +9,6 @@ set(FILES AzQtComponentsAPI.h Application/AzQtApplication.cpp Application/AzQtApplication.h - Application/AzQtTraceLogger.cpp - Application/AzQtTraceLogger.h Buses/DragAndDrop.h Buses/ShortcutDispatch.h DragAndDrop/MainWindowDragAndDrop.h diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp similarity index 62% rename from Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp rename to Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp index 6084d555e7..d9f9a444ee 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp @@ -10,59 +10,25 @@ * */ -#include +#include #include #include -#include -namespace AzQtComponents + +namespace AzToolsFramework { - class AzQtTraceLogger::Impl : public AZ::Debug::TraceMessageBus::Handler - { - public: - void WriteStartupLog(char name[]); - - Impl() - { - AZ::Debug::TraceMessageBus::Handler::BusConnect(); - } - ~Impl() - { - AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); - } - - protected: - ////////////////////////////////////////////////////////////////////////// - // AZ::Debug::TraceMessageBus::Handler overrides... - bool OnOutput(const char* window, const char* message) override; - ////////////////////////////////////////////////////////////////////////// - - struct LogMessage - { - public: - AZStd::string window; - AZStd::string message; - }; - AZStd::vector m_startupLogSink; - AZStd::unique_ptr m_logFile; - }; - AzQtTraceLogger::AzQtTraceLogger() - : m_impl(new Impl) { + AZ::Debug::TraceMessageBus::Handler::BusConnect(); } AzQtTraceLogger::~AzQtTraceLogger() { + AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); } - void AzQtTraceLogger::WriteStartupLog(char name[]) - { - m_impl->WriteStartupLog(name); - } - - bool AzQtTraceLogger::Impl::OnOutput(const char* window, const char* message) + bool AzQtTraceLogger::OnOutput(const char* window, const char* message) { if (m_logFile) { @@ -75,15 +41,13 @@ namespace AzQtComponents return false; } - void AzQtTraceLogger::Impl::WriteStartupLog(char name[]) - { - std::string temp = name; - - //using namespace AzFramework; - ///* + void AzQtTraceLogger::WriteStartupLog(char name[]) + { + using namespace AzFramework; + AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); AZ_Assert(fileIO != nullptr, "FileIO should be running at this point"); - /* + // There is no log system online so we have to create your own log file. char resolveBuffer[AZ_MAX_PATH_LEN] = { 0 }; fileIO->ResolvePath("@user@", resolveBuffer, AZ_MAX_PATH_LEN); @@ -111,6 +75,5 @@ namespace AzQtComponents m_startupLogSink = {}; m_logFile->FlushLog(); } - */ } -} // namespace AzQtComponents +} // namespace AzToolsFramework diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h similarity index 50% rename from Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h rename to Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h index 2207cfce4f..50655dfcda 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtTraceLogger.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h @@ -13,11 +13,11 @@ #pragma once #include -#include +#include -namespace AzQtComponents +namespace AzToolsFramework { - class AZ_QT_COMPONENTS_API AzQtTraceLogger + class AzQtTraceLogger : public AZ::Debug::TraceMessageBus::Handler { public: AzQtTraceLogger(); @@ -25,9 +25,18 @@ namespace AzQtComponents void WriteStartupLog(char name[]); protected: - class Impl; - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING - AZStd::unique_ptr m_impl; - AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING + ////////////////////////////////////////////////////////////////////////// + // AZ::Debug::TraceMessageBus::Handler overrides... + bool OnOutput(const char* window, const char* message) override; + ////////////////////////////////////////////////////////////////////////// + + struct LogMessage + { + public: + AZStd::string window; + AZStd::string message; + }; + AZStd::vector m_startupLogSink; + AZStd::unique_ptr m_logFile; }; -} // namespace AzQtComponents +} // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake index 7fbde67ce4..5718de48ab 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake @@ -147,6 +147,8 @@ set(FILES Entity/SliceEditorEntityOwnershipServiceBus.h Fingerprinting/TypeFingerprinter.h Fingerprinting/TypeFingerprinter.cpp + Logger/AzQtTraceLogger.cpp + Logger/AzQtTraceLogger.h Manipulators/AngularManipulator.cpp Manipulators/AngularManipulator.h Manipulators/BaseManipulator.cpp diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 75875d07de..25e23ad1e5 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -352,43 +352,7 @@ namespace MaterialEditor ExitMainLoop(); } } - /* - void MaterialEditorApplication::WriteStartupLog() - { - using namespace AzFramework; - AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); - AZ_Assert(fileIO != nullptr, "FileIO should be running at this point"); - - // There is no log system online so we have to create your own log file. - char resolveBuffer[AZ_MAX_PATH_LEN] = { 0 }; - fileIO->ResolvePath("@user@", resolveBuffer, AZ_MAX_PATH_LEN); - - // Note: @log@ hasn't been set at this point - AZStd::string logDirectory; - StringFunc::Path::Join(resolveBuffer, "log", logDirectory); - fileIO->SetAlias("@log@", logDirectory.c_str()); - - fileIO->CreatePath("@root@"); - fileIO->CreatePath("@user@"); - fileIO->CreatePath("@log@"); - - AZStd::string logPath; - StringFunc::Path::Join(logDirectory.c_str(), "MaterialEditor.log", logPath); - - m_logFile.reset(aznew LogFile(logPath.c_str())); - if (m_logFile) - { - m_logFile->SetMachineReadable(false); - for (const LogMessage& message : m_startupLogSink) - { - m_logFile->AppendLog(LogFile::SEV_NORMAL, message.window.c_str(), message.message.c_str()); - } - m_startupLogSink = {}; - m_logFile->FlushLog(); - } - } - */ void MaterialEditorApplication::LoadSettings() { AZ::SerializeContext* context = nullptr; @@ -476,8 +440,7 @@ namespace MaterialEditor return; } - m_traceLogger->WriteStartupLog("MaterialEditor.log"); - //WriteStartupLog(); + m_traceLogger.WriteStartupLog("MaterialEditor.log"); if (!LaunchDiscoveryService()) { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index 8b49f017c0..ff0809897d 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -20,9 +20,8 @@ #include #include #include - +#include #include -#include #include @@ -106,7 +105,6 @@ namespace MaterialEditor void CompileCriticalAssets(); void ProcessCommandLine(const AZ::CommandLine& commandLine); - //void WriteStartupLog(); void LoadSettings(); void UnloadSettings(); @@ -126,6 +124,8 @@ namespace MaterialEditor AZStd::vector m_startupLogSink; AZStd::unique_ptr m_logFile; + AzToolsFramework::AzQtTraceLogger m_traceLogger; + //! Local user settings are used to store material browser tree expansion state AZ::UserSettingsProvider m_localUserSettings; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp index e59bbde17d..5f330053b0 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp @@ -39,8 +39,6 @@ #include #include -#include - AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT #include #include @@ -345,6 +343,8 @@ namespace ShaderManagementConsole return; } + m_traceLogger.WriteStartupLog("ShaderManagementConsole.log"); + //[GFX TODO][ATOM-415] Try to factor out some of this stuff with AtomSampleViewerApplication AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusConnect(); AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotificationBus::Broadcast(&AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotifications::OnDatabaseInitialized); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h index 2139db45a2..9b7de38f0a 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h @@ -18,11 +18,13 @@ #include #include +#include #include #include #include + #include namespace ShaderManagementConsole @@ -113,6 +115,8 @@ namespace ShaderManagementConsole static void PyIdleWaitFrames(uint32_t frames); + AzToolsFramework::AzQtTraceLogger m_traceLogger; + //! Local user settings are used to store asset browser tree expansion state AZ::UserSettingsProvider m_localUserSettings; From c63c42c7f4a41437c2bdc9efb821a5fc096287bd Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 24 Jun 2021 14:49:09 -0500 Subject: [PATCH 17/37] Adding comments and changing QApplication org/app names Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 15 ++++----------- .../AzQtComponents/Application/AzQtApplication.h | 5 ++++- .../AzToolsFramework/Logger/AzQtTraceLogger.cpp | 4 ++-- .../AzToolsFramework/Logger/AzQtTraceLogger.h | 5 ++++- .../Code/Source/MaterialEditorApplication.cpp | 2 ++ .../Source/ShaderManagementConsoleApplication.cpp | 2 ++ 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 73c7fe7aba..7d6392bc57 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -22,24 +22,17 @@ namespace AzQtComponents : QApplication(argc, argv) { // Use a common Qt settings path for applications that don't register their own application name - if (QApplication::applicationName().isEmpty()) - { - QApplication::setOrganizationName("Amazon"); - QApplication::setOrganizationDomain("amazon.com"); - QApplication::setApplicationName("O3DEToolsApplication"); - } + QApplication::setOrganizationName("O3DE"); + QApplication::setOrganizationDomain("o3de.com"); + QApplication::setApplicationName("O3DEToolsApplication"); AzQtComponents::PrepareQtPaths(); QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); - } void AzQtApplication::setDpiScaling() - { - // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays - // on Windows 10 - + { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 37d33468b5..92f9d0f6dc 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -23,7 +23,10 @@ namespace AzQtComponents { public: AzQtApplication(int& argc, char** argv); - void static setDpiScaling(); + + //! DPI Scaling so that we support HighDpi monitors, like the Retina displays on Windows 10 + //! Must be set before QApplication is initialized, + static void setDpiScaling(); protected: }; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp index d9f9a444ee..f795719062 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp @@ -41,7 +41,7 @@ namespace AzToolsFramework return false; } - void AzQtTraceLogger::WriteStartupLog(char name[]) + void AzQtTraceLogger::WriteStartupLog(const AZStd::string& logFileName) { using namespace AzFramework; @@ -62,7 +62,7 @@ namespace AzToolsFramework fileIO->CreatePath("@log@"); AZStd::string logPath; - StringFunc::Path::Join(logDirectory.c_str(), name, logPath); + StringFunc::Path::Join(logDirectory.c_str(), logFileName.c_str(), logPath); m_logFile.reset(aznew LogFile(logPath.c_str())); if (m_logFile) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h index 50655dfcda..1a054513cd 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h @@ -17,12 +17,15 @@ namespace AzToolsFramework { + // Connects and disconnects TraceMessageBus and allows for logging for O3DEToolsApplications class AzQtTraceLogger : public AZ::Debug::TraceMessageBus::Handler { public: AzQtTraceLogger(); ~AzQtTraceLogger(); - void WriteStartupLog(char name[]); + + //! Intalize logging for O3DEToolsApplications + void WriteStartupLog(const AZStd::string& logFileName); protected: ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 25e23ad1e5..931051a7c4 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -74,6 +74,8 @@ namespace MaterialEditor : Application(argc, argv) , AzQtApplication(*argc, *argv) { + QApplication::setApplicationName("O3DE MaterialEditor"); + AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization( *AZ::SettingsRegistry::Get(), GetBuildTargetName()); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp index 5f330053b0..62493b8f84 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp @@ -70,6 +70,8 @@ namespace ShaderManagementConsole : Application(argc, argv) , AzQtApplication(*argc, *argv) { + QApplication::setApplicationName("O3DE ShaderManagementConsole"); + // The settings registry has been created at this point, so add the CMake target AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization( *AZ::SettingsRegistry::Get(), GetBuildTargetName()); From c86535f892702cf01e616e7aaf6f00d8aac23c64 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 24 Jun 2021 17:22:40 -0500 Subject: [PATCH 18/37] Styling fixes Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtApplication.cpp | 2 +- .../AzQtComponents/Application/AzQtApplication.h | 5 ++--- .../AzToolsFramework/Logger/AzQtTraceLogger.h | 2 +- .../MaterialEditor/Code/Source/MaterialEditorApplication.cpp | 2 +- .../Code/Source/ShaderManagementConsoleApplication.cpp | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 7d6392bc57..32389e78cc 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -31,7 +31,7 @@ namespace AzQtComponents QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); } - void AzQtApplication::setDpiScaling() + void AzQtApplication::SetDpiScaling() { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 92f9d0f6dc..85e4400c31 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -18,6 +18,7 @@ namespace AzQtComponents { + //! Base case for O3DE Tools Applications class AZ_QT_COMPONENTS_API AzQtApplication : public QApplication { @@ -26,9 +27,7 @@ namespace AzQtComponents //! DPI Scaling so that we support HighDpi monitors, like the Retina displays on Windows 10 //! Must be set before QApplication is initialized, - static void setDpiScaling(); - - protected: + static void SetDpiScaling(); }; } // namespace AzQtComponents diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h index 1a054513cd..9518c6842d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h @@ -17,7 +17,7 @@ namespace AzToolsFramework { - // Connects and disconnects TraceMessageBus and allows for logging for O3DEToolsApplications + //! Connects and disconnects TraceMessageBus and allows for logging for O3DE Tools Applications class AzQtTraceLogger : public AZ::Debug::TraceMessageBus::Handler { public: diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 931051a7c4..f880ad7680 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -74,7 +74,7 @@ namespace MaterialEditor : Application(argc, argv) , AzQtApplication(*argc, *argv) { - QApplication::setApplicationName("O3DE MaterialEditor"); + QApplication::setApplicationName("O3DE Material Editor"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization( *AZ::SettingsRegistry::Get(), GetBuildTargetName()); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp index 62493b8f84..f5ee1f5bcb 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp @@ -70,7 +70,7 @@ namespace ShaderManagementConsole : Application(argc, argv) , AzQtApplication(*argc, *argv) { - QApplication::setApplicationName("O3DE ShaderManagementConsole"); + QApplication::setApplicationName("O3DE Shader Management Console"); // The settings registry has been created at this point, so add the CMake target AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization( From 656a4bb09785f6eaf5a203f93cb6af686f55efff Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Fri, 25 Jun 2021 11:43:17 -0500 Subject: [PATCH 19/37] o3de.com to o3de.org Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtApplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 32389e78cc..3459656960 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -23,7 +23,7 @@ namespace AzQtComponents { // Use a common Qt settings path for applications that don't register their own application name QApplication::setOrganizationName("O3DE"); - QApplication::setOrganizationDomain("o3de.com"); + QApplication::setOrganizationDomain("o3de.org"); QApplication::setApplicationName("O3DEToolsApplication"); AzQtComponents::PrepareQtPaths(); From 27466154be97acb62b84656b5b63dcd2cf274f28 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Fri, 9 Jul 2021 15:10:20 -0500 Subject: [PATCH 20/37] AzQtApplication Window Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.h | 2 +- .../Window/AzQtApplicationWindow.cpp | 61 +++++++++++++ .../Window/AzQtApplicationWindow.h | 89 +++++++++++++++++++ .../AzQtComponents/azqtcomponents_files.cmake | 2 + .../Source/Window/MaterialEditorWindow.cpp | 44 +-------- .../Code/Source/Window/MaterialEditorWindow.h | 43 ++------- .../ShaderManagementConsoleApplication.cpp | 2 - .../Window/ShaderManagementConsoleWindow.cpp | 43 ++------- .../Window/ShaderManagementConsoleWindow.h | 44 ++------- 9 files changed, 175 insertions(+), 155 deletions(-) create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 85e4400c31..60d582a50a 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -18,7 +18,7 @@ namespace AzQtComponents { - //! Base case for O3DE Tools Applications + //! Base class for O3DE Tools Applications class AZ_QT_COMPONENTS_API AzQtApplication : public QApplication { diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp new file mode 100644 index 0000000000..b2dc0cf429 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp @@ -0,0 +1,61 @@ +/* +* 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 + + +namespace AzQtComponents +{ + AzQtApplicationWindow::AzQtApplicationWindow(QWidget* parent /* = 0 */, const AZStd::string& objectName) + : AzQtComponents::DockMainWindow(parent) + { + m_advancedDockManager = new AzQtComponents::FancyDocking(this); + + setObjectName(objectName.c_str()); + setDockNestingEnabled(true); + setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); + setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + + m_menuBar = new QMenuBar(this); + m_menuBar->setObjectName("MenuBar"); + setMenuBar(m_menuBar); + + m_centralWidget = new QWidget(this); + m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget); + m_tabWidget->setObjectName("TabWidget"); + m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); + m_tabWidget->setContentsMargins(0, 0, 0, 0); + + vl = new QVBoxLayout(m_centralWidget); + } + + void AzQtApplicationWindow::SelectPreviousTab() + { + if (m_tabWidget->count() > 1) + { + // Adding count to wrap around when index <= 0 + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); + } + } + + void AzQtApplicationWindow::SelectNextTab() + { + if (m_tabWidget->count() > 1) + { + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); + } + } +} + diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h new file mode 100644 index 0000000000..87d251f983 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h @@ -0,0 +1,89 @@ +/* + * 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 + +#if !defined(Q_MOC_RUN) +#include +#include +#include +#include + +AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT +#include +#include +#include +#include + +#include +#include +#include +#include +AZ_POP_DISABLE_WARNING +#endif + +namespace AzQtComponents +{ + /** + * //! Base class for O3DE Tools Applications Windows. Its responsibility is limited to initializing and connecting + * its panels, managing selection of assets, and performing high-level actions like saving. It contains... + */ + class AZ_QT_COMPONENTS_API AzQtApplicationWindow + : public AzQtComponents::DockMainWindow + { + Q_OBJECT + public: + AzQtApplicationWindow(QWidget* parent, const AZStd::string& objectName); + + protected: + virtual void SetupMenu() {}; + virtual void SetupTabs() {}; + + virtual void OpenTabContextMenu() {}; + + void SelectPreviousTab(); + void SelectNextTab(); + + AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; + QMenuBar* m_menuBar = nullptr; + QWidget* m_centralWidget = nullptr; + AzQtComponents::TabWidget* m_tabWidget = nullptr; + + QVBoxLayout* vl; + + QMenu* m_menuFile = {}; + QAction* m_actionOpen = {}; + QAction* m_actionOpenRecent = {}; + QAction* m_actionClose = {}; + QAction* m_actionCloseAll = {}; + QAction* m_actionCloseOthers = {}; + QAction* m_actionSave = {}; + QAction* m_actionSaveAsCopy = {}; + QAction* m_actionSaveAll = {}; + QAction* m_actionExit = {}; + + QMenu* m_menuEdit = {}; + QAction* m_actionUndo = {}; + QAction* m_actionRedo = {}; + QAction* m_actionSettings = {}; + + QMenu* m_menuView = {}; + QAction* m_actionAssetBrowser = {}; + QAction* m_actionPythonTerminal = {}; + QAction* m_actionNextTab = {}; + QAction* m_actionPreviousTab = {}; + + QMenu* m_menuHelp = {}; + QAction* m_actionHelp = {}; + QAction* m_actionAbout = {}; + }; +} // namespace ShaderManagementConsole diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index bcfbb84778..98882c5132 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -9,6 +9,8 @@ set(FILES AzQtComponentsAPI.h Application/AzQtApplication.cpp Application/AzQtApplication.h + Application/Window/AzQtApplicationWindow.cpp + Application/Window/AzQtApplicationWindow.h Buses/DragAndDrop.h Buses/ShortcutDispatch.h DragAndDrop/MainWindowDragAndDrop.h diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp index 7c3a912b95..3e39526689 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp @@ -55,7 +55,7 @@ AZ_POP_DISABLE_WARNING namespace MaterialEditor { MaterialEditorWindow::MaterialEditorWindow(QWidget* parent /* = 0 */) - : AzQtComponents::DockMainWindow(parent) + : AzQtComponents::AzQtApplicationWindow(parent, "MaterialEditorWindow") { resize(1280, 1024); @@ -82,45 +82,25 @@ namespace MaterialEditor setWindowTitle(QApplication::applicationName()); } - m_advancedDockManager = new AzQtComponents::FancyDocking(this); - - setObjectName("MaterialEditorWindow"); - setDockNestingEnabled(true); - setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); - setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); - - m_menuBar = new QMenuBar(this); - m_menuBar->setObjectName("MenuBar"); - setMenuBar(m_menuBar); - m_toolBar = new MaterialEditorToolBar(this); m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); - m_centralWidget = new QWidget(this); - m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget); - m_tabWidget->setObjectName("TabWidget"); - m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); - m_tabWidget->setContentsMargins(0, 0, 0, 0); - m_materialViewport = new MaterialViewportWidget(m_centralWidget); m_materialViewport->setObjectName("Viewport"); m_materialViewport->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - - QVBoxLayout* vl = new QVBoxLayout(m_centralWidget); + vl->setMargin(0); vl->setContentsMargins(0, 0, 0, 0); vl->addWidget(m_tabWidget); vl->addWidget(m_materialViewport); m_centralWidget->setLayout(vl); setCentralWidget(m_centralWidget); - + m_statusBar = new StatusBarWidget(this); m_statusBar->setObjectName("StatusBar"); statusBar()->addPermanentWidget(m_statusBar, 1); - + SetupMenu(); SetupTabs(); @@ -738,22 +718,6 @@ namespace MaterialEditor } } - void MaterialEditorWindow::SelectPreviousTab() - { - if (m_tabWidget->count() > 1) - { - // Adding count to wrap around when index <= 0 - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); - } - } - - void MaterialEditorWindow::SelectNextTab() - { - if (m_tabWidget->count() > 1) - { - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); - } - } } // namespace MaterialEditor #include diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h index 165767ecc5..b96ceb2aa4 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h @@ -12,10 +12,11 @@ #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT -#include +//#include #include #include #include +#include #include #include @@ -43,7 +44,7 @@ namespace MaterialEditor * 3) MaterialPropertyInspector - The user edits the properties of the selected Material. */ class MaterialEditorWindow - : public AzQtComponents::DockMainWindow + : public AzQtComponents::AzQtApplicationWindow , private MaterialEditorWindowRequestBus::Handler , private MaterialDocumentNotificationBus::Handler { @@ -74,61 +75,31 @@ namespace MaterialEditor void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; void OnDocumentSaved(const AZ::Uuid& documentId) override; - void SetupMenu(); + void SetupMenu() override; + void SetupTabs() override; - void SetupTabs(); void AddTabForDocumentId(const AZ::Uuid& documentId); void RemoveTabForDocumentId(const AZ::Uuid& documentId); void UpdateTabForDocumentId(const AZ::Uuid& documentId); - QString GetDocumentPath(const AZ::Uuid& documentId) const; AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; + QString GetDocumentPath(const AZ::Uuid& documentId) const; - void OpenTabContextMenu(); - void SelectPreviousTab(); - void SelectNextTab(); + void OpenTabContextMenu() override; void closeEvent(QCloseEvent* closeEvent) override; - AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; - QWidget* m_centralWidget = nullptr; - QMenuBar* m_menuBar = nullptr; - AzQtComponents::TabWidget* m_tabWidget = nullptr; MaterialViewportWidget* m_materialViewport = nullptr; MaterialEditorToolBar* m_toolBar = nullptr; AZStd::unordered_map m_dockWidgets; - QMenu* m_menuFile = {}; QAction* m_actionNew = {}; - QAction* m_actionOpen = {}; - QAction* m_actionOpenRecent = {}; - QAction* m_actionClose = {}; - QAction* m_actionCloseAll = {}; - QAction* m_actionCloseOthers = {}; - QAction* m_actionSave = {}; - QAction* m_actionSaveAsCopy = {}; QAction* m_actionSaveAsChild = {}; - QAction* m_actionSaveAll = {}; - QAction* m_actionExit = {}; - QMenu* m_menuEdit = {}; - QAction* m_actionUndo = {}; - QAction* m_actionRedo = {}; - QAction* m_actionSettings = {}; - - QMenu* m_menuView = {}; - QAction* m_actionAssetBrowser = {}; QAction* m_actionInspector = {}; QAction* m_actionConsole = {}; - QAction* m_actionPythonTerminal = {}; QAction* m_actionPerfMonitor = {}; QAction* m_actionViewportSettings = {}; - QAction* m_actionNextTab = {}; - QAction* m_actionPreviousTab = {}; - - QMenu* m_menuHelp = {}; - QAction* m_actionHelp = {}; - QAction* m_actionAbout = {}; StatusBarWidget* m_statusBar = {}; }; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp index f5ee1f5bcb..d10893ff46 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp @@ -152,7 +152,6 @@ namespace ShaderManagementConsole { AzFramework::AssetSystemStatusBus::Handler::BusConnect(); AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusConnect(); - AZ::Debug::TraceMessageBus::Handler::BusConnect(); AzFramework::Application::StartCommon(systemEntity); @@ -164,7 +163,6 @@ namespace ShaderManagementConsole void ShaderManagementConsoleApplication::OnShaderManagementConsoleWindowClosing() { ExitMainLoop(); - AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); ShaderManagementConsoleWindowNotificationBus::Handler::BusDisconnect(); AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusDisconnect(); } diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp index 103299a361..dde818d9e6 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp @@ -37,30 +37,14 @@ AZ_POP_DISABLE_WARNING namespace ShaderManagementConsole { ShaderManagementConsoleWindow::ShaderManagementConsoleWindow(QWidget* parent /* = 0 */) - : AzQtComponents::DockMainWindow(parent) + : AzQtComponents::AzQtApplicationWindow(parent, "ShaderManagementConsoleWindow") { setWindowTitle("Shader Management Console"); - m_advancedDockManager = new AzQtComponents::FancyDocking(this); - - setDockNestingEnabled(true); - setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); - setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); - - m_menuBar = new QMenuBar(this); - setMenuBar(m_menuBar); - m_toolBar = new ShaderManagementConsoleToolBar(this); + m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); - m_centralWidget = new QWidget(this); - m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget); - m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); - m_tabWidget->setContentsMargins(0, 0, 0, 0); - - QVBoxLayout* vl = new QVBoxLayout(m_centralWidget); vl->setMargin(0); vl->setContentsMargins(0, 0, 0, 0); vl->addWidget(m_tabWidget); @@ -143,7 +127,7 @@ namespace ShaderManagementConsole m_actionUndo->setEnabled(canUndo); m_actionRedo->setEnabled(canRedo); - m_actionPreferences->setEnabled(false); + m_actionSettings->setEnabled(false); m_actionAssetBrowser->setEnabled(true); m_actionPythonTerminal->setEnabled(true); @@ -263,9 +247,9 @@ namespace ShaderManagementConsole m_menuEdit->addSeparator(); - m_actionPreferences = m_menuEdit->addAction("&Preferences...", [this]() { + m_actionSettings = m_menuEdit->addAction("&Preferences...", [this]() { }, QKeySequence::Preferences); - m_actionPreferences->setEnabled(false); + m_actionSettings->setEnabled(false); m_menuView = m_menuBar->addMenu("&View"); @@ -471,23 +455,6 @@ namespace ShaderManagementConsole } } - void ShaderManagementConsoleWindow::SelectPreviousTab() - { - if (m_tabWidget->count() > 1) - { - // Adding count to wrap around when index <= 0 - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); - } - } - - void ShaderManagementConsoleWindow::SelectNextTab() - { - if (m_tabWidget->count() > 1) - { - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); - } - } - void ShaderManagementConsoleWindow::SelectDocumentForTab(const int tabIndex) { const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h index 0f8824f809..9201be8db0 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h @@ -15,10 +15,11 @@ #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT -#include +//#include #include #include #include +#include #include #include @@ -41,7 +42,7 @@ namespace ShaderManagementConsole * its panels, managing selection of assets, and performing high-level actions like saving. It contains... */ class ShaderManagementConsoleWindow - : public AzQtComponents::DockMainWindow + : public AzQtComponents::AzQtApplicationWindow , private ShaderManagementConsoleDocumentNotificationBus::Handler { Q_OBJECT @@ -59,17 +60,15 @@ namespace ShaderManagementConsole void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; void OnDocumentSaved(const AZ::Uuid& documentId) override; - void SetupMenu(); + void SetupMenu() override; + void SetupTabs() override; - void SetupTabs(); void AddTabForDocumentId(const AZ::Uuid& documentId); void RemoveTabForDocumentId(const AZ::Uuid& documentId); void UpdateTabForDocumentId(const AZ::Uuid& documentId); AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; - void OpenTabContextMenu(); - void SelectPreviousTab(); - void SelectNextTab(); + void OpenTabContextMenu() override; void SelectDocumentForTab(const int tabIndex); void CloseDocumentForTab(const int tabIndex); @@ -79,42 +78,11 @@ namespace ShaderManagementConsole void CreateDocumentContent(const AZ::Uuid& documentId, QStandardItemModel* model); - AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; - QMenuBar* m_menuBar = nullptr; - QWidget* m_centralWidget = nullptr; - AzQtComponents::TabWidget* m_tabWidget = nullptr; ShaderManagementConsoleBrowserWidget* m_assetBrowser = nullptr; ShaderManagementConsoleToolBar* m_toolBar = nullptr; AzToolsFramework::CScriptTermDialog* m_pythonTerminal = nullptr; AzQtComponents::StyledDockWidget* m_assetBrowserDockWidget = nullptr; AzQtComponents::StyledDockWidget* m_pythonTerminalDockWidget = nullptr; - - QMenu* m_menuFile = {}; - QMenu* m_menuNew = {}; - QAction* m_actionOpen = {}; - QAction* m_actionOpenRecent = {}; - QAction* m_actionClose = {}; - QAction* m_actionCloseAll = {}; - QAction* m_actionCloseOthers = {}; - QAction* m_actionSave = {}; - QAction* m_actionSaveAsCopy = {}; - QAction* m_actionSaveAll = {}; - QAction* m_actionExit = {}; - - QMenu* m_menuEdit = {}; - QAction* m_actionUndo = {}; - QAction* m_actionRedo = {}; - QAction* m_actionPreferences = {}; - - QMenu* m_menuView = {}; - QAction* m_actionAssetBrowser = {}; - QAction* m_actionPythonTerminal = {}; - QAction* m_actionNextTab = {}; - QAction* m_actionPreviousTab = {}; - - QMenu* m_menuHelp = {}; - QAction* m_actionHelp = {}; - QAction* m_actionAbout = {}; }; } // namespace ShaderManagementConsole From d36d1defab164aac182fdd484bcbe51c37e228e9 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 13 Jul 2021 13:05:31 -0500 Subject: [PATCH 21/37] Styling fixes and AzQtAppWindow changes Signed-off-by: Dayo Lawal --- .../Application/AzQtApplication.cpp | 3 +- .../Application/AzQtApplication.h | 8 +++-- .../Window/AzQtApplicationWindow.cpp | 34 +----------------- .../Window/AzQtApplicationWindow.h | 35 +------------------ .../{AzQtTraceLogger.cpp => TraceLogger.cpp} | 10 +++--- .../{AzQtTraceLogger.h => TraceLogger.h} | 9 +++-- .../aztoolsframework_files.cmake | 4 +-- .../Code/Source/MaterialEditorApplication.h | 4 +-- .../Source/Window/MaterialEditorWindow.cpp | 35 +++++++++++++++++-- .../Code/Source/Window/MaterialEditorWindow.h | 28 +++++++++++++++ .../ShaderManagementConsoleApplication.h | 4 +-- .../Window/ShaderManagementConsoleWindow.cpp | 32 ++++++++++++++++- .../Window/ShaderManagementConsoleWindow.h | 31 ++++++++++++++++ 13 files changed, 148 insertions(+), 89 deletions(-) rename Code/Framework/AzToolsFramework/AzToolsFramework/Logger/{AzQtTraceLogger.cpp => TraceLogger.cpp} (89%) rename Code/Framework/AzToolsFramework/AzToolsFramework/Logger/{AzQtTraceLogger.h => TraceLogger.h} (86%) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index 3459656960..f081159b87 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -31,7 +31,7 @@ namespace AzQtComponents QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); } - void AzQtApplication::SetDpiScaling() + void AzQtApplication::InitializeDpiScaling() { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); @@ -39,6 +39,5 @@ namespace AzQtComponents QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware); } - } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 60d582a50a..17ee29fc85 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -25,9 +25,11 @@ namespace AzQtComponents public: AzQtApplication(int& argc, char** argv); - //! DPI Scaling so that we support HighDpi monitors, like the Retina displays on Windows 10 - //! Must be set before QApplication is initialized, - static void SetDpiScaling(); + //! Initializes Qt DPI scaling to handle displays with high display densities, such as Retina displays. + //! Currently, this uses Qt's system DPI awareness, in which a common device scaling factor will be + //! calculated across all attached screens. + //! \warning This must be called before this AzQtApplication instance is initialized. + static void InitializeDpiScaling(); }; } // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp index b2dc0cf429..e8d16dfc58 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp @@ -16,46 +16,14 @@ namespace AzQtComponents { - AzQtApplicationWindow::AzQtApplicationWindow(QWidget* parent /* = 0 */, const AZStd::string& objectName) + AzQtApplicationWindow::AzQtApplicationWindow(QWidget* parent /* = 0 */) : AzQtComponents::DockMainWindow(parent) { m_advancedDockManager = new AzQtComponents::FancyDocking(this); - setObjectName(objectName.c_str()); - setDockNestingEnabled(true); - setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); - setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); - m_menuBar = new QMenuBar(this); m_menuBar->setObjectName("MenuBar"); setMenuBar(m_menuBar); - - m_centralWidget = new QWidget(this); - m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget); - m_tabWidget->setObjectName("TabWidget"); - m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); - m_tabWidget->setContentsMargins(0, 0, 0, 0); - - vl = new QVBoxLayout(m_centralWidget); - } - - void AzQtApplicationWindow::SelectPreviousTab() - { - if (m_tabWidget->count() > 1) - { - // Adding count to wrap around when index <= 0 - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); - } - } - - void AzQtApplicationWindow::SelectNextTab() - { - if (m_tabWidget->count() > 1) - { - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); - } } } diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h index 87d251f983..4a9a67d4df 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h @@ -42,7 +42,7 @@ namespace AzQtComponents { Q_OBJECT public: - AzQtApplicationWindow(QWidget* parent, const AZStd::string& objectName); + AzQtApplicationWindow(QWidget* parent); protected: virtual void SetupMenu() {}; @@ -50,40 +50,7 @@ namespace AzQtComponents virtual void OpenTabContextMenu() {}; - void SelectPreviousTab(); - void SelectNextTab(); - AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; QMenuBar* m_menuBar = nullptr; - QWidget* m_centralWidget = nullptr; - AzQtComponents::TabWidget* m_tabWidget = nullptr; - - QVBoxLayout* vl; - - QMenu* m_menuFile = {}; - QAction* m_actionOpen = {}; - QAction* m_actionOpenRecent = {}; - QAction* m_actionClose = {}; - QAction* m_actionCloseAll = {}; - QAction* m_actionCloseOthers = {}; - QAction* m_actionSave = {}; - QAction* m_actionSaveAsCopy = {}; - QAction* m_actionSaveAll = {}; - QAction* m_actionExit = {}; - - QMenu* m_menuEdit = {}; - QAction* m_actionUndo = {}; - QAction* m_actionRedo = {}; - QAction* m_actionSettings = {}; - - QMenu* m_menuView = {}; - QAction* m_actionAssetBrowser = {}; - QAction* m_actionPythonTerminal = {}; - QAction* m_actionNextTab = {}; - QAction* m_actionPreviousTab = {}; - - QMenu* m_menuHelp = {}; - QAction* m_actionHelp = {}; - QAction* m_actionAbout = {}; }; } // namespace ShaderManagementConsole diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp similarity index 89% rename from Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp rename to Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp index f795719062..3b40455483 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp @@ -10,7 +10,7 @@ * */ -#include +#include #include #include @@ -18,17 +18,17 @@ namespace AzToolsFramework { - AzQtTraceLogger::AzQtTraceLogger() + TraceLogger::TraceLogger() { AZ::Debug::TraceMessageBus::Handler::BusConnect(); } - AzQtTraceLogger::~AzQtTraceLogger() + TraceLogger::~TraceLogger() { AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); } - bool AzQtTraceLogger::OnOutput(const char* window, const char* message) + bool TraceLogger::OnOutput(const char* window, const char* message) { if (m_logFile) { @@ -41,7 +41,7 @@ namespace AzToolsFramework return false; } - void AzQtTraceLogger::WriteStartupLog(const AZStd::string& logFileName) + void TraceLogger::WriteStartupLog(const AZStd::string& logFileName) { using namespace AzFramework; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h similarity index 86% rename from Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h rename to Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h index 9518c6842d..cd605e83ab 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/AzQtTraceLogger.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h @@ -14,15 +14,18 @@ #include #include +#include +#include namespace AzToolsFramework { //! Connects and disconnects TraceMessageBus and allows for logging for O3DE Tools Applications - class AzQtTraceLogger : public AZ::Debug::TraceMessageBus::Handler + class TraceLogger + : public AZ::Debug::TraceMessageBus::Handler { public: - AzQtTraceLogger(); - ~AzQtTraceLogger(); + TraceLogger(); + ~TraceLogger(); //! Intalize logging for O3DEToolsApplications void WriteStartupLog(const AZStd::string& logFileName); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake index 5718de48ab..75b5bd4a56 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake @@ -147,8 +147,8 @@ set(FILES Entity/SliceEditorEntityOwnershipServiceBus.h Fingerprinting/TypeFingerprinter.h Fingerprinting/TypeFingerprinter.cpp - Logger/AzQtTraceLogger.cpp - Logger/AzQtTraceLogger.h + Logger/TraceLogger.cpp + Logger/TraceLogger.h Manipulators/AngularManipulator.cpp Manipulators/AngularManipulator.h Manipulators/BaseManipulator.cpp diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index ff0809897d..284eddee93 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include @@ -124,7 +124,7 @@ namespace MaterialEditor AZStd::vector m_startupLogSink; AZStd::unique_ptr m_logFile; - AzToolsFramework::AzQtTraceLogger m_traceLogger; + AzToolsFramework::TraceLogger m_traceLogger; //! Local user settings are used to store material browser tree expansion state AZ::UserSettingsProvider m_localUserSettings; diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp index 3e39526689..2c4e19a037 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp @@ -55,7 +55,7 @@ AZ_POP_DISABLE_WARNING namespace MaterialEditor { MaterialEditorWindow::MaterialEditorWindow(QWidget* parent /* = 0 */) - : AzQtComponents::AzQtApplicationWindow(parent, "MaterialEditorWindow") + : AzQtComponents::AzQtApplicationWindow(parent) { resize(1280, 1024); @@ -82,14 +82,28 @@ namespace MaterialEditor setWindowTitle(QApplication::applicationName()); } + setObjectName("MaterialEditorWindow"); + setDockNestingEnabled(true); + setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); + setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + m_toolBar = new MaterialEditorToolBar(this); m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); + m_centralWidget = new QWidget(this); + m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget); + m_tabWidget->setObjectName("TabWidget"); + m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); + m_tabWidget->setContentsMargins(0, 0, 0, 0); + m_materialViewport = new MaterialViewportWidget(m_centralWidget); m_materialViewport->setObjectName("Viewport"); m_materialViewport->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - + + QVBoxLayout* vl = new QVBoxLayout(m_centralWidget); vl->setMargin(0); vl->setContentsMargins(0, 0, 0, 0); vl->addWidget(m_tabWidget); @@ -718,6 +732,23 @@ namespace MaterialEditor } } + void MaterialEditorWindow::SelectPreviousTab() + { + if (m_tabWidget->count() > 1) + { + // Adding count to wrap around when index <= 0 + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); + } + } + + void MaterialEditorWindow::SelectNextTab() + { + if (m_tabWidget->count() > 1) + { + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); + } + } + } // namespace MaterialEditor #include diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h index b96ceb2aa4..e7efcfc528 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h @@ -85,21 +85,49 @@ namespace MaterialEditor QString GetDocumentPath(const AZ::Uuid& documentId) const; void OpenTabContextMenu() override; + void SelectPreviousTab(); + void SelectNextTab(); void closeEvent(QCloseEvent* closeEvent) override; + QWidget* m_centralWidget = nullptr; + AzQtComponents::TabWidget* m_tabWidget = nullptr; MaterialViewportWidget* m_materialViewport = nullptr; MaterialEditorToolBar* m_toolBar = nullptr; AZStd::unordered_map m_dockWidgets; + QMenu* m_menuFile = {}; QAction* m_actionNew = {}; + QAction* m_actionOpen = {}; + QAction* m_actionOpenRecent = {}; + QAction* m_actionClose = {}; + QAction* m_actionCloseAll = {}; + QAction* m_actionCloseOthers = {}; + QAction* m_actionSave = {}; + QAction* m_actionSaveAsCopy = {}; QAction* m_actionSaveAsChild = {}; + QAction* m_actionSaveAll = {}; + QAction* m_actionExit = {}; + QMenu* m_menuEdit = {}; + QAction* m_actionUndo = {}; + QAction* m_actionRedo = {}; + QAction* m_actionSettings = {}; + + QMenu* m_menuView = {}; + QAction* m_actionAssetBrowser = {}; QAction* m_actionInspector = {}; QAction* m_actionConsole = {}; + QAction* m_actionPythonTerminal = {}; QAction* m_actionPerfMonitor = {}; QAction* m_actionViewportSettings = {}; + QAction* m_actionNextTab = {}; + QAction* m_actionPreviousTab = {}; + + QMenu* m_menuHelp = {}; + QAction* m_actionHelp = {}; + QAction* m_actionAbout = {}; StatusBarWidget* m_statusBar = {}; }; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h index 9b7de38f0a..bd2e0b9403 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -115,7 +115,7 @@ namespace ShaderManagementConsole static void PyIdleWaitFrames(uint32_t frames); - AzToolsFramework::AzQtTraceLogger m_traceLogger; + AzToolsFramework::TraceLogger m_traceLogger; //! Local user settings are used to store asset browser tree expansion state AZ::UserSettingsProvider m_localUserSettings; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp index dde818d9e6..6c2ae0c322 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp @@ -37,14 +37,27 @@ AZ_POP_DISABLE_WARNING namespace ShaderManagementConsole { ShaderManagementConsoleWindow::ShaderManagementConsoleWindow(QWidget* parent /* = 0 */) - : AzQtComponents::AzQtApplicationWindow(parent, "ShaderManagementConsoleWindow") + : AzQtComponents::AzQtApplicationWindow(parent) { setWindowTitle("Shader Management Console"); + setObjectName("ShaderManagementConsoleWindow"); + setDockNestingEnabled(true); + setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); + setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); m_toolBar = new ShaderManagementConsoleToolBar(this); m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); + m_centralWidget = new QWidget(this); + m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget); + m_tabWidget->setObjectName("TabWidget"); + m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); + m_tabWidget->setContentsMargins(0, 0, 0, 0); + + QVBoxLayout* vl = new QVBoxLayout(m_centralWidget); vl->setMargin(0); vl->setContentsMargins(0, 0, 0, 0); vl->addWidget(m_tabWidget); @@ -535,6 +548,23 @@ namespace ShaderManagementConsole } } } + + void ShaderManagementConsoleWindow::SelectPreviousTab() + { + if (m_tabWidget->count() > 1) + { + // Adding count to wrap around when index <= 0 + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); + } + } + + void ShaderManagementConsoleWindow::SelectNextTab() + { + if (m_tabWidget->count() > 1) + { + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); + } + } } // namespace ShaderManagementConsole #include diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h index 9201be8db0..cd9bcce482 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h @@ -69,6 +69,8 @@ namespace ShaderManagementConsole AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; void OpenTabContextMenu() override; + void SelectPreviousTab(); + void SelectNextTab(); void SelectDocumentForTab(const int tabIndex); void CloseDocumentForTab(const int tabIndex); @@ -78,11 +80,40 @@ namespace ShaderManagementConsole void CreateDocumentContent(const AZ::Uuid& documentId, QStandardItemModel* model); + QWidget* m_centralWidget = nullptr; + AzQtComponents::TabWidget* m_tabWidget = nullptr; ShaderManagementConsoleBrowserWidget* m_assetBrowser = nullptr; ShaderManagementConsoleToolBar* m_toolBar = nullptr; AzToolsFramework::CScriptTermDialog* m_pythonTerminal = nullptr; AzQtComponents::StyledDockWidget* m_assetBrowserDockWidget = nullptr; AzQtComponents::StyledDockWidget* m_pythonTerminalDockWidget = nullptr; + + QMenu* m_menuFile = {}; + QMenu* m_menuNew = {}; + QAction* m_actionOpen = {}; + QAction* m_actionOpenRecent = {}; + QAction* m_actionClose = {}; + QAction* m_actionCloseAll = {}; + QAction* m_actionCloseOthers = {}; + QAction* m_actionSave = {}; + QAction* m_actionSaveAsCopy = {}; + QAction* m_actionSaveAll = {}; + QAction* m_actionExit = {}; + + QMenu* m_menuEdit = {}; + QAction* m_actionUndo = {}; + QAction* m_actionRedo = {}; + QAction* m_actionSettings = {}; + + QMenu* m_menuView = {}; + QAction* m_actionAssetBrowser = {}; + QAction* m_actionPythonTerminal = {}; + QAction* m_actionNextTab = {}; + QAction* m_actionPreviousTab = {}; + + QMenu* m_menuHelp = {}; + QAction* m_actionHelp = {}; + QAction* m_actionAbout = {}; }; } // namespace ShaderManagementConsole From 92ead794fa11af76968dcde64aaa1fb7e0ed84b8 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 13 Jul 2021 15:47:59 -0500 Subject: [PATCH 22/37] Removal of AzQtAppWindow Signed-off-by: Dayo Lawal --- .../Window/AzQtApplicationWindow.cpp | 29 ---------- .../Window/AzQtApplicationWindow.h | 56 ------------------- .../AzToolsFramework/Logger/TraceLogger.cpp | 10 +--- .../AzToolsFramework/Logger/TraceLogger.h | 10 +--- .../Source/Window/MaterialEditorWindow.cpp | 8 ++- .../Code/Source/Window/MaterialEditorWindow.h | 13 +++-- .../Window/ShaderManagementConsoleWindow.cpp | 8 ++- .../Window/ShaderManagementConsoleWindow.h | 13 +++-- 8 files changed, 34 insertions(+), 113 deletions(-) delete mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp delete mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp deleted file mode 100644 index e8d16dfc58..0000000000 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -* 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 - - -namespace AzQtComponents -{ - AzQtApplicationWindow::AzQtApplicationWindow(QWidget* parent /* = 0 */) - : AzQtComponents::DockMainWindow(parent) - { - m_advancedDockManager = new AzQtComponents::FancyDocking(this); - - m_menuBar = new QMenuBar(this); - m_menuBar->setObjectName("MenuBar"); - setMenuBar(m_menuBar); - } -} - diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h deleted file mode 100644 index 4a9a67d4df..0000000000 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/Window/AzQtApplicationWindow.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT -#include -#include -#include -#include - -#include -#include -#include -#include -AZ_POP_DISABLE_WARNING -#endif - -namespace AzQtComponents -{ - /** - * //! Base class for O3DE Tools Applications Windows. Its responsibility is limited to initializing and connecting - * its panels, managing selection of assets, and performing high-level actions like saving. It contains... - */ - class AZ_QT_COMPONENTS_API AzQtApplicationWindow - : public AzQtComponents::DockMainWindow - { - Q_OBJECT - public: - AzQtApplicationWindow(QWidget* parent); - - protected: - virtual void SetupMenu() {}; - virtual void SetupTabs() {}; - - virtual void OpenTabContextMenu() {}; - - AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; - QMenuBar* m_menuBar = nullptr; - }; -} // namespace ShaderManagementConsole diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp index 3b40455483..e306f0d21d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp @@ -1,12 +1,8 @@ /* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. + * 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. * - * 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. + * SPDX-License-Identifier: Apache-2.0 OR MIT * */ diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h index cd605e83ab..e9314137d1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h @@ -1,12 +1,8 @@ /* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. + * 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. * - * 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. + * SPDX-License-Identifier: Apache-2.0 OR MIT * */ diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp index 2c4e19a037..34962806cc 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp @@ -55,7 +55,7 @@ AZ_POP_DISABLE_WARNING namespace MaterialEditor { MaterialEditorWindow::MaterialEditorWindow(QWidget* parent /* = 0 */) - : AzQtComponents::AzQtApplicationWindow(parent) + : AzQtComponents::DockMainWindow(parent) { resize(1280, 1024); @@ -82,6 +82,8 @@ namespace MaterialEditor setWindowTitle(QApplication::applicationName()); } + m_advancedDockManager = new AzQtComponents::FancyDocking(this); + setObjectName("MaterialEditorWindow"); setDockNestingEnabled(true); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); @@ -89,6 +91,10 @@ namespace MaterialEditor setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + m_menuBar = new QMenuBar(this); + m_menuBar->setObjectName("MenuBar"); + setMenuBar(m_menuBar); + m_toolBar = new MaterialEditorToolBar(this); m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h index e7efcfc528..8c288abca9 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h @@ -12,11 +12,10 @@ #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT -//#include +#include #include #include #include -#include #include #include @@ -44,7 +43,7 @@ namespace MaterialEditor * 3) MaterialPropertyInspector - The user edits the properties of the selected Material. */ class MaterialEditorWindow - : public AzQtComponents::AzQtApplicationWindow + : public AzQtComponents::DockMainWindow , private MaterialEditorWindowRequestBus::Handler , private MaterialDocumentNotificationBus::Handler { @@ -75,8 +74,8 @@ namespace MaterialEditor void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; void OnDocumentSaved(const AZ::Uuid& documentId) override; - void SetupMenu() override; - void SetupTabs() override; + void SetupMenu(); + void SetupTabs(); void AddTabForDocumentId(const AZ::Uuid& documentId); void RemoveTabForDocumentId(const AZ::Uuid& documentId); @@ -84,12 +83,14 @@ namespace MaterialEditor AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; QString GetDocumentPath(const AZ::Uuid& documentId) const; - void OpenTabContextMenu() override; + void OpenTabContextMenu(); void SelectPreviousTab(); void SelectNextTab(); void closeEvent(QCloseEvent* closeEvent) override; + AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; + QMenuBar* m_menuBar = nullptr; QWidget* m_centralWidget = nullptr; AzQtComponents::TabWidget* m_tabWidget = nullptr; MaterialViewportWidget* m_materialViewport = nullptr; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp index 6c2ae0c322..fea10dfb7a 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp @@ -37,8 +37,10 @@ AZ_POP_DISABLE_WARNING namespace ShaderManagementConsole { ShaderManagementConsoleWindow::ShaderManagementConsoleWindow(QWidget* parent /* = 0 */) - : AzQtComponents::AzQtApplicationWindow(parent) + : AzQtComponents::DockMainWindow(parent) { + m_advancedDockManager = new AzQtComponents::FancyDocking(this); + setWindowTitle("Shader Management Console"); setObjectName("ShaderManagementConsoleWindow"); setDockNestingEnabled(true); @@ -47,6 +49,10 @@ namespace ShaderManagementConsole setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + m_menuBar = new QMenuBar(this); + m_menuBar->setObjectName("MenuBar"); + setMenuBar(m_menuBar); + m_toolBar = new ShaderManagementConsoleToolBar(this); m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h index cd9bcce482..f35000ce26 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h @@ -15,11 +15,10 @@ #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT -//#include +#include #include #include #include -#include #include #include @@ -42,7 +41,7 @@ namespace ShaderManagementConsole * its panels, managing selection of assets, and performing high-level actions like saving. It contains... */ class ShaderManagementConsoleWindow - : public AzQtComponents::AzQtApplicationWindow + : public AzQtComponents::DockMainWindow , private ShaderManagementConsoleDocumentNotificationBus::Handler { Q_OBJECT @@ -60,15 +59,15 @@ namespace ShaderManagementConsole void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override; void OnDocumentSaved(const AZ::Uuid& documentId) override; - void SetupMenu() override; - void SetupTabs() override; + void SetupMenu(); + void SetupTabs(); void AddTabForDocumentId(const AZ::Uuid& documentId); void RemoveTabForDocumentId(const AZ::Uuid& documentId); void UpdateTabForDocumentId(const AZ::Uuid& documentId); AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; - void OpenTabContextMenu() override; + void OpenTabContextMenu(); void SelectPreviousTab(); void SelectNextTab(); @@ -80,6 +79,8 @@ namespace ShaderManagementConsole void CreateDocumentContent(const AZ::Uuid& documentId, QStandardItemModel* model); + AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; + QMenuBar* m_menuBar = nullptr; QWidget* m_centralWidget = nullptr; AzQtComponents::TabWidget* m_tabWidget = nullptr; ShaderManagementConsoleBrowserWidget* m_assetBrowser = nullptr; From 986ee5aa9b14f498a08d233d4445097f4008f5ef Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 13 Jul 2021 18:55:18 -0500 Subject: [PATCH 23/37] Changing cmake Signed-off-by: Dayo Lawal --- .../AzQtComponents/AzQtComponents/azqtcomponents_files.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index 98882c5132..bcfbb84778 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -9,8 +9,6 @@ set(FILES AzQtComponentsAPI.h Application/AzQtApplication.cpp Application/AzQtApplication.h - Application/Window/AzQtApplicationWindow.cpp - Application/Window/AzQtApplicationWindow.h Buses/DragAndDrop.h Buses/ShortcutDispatch.h DragAndDrop/MainWindowDragAndDrop.h From 9c63968833d354ec614139ccfe344e1a52f2b5c8 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 13 Jul 2021 19:24:36 -0500 Subject: [PATCH 24/37] Style fixing Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtApplication.cpp | 2 +- .../Atom/Tools/MaterialEditor/Code/Source/main.cpp | 12 +----------- .../ShaderManagementConsole/Code/Source/main.cpp | 14 +------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index f081159b87..d234a95013 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -24,7 +24,7 @@ namespace AzQtComponents // Use a common Qt settings path for applications that don't register their own application name QApplication::setOrganizationName("O3DE"); QApplication::setOrganizationDomain("o3de.org"); - QApplication::setApplicationName("O3DEToolsApplication"); + QApplication::setApplicationName("O3DE Tools Application"); AzQtComponents::PrepareQtPaths(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp index 3ea7d37175..2693101ebf 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp @@ -28,18 +28,8 @@ int main(int argc, char** argv) QApplication::setOrganizationDomain("o3de.org"); QApplication::setApplicationName("O3DE Material Editor"); - AzQtComponents::PrepareQtPaths(); + AzQtComponents::AzQtApplication::InitializeDpiScaling(); - QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); - - // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays - // on Windows 10 - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); - QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); - AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware); - //*/ MaterialEditor::MaterialEditorApplication app(&argc, &argv); auto globalEventFilter = new AzQtComponents::GlobalEventFilter(&app); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp index ed5537e93d..4ff38ac73f 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp @@ -28,19 +28,7 @@ int main(int argc, char** argv) QApplication::setOrganizationDomain("o3de.com"); QApplication::setApplicationName("O3DE Shader Management Console"); - AzQtComponents::PrepareQtPaths(); - - QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); - - // Must be set before QApplication is initialized, so that we support HighDpi monitors, like the Retina displays - // on Windows 10 - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); - QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); - AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::PerScreenDpiAware); - - AzQtComponents::AzQtApplication::setDpiScaling(); + AzQtComponents::AzQtApplication::InitializeDpiScaling(); ShaderManagementConsole::ShaderManagementConsoleApplication app(&argc, &argv); From 54947791d2af9efb2a4b5077bbac255582612f0f Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Tue, 13 Jul 2021 19:51:58 -0500 Subject: [PATCH 25/37] Fixing copyright header Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtApplication.cpp | 10 +++------- .../AzQtComponents/Application/AzQtApplication.h | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index d234a95013..b8c26750e3 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -1,12 +1,8 @@ /* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. + * 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. * - * 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. + * SPDX-License-Identifier: Apache-2.0 OR MIT * */ diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 17ee29fc85..2dd28dcea6 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -1,12 +1,8 @@ /* - * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or - * its licensors. + * 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. * - * 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. + * SPDX-License-Identifier: Apache-2.0 OR MIT * */ From 8f22bff1fbfba428fc129ad2b1934e11c4d227a8 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 15 Jul 2021 11:28:04 -0500 Subject: [PATCH 26/37] QEditorApplication inheriting from AzQtApplication Signed-off-by: Dayo Lawal --- Code/Editor/Core/QtEditorApplication.cpp | 4 +--- Code/Editor/Core/QtEditorApplication.h | 4 ++-- .../Code/Source/ShaderManagementConsoleApplication.h | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Code/Editor/Core/QtEditorApplication.cpp b/Code/Editor/Core/QtEditorApplication.cpp index f5c886761c..04b5d45907 100644 --- a/Code/Editor/Core/QtEditorApplication.cpp +++ b/Code/Editor/Core/QtEditorApplication.cpp @@ -242,7 +242,7 @@ namespace Editor } EditorQtApplication::EditorQtApplication(int& argc, char** argv) - : QApplication(argc, argv) + : AzQtApplication(argc, argv) , m_inWinEventFilter(false) , m_stylesheet(new AzQtComponents::O3DEStylesheet(this)) , m_idleTimer(new QTimer(this)) @@ -252,8 +252,6 @@ namespace Editor setWindowIcon(QIcon(":/Application/res/o3de_editor.ico")); // set the default key store for our preferences: - setOrganizationName("O3DE"); - setOrganizationDomain("o3de.org"); setApplicationName("O3DE Editor"); connect(m_idleTimer, &QTimer::timeout, this, &EditorQtApplication::maybeProcessIdle); diff --git a/Code/Editor/Core/QtEditorApplication.h b/Code/Editor/Core/QtEditorApplication.h index 7baaae8e28..e782b8bfc7 100644 --- a/Code/Editor/Core/QtEditorApplication.h +++ b/Code/Editor/Core/QtEditorApplication.h @@ -7,7 +7,6 @@ #pragma once #if !defined(Q_MOC_RUN) -#include #include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include #endif class QFileInfo; @@ -47,7 +47,7 @@ namespace Editor void ScanDirectories(QFileInfoList& directoryList, const QStringList& filters, QFileInfoList& files, ScanDirectoriesUpdateCallBack updateCallback = nullptr); class EditorQtApplication - : public QApplication + : public AzQtComponents::AzQtApplication , public QAbstractNativeEventFilter , public IEditorNotifyListener , public AZ::UserSettingsOwnerRequestBus::Handler diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h index bd2e0b9403..e74458b2e7 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h @@ -7,7 +7,6 @@ #pragma once - #include #include #include From f215011de414fa002dad22d26b3cf8e24c38ac05 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 15 Jul 2021 12:44:26 -0500 Subject: [PATCH 27/37] Copyright header and whitespace fixes Signed-off-by: Dayo Lawal --- .../AzQtComponents/Application/AzQtApplication.cpp | 3 +-- .../AzQtComponents/Application/AzQtApplication.h | 3 +-- .../AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp | 3 +-- .../AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h | 3 +-- .../AzToolsFramework/aztoolsframework_files.cmake | 4 ++-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp index b8c26750e3..594a339448 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.cpp @@ -1,6 +1,5 @@ /* - * 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. + * 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 * diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h index 2dd28dcea6..2aa4be646c 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Application/AzQtApplication.h @@ -1,6 +1,5 @@ /* - * 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. + * 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 * diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp index e306f0d21d..5f1546bf83 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.cpp @@ -1,6 +1,5 @@ /* - * 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. + * 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 * diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h index e9314137d1..a10f4fc2df 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Logger/TraceLogger.h @@ -1,6 +1,5 @@ /* - * 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. + * 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 * diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake index 75b5bd4a56..59044113c1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake @@ -147,8 +147,8 @@ set(FILES Entity/SliceEditorEntityOwnershipServiceBus.h Fingerprinting/TypeFingerprinter.h Fingerprinting/TypeFingerprinter.cpp - Logger/TraceLogger.cpp - Logger/TraceLogger.h + Logger/TraceLogger.cpp + Logger/TraceLogger.h Manipulators/AngularManipulator.cpp Manipulators/AngularManipulator.h Manipulators/BaseManipulator.cpp From 6a0257b5090415d6b059361a8a6536bc9ff5e270 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Thu, 15 Jul 2021 16:23:46 -0500 Subject: [PATCH 28/37] Reverting changes to AtomTools windows Signed-off-by: Dayo Lawal --- .../Source/Window/MaterialEditorWindow.cpp | 5 +- .../Code/Source/Window/MaterialEditorWindow.h | 6 +-- .../Window/ShaderManagementConsoleWindow.cpp | 49 +++++++++---------- .../Window/ShaderManagementConsoleWindow.h | 4 +- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp index 34962806cc..7c3a912b95 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp @@ -116,11 +116,11 @@ namespace MaterialEditor vl->addWidget(m_materialViewport); m_centralWidget->setLayout(vl); setCentralWidget(m_centralWidget); - + m_statusBar = new StatusBarWidget(this); m_statusBar->setObjectName("StatusBar"); statusBar()->addPermanentWidget(m_statusBar, 1); - + SetupMenu(); SetupTabs(); @@ -754,7 +754,6 @@ namespace MaterialEditor m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); } } - } // namespace MaterialEditor #include diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h index 8c288abca9..165767ecc5 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.h @@ -75,13 +75,13 @@ namespace MaterialEditor void OnDocumentSaved(const AZ::Uuid& documentId) override; void SetupMenu(); - void SetupTabs(); + void SetupTabs(); void AddTabForDocumentId(const AZ::Uuid& documentId); void RemoveTabForDocumentId(const AZ::Uuid& documentId); void UpdateTabForDocumentId(const AZ::Uuid& documentId); - AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; QString GetDocumentPath(const AZ::Uuid& documentId) const; + AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const; void OpenTabContextMenu(); void SelectPreviousTab(); @@ -90,8 +90,8 @@ namespace MaterialEditor void closeEvent(QCloseEvent* closeEvent) override; AzQtComponents::FancyDocking* m_advancedDockManager = nullptr; - QMenuBar* m_menuBar = nullptr; QWidget* m_centralWidget = nullptr; + QMenuBar* m_menuBar = nullptr; AzQtComponents::TabWidget* m_tabWidget = nullptr; MaterialViewportWidget* m_materialViewport = nullptr; MaterialEditorToolBar* m_toolBar = nullptr; diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp index fea10dfb7a..103299a361 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.cpp @@ -39,10 +39,10 @@ namespace ShaderManagementConsole ShaderManagementConsoleWindow::ShaderManagementConsoleWindow(QWidget* parent /* = 0 */) : AzQtComponents::DockMainWindow(parent) { - m_advancedDockManager = new AzQtComponents::FancyDocking(this); - setWindowTitle("Shader Management Console"); - setObjectName("ShaderManagementConsoleWindow"); + + m_advancedDockManager = new AzQtComponents::FancyDocking(this); + setDockNestingEnabled(true); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); @@ -50,16 +50,13 @@ namespace ShaderManagementConsole setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); m_menuBar = new QMenuBar(this); - m_menuBar->setObjectName("MenuBar"); setMenuBar(m_menuBar); m_toolBar = new ShaderManagementConsoleToolBar(this); - m_toolBar->setObjectName("ToolBar"); addToolBar(m_toolBar); m_centralWidget = new QWidget(this); m_tabWidget = new AzQtComponents::TabWidget(m_centralWidget); - m_tabWidget->setObjectName("TabWidget"); m_tabWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); m_tabWidget->setContentsMargins(0, 0, 0, 0); @@ -146,7 +143,7 @@ namespace ShaderManagementConsole m_actionUndo->setEnabled(canUndo); m_actionRedo->setEnabled(canRedo); - m_actionSettings->setEnabled(false); + m_actionPreferences->setEnabled(false); m_actionAssetBrowser->setEnabled(true); m_actionPythonTerminal->setEnabled(true); @@ -266,9 +263,9 @@ namespace ShaderManagementConsole m_menuEdit->addSeparator(); - m_actionSettings = m_menuEdit->addAction("&Preferences...", [this]() { + m_actionPreferences = m_menuEdit->addAction("&Preferences...", [this]() { }, QKeySequence::Preferences); - m_actionSettings->setEnabled(false); + m_actionPreferences->setEnabled(false); m_menuView = m_menuBar->addMenu("&View"); @@ -474,6 +471,23 @@ namespace ShaderManagementConsole } } + void ShaderManagementConsoleWindow::SelectPreviousTab() + { + if (m_tabWidget->count() > 1) + { + // Adding count to wrap around when index <= 0 + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); + } + } + + void ShaderManagementConsoleWindow::SelectNextTab() + { + if (m_tabWidget->count() > 1) + { + m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); + } + } + void ShaderManagementConsoleWindow::SelectDocumentForTab(const int tabIndex) { const AZ::Uuid documentId = GetDocumentIdFromTab(tabIndex); @@ -554,23 +568,6 @@ namespace ShaderManagementConsole } } } - - void ShaderManagementConsoleWindow::SelectPreviousTab() - { - if (m_tabWidget->count() > 1) - { - // Adding count to wrap around when index <= 0 - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + m_tabWidget->count() - 1) % m_tabWidget->count()); - } - } - - void ShaderManagementConsoleWindow::SelectNextTab() - { - if (m_tabWidget->count() > 1) - { - m_tabWidget->setCurrentIndex((m_tabWidget->currentIndex() + 1) % m_tabWidget->count()); - } - } } // namespace ShaderManagementConsole #include diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h index f35000ce26..0f8824f809 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleWindow.h @@ -60,8 +60,8 @@ namespace ShaderManagementConsole void OnDocumentSaved(const AZ::Uuid& documentId) override; void SetupMenu(); - void SetupTabs(); + void SetupTabs(); void AddTabForDocumentId(const AZ::Uuid& documentId); void RemoveTabForDocumentId(const AZ::Uuid& documentId); void UpdateTabForDocumentId(const AZ::Uuid& documentId); @@ -105,7 +105,7 @@ namespace ShaderManagementConsole QMenu* m_menuEdit = {}; QAction* m_actionUndo = {}; QAction* m_actionRedo = {}; - QAction* m_actionSettings = {}; + QAction* m_actionPreferences = {}; QMenu* m_menuView = {}; QAction* m_actionAssetBrowser = {}; From b2a4cf711ec15230ff0c9722f12774ba36bfef36 Mon Sep 17 00:00:00 2001 From: scspaldi Date: Fri, 16 Jul 2021 12:39:17 -0700 Subject: [PATCH 29/37] Removed AutomatedLauncherTesting Gem and LauncherTestTools. Signed-off-by: scspaldi --- Gems/AutomatedLauncherTesting/CMakeLists.txt | 8 - .../Code/CMakeLists.txt | 44 --- .../AutomatedLauncherTestingBus.h | 27 -- .../Source/AutomatedLauncherTestingModule.cpp | 47 --- ...utomatedLauncherTestingSystemComponent.cpp | 230 -------------- .../AutomatedLauncherTestingSystemComponent.h | 114 ------- .../Code/Source/SpawnDynamicSlice.cpp | 53 ---- .../Code/Source/SpawnDynamicSlice.h | 24 -- .../Code/automatedlaunchertesting_files.cmake | 14 - ...utomatedlaunchertesting_shared_files.cmake | 10 - Gems/AutomatedLauncherTesting/gem.json | 12 - Gems/AutomatedLauncherTesting/preview.png | 3 - Tools/LauncherTestTools/__init__.py | 5 - .../device_farm_create_bundle.py | 80 ----- .../device_farm_create_bundle_startergame.bat | 10 - ...ice_farm_default_device_pool_template.json | 7 - .../device_farm_schedule_run.py | 286 ------------------ ..._farm_schedule_run_android_startergame.bat | 14 - ..._run_execution_configuration_template.json | 4 - ...evice_farm_schedule_run_ios_startergame.sh | 9 - ...evice_farm_schedule_run_test_template.json | 5 - .../device_farm_test_spec_android.yaml | 16 - .../device_farm_test_spec_ios.yaml | 16 - Tools/LauncherTestTools/run_launcher_tests.py | 131 -------- .../run_launcher_tests_android.py | 108 ------- .../run_launcher_tests_ios.py | 91 ------ .../run_launcher_tests_local_validation.py | 77 ----- .../run_launcher_tests_win.py | 66 ---- ...cal_launcher_test_win_automatedtesting.bat | 11 - engine.json | 1 - 30 files changed, 1523 deletions(-) delete mode 100644 Gems/AutomatedLauncherTesting/CMakeLists.txt delete mode 100644 Gems/AutomatedLauncherTesting/Code/CMakeLists.txt delete mode 100644 Gems/AutomatedLauncherTesting/Code/Include/AutomatedLauncherTesting/AutomatedLauncherTestingBus.h delete mode 100644 Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingModule.cpp delete mode 100644 Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.cpp delete mode 100644 Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.h delete mode 100644 Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.cpp delete mode 100644 Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.h delete mode 100644 Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_files.cmake delete mode 100644 Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_shared_files.cmake delete mode 100644 Gems/AutomatedLauncherTesting/gem.json delete mode 100644 Gems/AutomatedLauncherTesting/preview.png delete mode 100755 Tools/LauncherTestTools/__init__.py delete mode 100755 Tools/LauncherTestTools/device_farm_create_bundle.py delete mode 100644 Tools/LauncherTestTools/device_farm_create_bundle_startergame.bat delete mode 100644 Tools/LauncherTestTools/device_farm_default_device_pool_template.json delete mode 100755 Tools/LauncherTestTools/device_farm_schedule_run.py delete mode 100644 Tools/LauncherTestTools/device_farm_schedule_run_android_startergame.bat delete mode 100644 Tools/LauncherTestTools/device_farm_schedule_run_execution_configuration_template.json delete mode 100755 Tools/LauncherTestTools/device_farm_schedule_run_ios_startergame.sh delete mode 100644 Tools/LauncherTestTools/device_farm_schedule_run_test_template.json delete mode 100644 Tools/LauncherTestTools/device_farm_test_spec_android.yaml delete mode 100644 Tools/LauncherTestTools/device_farm_test_spec_ios.yaml delete mode 100755 Tools/LauncherTestTools/run_launcher_tests.py delete mode 100755 Tools/LauncherTestTools/run_launcher_tests_android.py delete mode 100755 Tools/LauncherTestTools/run_launcher_tests_ios.py delete mode 100755 Tools/LauncherTestTools/run_launcher_tests_local_validation.py delete mode 100755 Tools/LauncherTestTools/run_launcher_tests_win.py delete mode 100644 Tools/LauncherTestTools/run_local_launcher_test_win_automatedtesting.bat diff --git a/Gems/AutomatedLauncherTesting/CMakeLists.txt b/Gems/AutomatedLauncherTesting/CMakeLists.txt deleted file mode 100644 index 34bce0825f..0000000000 --- a/Gems/AutomatedLauncherTesting/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# -# 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 -# -# - -add_subdirectory(Code) diff --git a/Gems/AutomatedLauncherTesting/Code/CMakeLists.txt b/Gems/AutomatedLauncherTesting/Code/CMakeLists.txt deleted file mode 100644 index 41c81bc3f1..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# -# 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 -# -# - -ly_add_target( - NAME AutomatedLauncherTesting.Static STATIC - NAMESPACE Gem - FILES_CMAKE - automatedlaunchertesting_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Source - PUBLIC - Include - BUILD_DEPENDENCIES - PUBLIC - AZ::AzCore - Legacy::CryCommon - Gem::LmbrCentral -) - -ly_add_target( - NAME AutomatedLauncherTesting ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE} - NAMESPACE Gem - FILES_CMAKE - automatedlaunchertesting_shared_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - Source - PUBLIC - Include - BUILD_DEPENDENCIES - PRIVATE - Gem::AutomatedLauncherTesting.Static - RUNTIME_DEPENDENCIES - Gem::LmbrCentral -) - -# servers and clients use the above module. -ly_create_alias(NAME AutomatedLauncherTesting.Servers NAMESPACE Gem TARGETS Gem::AutomatedLauncherTesting) -ly_create_alias(NAME AutomatedLauncherTesting.Clients NAMESPACE Gem TARGETS Gem::AutomatedLauncherTesting) diff --git a/Gems/AutomatedLauncherTesting/Code/Include/AutomatedLauncherTesting/AutomatedLauncherTestingBus.h b/Gems/AutomatedLauncherTesting/Code/Include/AutomatedLauncherTesting/AutomatedLauncherTestingBus.h deleted file mode 100644 index f5cad4827c..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/Include/AutomatedLauncherTesting/AutomatedLauncherTestingBus.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 - -namespace AutomatedLauncherTesting -{ - class AutomatedLauncherTestingRequests - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // EBusTraits overrides - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - ////////////////////////////////////////////////////////////////////////// - - // Call this method from your test logic when a test is complete. - virtual void CompleteTest(bool success, const AZStd::string& message) = 0; - }; - using AutomatedLauncherTestingRequestBus = AZ::EBus; -} // namespace AutomatedLauncherTesting diff --git a/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingModule.cpp b/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingModule.cpp deleted file mode 100644 index 4dfad2ecbd..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingModule.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 -#include - -#include - - -namespace AutomatedLauncherTesting -{ - class AutomatedLauncherTestingModule - : public AZ::Module - { - public: - AZ_RTTI(AutomatedLauncherTestingModule, "{3FC3E44A-0AC0-47C5-BD02-ADB2BA4338CA}", AZ::Module); - AZ_CLASS_ALLOCATOR(AutomatedLauncherTestingModule, AZ::SystemAllocator, 0); - - AutomatedLauncherTestingModule() - : AZ::Module() - { - // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here. - m_descriptors.insert(m_descriptors.end(), { - AutomatedLauncherTestingSystemComponent::CreateDescriptor(), - }); - } - - /** - * Add required SystemComponents to the SystemEntity. - */ - AZ::ComponentTypeList GetRequiredSystemComponents() const override - { - return AZ::ComponentTypeList{ - azrtti_typeid(), - }; - } - }; -} - -// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM -// The first parameter should be GemName_GemIdLower -// The second should be the fully qualified name of the class above -AZ_DECLARE_MODULE_CLASS(Gem_AutomatedLauncherTesting, AutomatedLauncherTesting::AutomatedLauncherTestingModule) diff --git a/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.cpp b/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.cpp deleted file mode 100644 index fd1e0b5a54..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * 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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "SpawnDynamicSlice.h" -#include - - -namespace AutomatedLauncherTesting -{ - void AutomatedLauncherTestingSystemComponent::Reflect(AZ::ReflectContext* context) - { - if (AZ::SerializeContext* serialize = azrtti_cast(context)) - { - serialize->Class() - ->Version(0); - - if (AZ::EditContext* ec = serialize->GetEditContext()) - { - ec->Class("AutomatedLauncherTesting", "[Description of functionality provided by this System Component]") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System")) - ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ; - } - } - - if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) - { - behaviorContext->EBus("AutomatedLauncherTestingRequestBus") - ->Attribute(AZ::Script::Attributes::Category, "Testing") - ->Event("CompleteTest", &AutomatedLauncherTestingRequestBus::Events::CompleteTest) - ; - } - } - - void AutomatedLauncherTestingSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) - { - provided.push_back(AZ_CRC("AutomatedLauncherTestingService")); - } - - void AutomatedLauncherTestingSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) - { - incompatible.push_back(AZ_CRC("AutomatedLauncherTestingService")); - } - - void AutomatedLauncherTestingSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) - { - AZ_UNUSED(required); - } - - void AutomatedLauncherTestingSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent) - { - AZ_UNUSED(dependent); - } - - void AutomatedLauncherTestingSystemComponent::Init() - { - } - - void AutomatedLauncherTestingSystemComponent::Activate() - { - AutomatedLauncherTestingRequestBus::Handler::BusConnect(); - CrySystemEventBus::Handler::BusConnect(); - AZ::TickBus::Handler::BusConnect(); - } - - void AutomatedLauncherTestingSystemComponent::Deactivate() - { - AZ::TickBus::Handler::BusDisconnect(); - CrySystemEventBus::Handler::BusDisconnect(); - AutomatedLauncherTestingRequestBus::Handler::BusDisconnect(); - } - - void AutomatedLauncherTestingSystemComponent::CompleteTest(bool success, const AZStd::string& message) - { - AZ_Assert( - m_phase == Phase::RunningTest, - "Expected current phase to be RunningTest (%d), got %d, will skip printing CompleteTest message.", - Phase::RunningTest, m_phase); - - if (m_phase == Phase::RunningTest) - { - if (!message.empty()) - { - LogAlways("AutomatedLauncher: %s", message.c_str()); - } - - // Make sure this is always printed, in case log severity is turned down. - LogAlways("AutomatedLauncher: %s", success ? "AUTO_LAUNCHER_TEST_COMPLETE" : "AUTO_LAUNCHER_TEST_FAIL"); - - m_phase = Phase::Complete; - } - } - - void AutomatedLauncherTestingSystemComponent::OnCrySystemInitialized(ISystem& system, [[maybe_unused]] const SSystemInitParams& systemInitParams) - { - m_system = &system; - // Only allow any testing to actually happen in non-release builds. -#if !defined(_RELEASE) - ICmdLine* cmdLine = m_system->GetICmdLine(); - if (cmdLine) - { - AZ_Printf("AutomatedLauncher", "Checking for automated launcher testing command line arguments."); - const ICmdLineArg* mapArg = cmdLine->FindArg(eCLAT_Pre, "ltest_map"); - if (mapArg) - { - AZStd::string map = mapArg->GetValue(); - AZ_Printf("AutomatedLauncher", "Found ltest_map arg %s.", map.c_str()); - if(map.compare("default") != 0) - { - AZStd::lock_guard lock(m_testOperationsMutex); - m_testOperations.push_back(TestOperation(TestOperationType::LoadMap, map.c_str())); - } - else - { - // Allow the default menu to load, watch for the next level to load - m_phase = Phase::LoadingMap; - m_nextLevelLoad = NextLevelLoad::WatchForNextLevelLoad; - } - } - - const ICmdLineArg* sliceArg = cmdLine->FindArg(eCLAT_Pre, "ltest_slice"); - if (sliceArg) - { - AZStd::string slice = sliceArg->GetValue(); - AZ_Printf("AutomatedLauncher", "Found ltest_slice arg %s.", slice.c_str()); - - AzFramework::StringFunc::Tokenize(slice.c_str(), m_slices, ","); - - if (!m_slices.empty()) - { - AZStd::lock_guard lock(m_testOperationsMutex); - m_testOperations.push_back(TestOperation(TestOperationType::SpawnDynamicSlice, m_slices[0].c_str())); - m_slices.erase(m_slices.begin()); - } - } - } -#endif - } - - void AutomatedLauncherTestingSystemComponent::OnCrySystemShutdown([[maybe_unused]] ISystem& system) - { - m_system = nullptr; - } - - void AutomatedLauncherTestingSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) - { - // Check to see if there is a load map operation in flight - if (m_currentTestOperation.m_type == TestOperationType::LoadMap && !m_currentTestOperation.m_complete) - { - if (m_system->GetSystemGlobalState() == ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_COMPLETE) - { - m_currentTestOperation.m_complete = true; - } - } - // Only start a new operation if there isn't already one in flight right now. - else if (!m_testOperations.empty()) - { - // Grab the first operation from the list - { - AZStd::lock_guard lock(m_testOperationsMutex); - m_currentTestOperation = m_testOperations.at(0); - m_testOperations.erase(m_testOperations.begin()); - } - - // If it was a map command, go ahead and launch it. - if (m_currentTestOperation.m_type == TestOperationType::LoadMap) - { - AZ_Assert(m_phase == Phase::None, "Expected current phase to be None (%d), got %d", Phase::None, m_phase); - AZStd::string command = AZStd::string::format("map %s", m_currentTestOperation.m_value.c_str()); - m_system->GetIConsole()->ExecuteString(command.c_str()); - m_phase = Phase::LoadingMap; - } - // If it was a spawn dynamic slice command, go ahead and spawn it. - else if (m_currentTestOperation.m_type == TestOperationType::SpawnDynamicSlice) - { - AZ_Assert((m_phase == Phase::LoadingMap) || (m_phase == Phase::RunningTest), "Expected current phase to be LoadMap or RunningTest (%d), got %d", Phase::LoadingMap, m_phase); - AZ::Entity* spawnedEntity = SpawnDynamicSlice::CreateSpawner(m_currentTestOperation.m_value, "Automated Testing Dynamic Slice Spawner"); - if (spawnedEntity) - { - m_spawnedEntities.emplace_back(std::move(spawnedEntity)); - } - m_phase = Phase::RunningTest; - } - } - else if ((m_nextLevelLoad == NextLevelLoad::None) && (m_phase == Phase::RunningTest) && (m_system->GetSystemGlobalState() == ESYSTEM_GLOBAL_STATE_RUNNING)) - { - AZ_Printf("AutomatedLauncher", "Running Test - Watching for a next level load"); - m_nextLevelLoad = NextLevelLoad::WatchForNextLevelLoad; - } - else if ((m_nextLevelLoad == NextLevelLoad::WatchForNextLevelLoad) && (m_system->GetSystemGlobalState() == ESYSTEM_GLOBAL_STATE_LEVEL_LOAD_COMPLETE)) - { - AZ_Printf("AutomatedLauncher", "Next level loaded, adding operations"); - if (!m_slices.empty()) - { - m_testOperations.push_back(TestOperation(TestOperationType::SpawnDynamicSlice, m_slices[0].c_str())); - m_slices.erase(m_slices.begin()); - - m_nextLevelLoad = NextLevelLoad::None; - } - else - { - m_nextLevelLoad = NextLevelLoad::LevelLoadsComplete; - } - } - } - - void AutomatedLauncherTestingSystemComponent::LogAlways(const char* format, ...) - { - va_list args; - va_start(args, format); - m_system->GetILog()->LogV(ILog::eAlways, format, args); - va_end(args); - } -} diff --git a/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.h b/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.h deleted file mode 100644 index 6ab5ed710e..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/Source/AutomatedLauncherTestingSystemComponent.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 - -#include -#include -#include -#include -#include - -namespace AZ -{ - class Entity; -} - -namespace AutomatedLauncherTesting -{ - class AutomatedLauncherTestingSystemComponent - : public AZ::Component - , protected AutomatedLauncherTestingRequestBus::Handler - , private CrySystemEventBus::Handler - , private AZ::TickBus::Handler - { - - private: - enum class Phase - { - None, - LoadingMap, - RunningTest, - Complete - }; - - enum class NextLevelLoad - { - None, - WatchForNextLevelLoad, - LevelLoadsComplete - }; - - enum class TestOperationType - { - None, - LoadMap, - SpawnDynamicSlice - }; - - struct TestOperation - { - TestOperation() - { - } - - TestOperation(TestOperationType type, const AZStd::string& value) - : m_type(type) - , m_value(value) - - { - } - - TestOperationType m_type = TestOperationType::None; - AZStd::string m_value; - bool m_complete = false; - }; - - public: - AZ_COMPONENT(AutomatedLauncherTestingSystemComponent, "{87A405E2-390B-43A9-9A96-94BDC0DF680B}"); - - static void Reflect(AZ::ReflectContext* context); - - static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); - static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); - static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); - static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent); - - protected: - //////////////////////////////////////////////////////////////////////// - // AutomatedLauncherTestingRequestBus interface implementation - void CompleteTest(bool success, const AZStd::string& message) override; - //////////////////////////////////////////////////////////////////////// - - protected: - //////////////////////////////////////////////////////////////////////////// - // CrySystemEvents - void OnCrySystemInitialized(ISystem& system, const SSystemInitParams& systemInitParams) override; - void OnCrySystemShutdown(ISystem& system) override; - - // AZ::Component interface implementation - void Init() override; - void Activate() override; - void Deactivate() override; - - // TickBus - void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; - - void LogAlways(const char* format, ...); - - private: - ISystem* m_system = nullptr; - AZStd::vector m_testOperations; - AZStd::vector m_slices; - MutexType m_testOperationsMutex; - TestOperation m_currentTestOperation; - AZStd::vector> m_spawnedEntities; - Phase m_phase = Phase::None; - NextLevelLoad m_nextLevelLoad = NextLevelLoad::None; - }; -} diff --git a/Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.cpp b/Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.cpp deleted file mode 100644 index 3b555d58a0..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 "SpawnDynamicSlice.h" - -#include -#include -#include -#include - - -namespace AutomatedLauncherTesting -{ - AZ::Entity* SpawnDynamicSlice::CreateSpawner(const AZStd::string& path, const AZStd::string& entityName) - { - AZ::Entity* spawnerEntity = nullptr; - - AZ::Data::AssetId sliceAssetId; - AZ::Data::AssetCatalogRequestBus::BroadcastResult(sliceAssetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, path.c_str(), AZ::Data::s_invalidAssetType, false); - if (sliceAssetId.IsValid()) - { - AZ_Printf("System", "Spawning dynamic slide %s", path.c_str()); - spawnerEntity = aznew AZ::Entity(entityName.c_str()); - spawnerEntity->Init(); - - LmbrCentral::SpawnerConfig spawnerConfig; - - AZ::Data::Asset sliceAssetData = AZ::Data::AssetManager::Instance().GetAsset(sliceAssetId, spawnerConfig.m_sliceAsset.GetAutoLoadBehavior()); - sliceAssetData.BlockUntilLoadComplete(); - - AZ::Component* spawnerComponent = nullptr; - AZ::ComponentDescriptorBus::EventResult(spawnerComponent, LmbrCentral::SpawnerComponentTypeId, &AZ::ComponentDescriptorBus::Events::CreateComponent); - - spawnerConfig.m_sliceAsset = sliceAssetData; - spawnerConfig.m_spawnOnActivate = true; - spawnerComponent->SetConfiguration(spawnerConfig); - - spawnerEntity->AddComponent(spawnerComponent); - - spawnerEntity->Activate(); - } - else - { - AZ_Warning("System", false, "Could not create asset for dynamic slide %s", path.c_str()); - } - - return spawnerEntity; - } - -} // namespace AutomatedLauncherTesting diff --git a/Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.h b/Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.h deleted file mode 100644 index 1bc161ca90..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/Source/SpawnDynamicSlice.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 - -namespace AZ -{ - class Entity; -} - -namespace AutomatedLauncherTesting -{ - class SpawnDynamicSlice - { - public: - static AZ::Entity* CreateSpawner(const AZStd::string& path, const AZStd::string& entityName); - }; - -} // namespace AutomatedLauncherTesting diff --git a/Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_files.cmake b/Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_files.cmake deleted file mode 100644 index f6c1942225..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_files.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# -# 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 -# -# - -set(FILES - Include/AutomatedLauncherTesting/AutomatedLauncherTestingBus.h - Source/AutomatedLauncherTestingSystemComponent.cpp - Source/AutomatedLauncherTestingSystemComponent.h - Source/SpawnDynamicSlice.cpp - Source/SpawnDynamicSlice.h -) diff --git a/Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_shared_files.cmake b/Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_shared_files.cmake deleted file mode 100644 index e810bc132f..0000000000 --- a/Gems/AutomatedLauncherTesting/Code/automatedlaunchertesting_shared_files.cmake +++ /dev/null @@ -1,10 +0,0 @@ -# -# 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 -# -# - -set(FILES - Source/AutomatedLauncherTestingModule.cpp -) diff --git a/Gems/AutomatedLauncherTesting/gem.json b/Gems/AutomatedLauncherTesting/gem.json deleted file mode 100644 index c7ecd02739..0000000000 --- a/Gems/AutomatedLauncherTesting/gem.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "gem_name": "AutomatedLauncherTesting", - "display_name": "Automated Launcher Testing", - "license": "Apache-2.0 Or MIT", - "origin": "Open 3D Engine - o3de.org", - "type": "Code", - "summary": "The Automated Launcher Testing Gem manages automated Open 3D Engine (O3DE) launcher tests.", - "canonical_tags": ["Gem"], - "user_tags": ["Debug", "Tools"], - "icon_path": "preview.png", - "requirements": "" -} diff --git a/Gems/AutomatedLauncherTesting/preview.png b/Gems/AutomatedLauncherTesting/preview.png deleted file mode 100644 index 2f1ed47754..0000000000 --- a/Gems/AutomatedLauncherTesting/preview.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6d6204c6730e5675791765ca194e9b1cbec282208e280507de830afc2805e5fa -size 41127 diff --git a/Tools/LauncherTestTools/__init__.py b/Tools/LauncherTestTools/__init__.py deleted file mode 100755 index 99aac69543..0000000000 --- a/Tools/LauncherTestTools/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -""" -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 -""" \ No newline at end of file diff --git a/Tools/LauncherTestTools/device_farm_create_bundle.py b/Tools/LauncherTestTools/device_farm_create_bundle.py deleted file mode 100755 index 793bc109af..0000000000 --- a/Tools/LauncherTestTools/device_farm_create_bundle.py +++ /dev/null @@ -1,80 +0,0 @@ -""" -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 - -Device Farm Create Bundle -""" - -import argparse -import logging -import os -import shutil -import stat - -logger = logging.getLogger(__name__) - - -def on_rm_error( func, path, exc_info): - # path contains the path of the file that couldn't be removed - # let's just assume that it's read-only and unlink it. - os.chmod( path, stat.S_IWRITE ) - os.unlink( path ) - -def copy_python_code_tree(src, dest): - shutil.copytree(src, dest, ignore=shutil.ignore_patterns('*.pyc', '__pycache__')) - -def create_test_bundle(project, project_launcher_tests_folder, python_test_tools_folder): - - temp_folder = os.path.join('temp', project) - - # Place all artifacts to send to device farm in this output folder - zip_output_folder = os.path.join(temp_folder, 'zip_output') - - # clear the old virtual env folder - logger.info("deleting old zip folder ...") - if os.path.isdir(zip_output_folder): - logger.info("Removing virtual env folder \"{}\" ...".format(zip_output_folder)) - shutil.rmtree(zip_output_folder, onerror = on_rm_error) - - # create the output folder where we dump everything to be zipped up. - os.makedirs(zip_output_folder) - - # core files to add (iOS won't be referenced on Android, but it won't hurt anything) - core_files = [ - 'run_launcher_tests.py', - 'run_launcher_tests_ios.py', - 'run_launcher_tests_android.py', - os.path.join('..', '..', project, 'project.json')] - for file in core_files: - shutil.copy2(file, os.path.join(zip_output_folder, os.path.basename(file))) - - logger.info("Including test code ...") - test_output_folder = os.path.join(zip_output_folder, 'tests') - copy_python_code_tree(project_launcher_tests_folder, test_output_folder) - - # Copy remote console from PythonTestTools - logger.info("Including python PythonTestTools remote console ...") - shutil.copy2( - os.path.join(python_test_tools_folder, 'shared', 'remote_console_commands.py'), - os.path.join(test_output_folder, 'remote_console_commands.py')) - - # Zip the tests/ folder, wheelhouse/ folder, and the requirements.txt file into a single archive: - test_bundle_path = os.path.join(temp_folder, 'test_bundle') - logger.info("Generating test bundle zip {} ...".format(test_bundle_path)) - shutil.make_archive(test_bundle_path, 'zip', zip_output_folder) - -def main(): - - parser = argparse.ArgumentParser(description='Create the test bundle zip file for use on the Device Farm.') - parser.add_argument('--project', required=True, help='Lumberyard Project') - parser.add_argument('--project-launcher-tests-folder', required=True, help='Absolute path of the folder that contains the test code source.') - parser.add_argument('--python-test-tools-folder', required=True, help='Absolute path of the PythonTestTools folder.') - args = parser.parse_args() - - logging.basicConfig(level=logging.DEBUG) - - create_test_bundle(args.project, args.project_launcher_tests_folder, args.python_test_tools_folder) - -if __name__== "__main__": - main() diff --git a/Tools/LauncherTestTools/device_farm_create_bundle_startergame.bat b/Tools/LauncherTestTools/device_farm_create_bundle_startergame.bat deleted file mode 100644 index aca4458ac5..0000000000 --- a/Tools/LauncherTestTools/device_farm_create_bundle_startergame.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off -REM -REM 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. -REM -REM SPDX-License-Identifier: Apache-2.0 OR MIT -REM -REM -REM - -python device_farm_create_bundle.py --project StarterGame --project-launcher-tests-folder "../../StarterGame/LauncherTests" --python-test-tools-folder "../PythonTestTools/test_tools" diff --git a/Tools/LauncherTestTools/device_farm_default_device_pool_template.json b/Tools/LauncherTestTools/device_farm_default_device_pool_template.json deleted file mode 100644 index edc92d6dff..0000000000 --- a/Tools/LauncherTestTools/device_farm_default_device_pool_template.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "attribute": "ARN", - "operator": "IN", - "value": "[%DEVICE_ARN_LIST%]" - } -] \ No newline at end of file diff --git a/Tools/LauncherTestTools/device_farm_schedule_run.py b/Tools/LauncherTestTools/device_farm_schedule_run.py deleted file mode 100755 index 50928cd196..0000000000 --- a/Tools/LauncherTestTools/device_farm_schedule_run.py +++ /dev/null @@ -1,286 +0,0 @@ -""" -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 - -Device Farm Schecule Run -""" - -import argparse -import datetime -import json -import logging -import os -import subprocess -import sys -import time -import requests - -logger = logging.getLogger(__name__) - - - -def bake_template(filename, values): - """Open a template and replace values. Return path to baked file.""" - # Open the options json template and replace with real values. - with open(filename, 'r') as in_file: - data = in_file.read() - for key, value in values.iteritems(): - data = data.replace(key, str(value)) - filename_out = os.path.join('temp', filename) - with open(filename_out, 'w') as out_file: - out_file.write(data) - return filename_out - -def execute_aws_command(args): - """ Execut the aws cli devicefarm command. """ - # Use .cmd on Windows, not sure exactly why, but aws will not be found without it. - aws_executable = 'aws.cmd' if sys.platform.startswith('win') else 'aws' - aws_args = [aws_executable, 'devicefarm', '--region', 'us-west-2'] + args - logger.info("Running {} ...".format(" ".join(aws_args))) - p = subprocess.Popen(aws_args, stdout=subprocess.PIPE) - out, err = p.communicate() - if p.returncode != 0: - msg = "Command '{}' failed. return code: {} out: {} err: {}".format( - " ".join(aws_args), - p.returncode, - out, - err - ) - raise Exception(msg) - return out - - -def find_or_create_project(project_name): - """ Find the project by name, or create a new one. """ - list_projects_data = json.loads(execute_aws_command(['list-projects'])) - - # return the arn if it is found - for project_data in list_projects_data['projects']: - if project_data['name'] == project_name: - logger.info("Found existing project named {}.".format(project_name)) - return project_data['arn'] - - # project not found, create a new project with the give name - project_data = json.loads(execute_aws_command(['create-project', '--name', project_name])) - return project_data['project']['arn'] - -def find_or_create_device_pool(project_name, device_pool_name, device_arns): - """ Find the device pool in the project by name, or create a new one. """ - list_device_pools_data = json.loads(execute_aws_command(['list-device-pools', '--arn', project_name])) - - # return the arn if it is found - for device_pool_data in list_device_pools_data['devicePools']: - if device_pool_data['name'] == device_pool_name: - logger.info("Found existing device pool named {}.".format(device_pool_name)) - return device_pool_data['arn'] - - device_pool_json_path_out = bake_template( - 'device_farm_default_device_pool_template.json', - {'%DEVICE_ARN_LIST%' : device_arns}) - - # create a default device pool - args = [ - 'create-device-pool', - '--project-arn', - project_name, - '--name', - device_pool_name, - '--rules', - "file://{}".format(device_pool_json_path_out)] - device_pools_data = json.loads(execute_aws_command(args)) - return device_pools_data['devicePool']['arn'] - - -def create_upload(project_arn, path, type): - """ Create an upload and return the ARN """ - args = ['create-upload', '--project-arn', project_arn, '--name', os.path.basename(path), '--type', type] - upload_data = json.loads(execute_aws_command(args)) - return upload_data['upload']['arn'], upload_data['upload']['url'] - -def send_upload(filename, url): - """ Upload a file with a put request. """ - logger.info("Sending upload {} ...".format(filename)) - with open(filename, 'rb') as uploadfile: - data = uploadfile.read() - headers = {"content-type": "application/octet-stream"} - output = requests.put(url, data=data, allow_redirects=True, headers=headers) - logger.info("Sent upload {}.".format(output)) - -def wait_for_upload_to_finish(poll_time, upload_arn): - """ Wait for an upload to finish by polling for status """ - logger.info("Waiting for upload {} ...".format(upload_arn)) - upload_data = json.loads(execute_aws_command(['get-upload', '--arn', upload_arn])) - while not upload_data['upload']['status'] in ['SUCCEEDED', 'FAILED']: - time.sleep(poll_time) - upload_data = json.loads(execute_aws_command(['get-upload', '--arn', upload_arn])) - - if upload_data['upload']['status'] != 'SUCCEEDED': - raise Exception('Upload failed.') - -def upload(poll_time, project_arn, path, type): - """ Create the upload on the Device Farm, upload the file and wait for completion. """ - arn, url = create_upload(project_arn, path, type) - send_upload(path, url) - wait_for_upload_to_finish(poll_time, arn) - return arn - -def schedule_run(project_arn, app_arn, device_pool_arn, test_spec_arn, test_bundle_arn, execution_timeout): - """ Schecule the test run on the Device Farm """ - run_name = "LY LT {}".format(datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")) - logger.info("Scheduling run {} ...".format(run_name)) - - schedule_run_test_json_path_out = bake_template( - 'device_farm_schedule_run_test_template.json', - {'%TEST_SPEC_ARN%' : test_spec_arn, '%TEST_PACKAGE_ARN%' : test_bundle_arn}) - - execution_configuration_json_path_out = bake_template( - 'device_farm_schedule_run_execution_configuration_template.json', - {'%EXECUTION_TIMEOUT%' : execution_timeout}) - - args = [ - 'schedule-run', - '--project-arn', - project_arn, - '--app-arn', - app_arn, - '--device-pool-arn', - device_pool_arn, - '--name', - "\"{}\"".format(run_name), - '--test', - "file://{}".format(schedule_run_test_json_path_out), - '--execution-configuration', - "file://{}".format(execution_configuration_json_path_out)] - - schedule_run_data = json.loads(execute_aws_command(args)) - return schedule_run_data['run']['arn'] - -def download_file(url, output_path): - """ download a file from a url, save in output_path """ - try: - r = requests.get(url, stream=True) - r.raise_for_status() - output_folder = os.path.dirname(output_path) - if not os.path.exists(output_folder): - os.makedirs(output_folder) - with open(output_path, 'wb') as f: - for chunk in r.iter_content(chunk_size=8192): - if chunk: - f.write(chunk) - except requests.exceptions.RequestException as e: - logging.exception("Failed request for downloading file from {}.".format(url)) - return False - except IOError as e: - logging.exception("Failed writing to file {}.".format(output_path)) - return False - return True - -def download_artifacts(run_arn, artifacts_output_folder): - """ - Download run artifacts and write to path set in artifacts_output_folder. - """ - logging.basicConfig(level=logging.DEBUG) - - list_jobs_data = json.loads(execute_aws_command(['list-jobs', '--arn', run_arn])) - for job_data in list_jobs_data['jobs']: - logger.info("Downloading artifacts for {} ...".format(job_data['name'])) - safe_job_name = "".join(x for x in job_data['name'] if x.isalnum()) - list_artifacts_data = json.loads(execute_aws_command(['list-artifacts', '--arn', job_data['arn'], '--type', 'FILE'])) - for artifact_data in list_artifacts_data['artifacts']: - # A run may contain many jobs. Usually each job is one device type. - # Each job has 3 stages: setup, test and shutdown. You can tell what - # stage an artifact is from based on the ARN. - # We only care about artifacts from the main stage of the job, - # not the setup or tear down artifacts. So parse the ARN and look - # for the 00001 identifier. - print artifact_data['arn'] - if artifact_data['arn'].split('/')[3] == '00001': - logger.info("Downloading artifacts {} ...".format(artifact_data['name'])) - output_filename = "{}.{}".format( - "".join(x for x in artifact_data['name'] if x.isalnum()), - artifact_data['extension']) - output_path = os.path.join(artifacts_output_folder, safe_job_name, output_filename) - if not download_file(artifact_data['url'], output_path): - msg = "Failed to download file from {} and save to {}".format(artifact_data['url'], output_path) - logger.error(msg) - -def main(): - - parser = argparse.ArgumentParser(description='Upload and app and schedule a run on the Device Farm.') - parser.add_argument('--app-path', required=True, help='Path of the app file.') - parser.add_argument('--test-spec-path', required=True, help='Path of the test spec yaml.') - parser.add_argument('--test-bundle-path', required=True, help='Path of the test bundle zip.') - parser.add_argument('--project-name', required=True, help='The name of the project.') - parser.add_argument('--device-pool-name', required=True, help='The name of the device pool.') - parser.add_argument('--device-arns', - default='\\"arn:aws:devicefarm:us-west-2::device:6CCDF49186B64E3FB27B9346AC9FAEC1\\"', - help='List of device ARNs. Used when existing pool is not found by name. Default is Galaxy S8.') - parser.add_argument('--wait-for-result', default="true", help='Set to "true" to wait for result of run.') - parser.add_argument('--download-artifacts', default="true", help='Set to "true" to download artifacts after run. requires --wait-for-result') - parser.add_argument('--artifacts-output-folder', default="temp", help='Folder to place the downloaded artifacts.') - parser.add_argument('--upload-poll-time', default=10, help='How long to wait between polling upload status.') - parser.add_argument('--run-poll-time', default=60, help='How long to wait between polling run status.') - parser.add_argument('--run-execution-timeout', default=60, help='Run execution timeout.') - parser.add_argument('--test-names', nargs='+', help='A list of test names to run, default runs all tests.') - - - args = parser.parse_args() - - logging.basicConfig(level=logging.DEBUG) - - # Find the project by name, or create a new one. - project_arn = find_or_create_project(args.project_name) - - # Find the device pool in the project by name, or create a new one. - device_pool_arn = find_or_create_device_pool(project_arn, args.device_pool_name, args.device_arns) - - # Bake out EXTRA_ARGS option with args.test_names - extra_args = "" - if args.test_names: - extra_args = "--test-names {}".format(" ".join("\"{}\"".format(test_name) for test_name in args.test_names)) - - test_spec_path_out = bake_template( - args.test_spec_path, - {'%EXTRA_ARGS%' : extra_args}) - - # Upload test spec and test bundle (Appium js is just a generic avenue to our own custom code). - test_spec_arn = upload(args.upload_poll_time, project_arn, test_spec_path_out, 'APPIUM_NODE_TEST_SPEC') - test_bundle_arn = upload(args.upload_poll_time, project_arn, args.test_bundle_path, 'APPIUM_NODE_TEST_PACKAGE') - - # Upload the app. - type = 'ANDROID_APP' if args.app_path.lower().endswith('.apk') else 'IOS_APP' - app_arn = upload(args.upload_poll_time, project_arn, args.app_path, type) - - # Schedule the test run. - run_arn = schedule_run(project_arn, app_arn, device_pool_arn, test_spec_arn, test_bundle_arn, args.run_execution_timeout) - - logger.info('Run scheduled.') - - # Wait for run, exit with failure if test run fails. - # strcmp with true for easy of use jenkins boolean env var. - if args.wait_for_result.lower() == 'true': - - # Runs can take a long time, so just poll once a mintue by default. - run_data = json.loads(execute_aws_command(['get-run', '--arn', run_arn])) - while run_data['run']['result'] == 'PENDING': - logger.info("Run status: {} waiting {} seconds ...".format(run_data['run']['result'], args.run_poll_time)) - time.sleep(args.run_poll_time) - run_data = json.loads(execute_aws_command(['get-run', '--arn', run_arn])) - - # Download run artifacts. strcmp with true for easy of use jenkins boolean env var. - if args.download_artifacts.lower() == 'true': - download_artifacts(run_arn, args.artifacts_output_folder) - - # If the run did not pass raise an exception to fail this jenkins job. - if run_data['run']['result'] != 'PASSED': - # Dump all of the run info. - logger.info(run_data) - # Raise an exception to fail this test. - msg = "Run fail with result {}\nRun ARN: {}".format(run_data['run']['result'], run_arn) - raise Exception(msg) - - logger.info('Run passed.') - -if __name__== "__main__": - main() diff --git a/Tools/LauncherTestTools/device_farm_schedule_run_android_startergame.bat b/Tools/LauncherTestTools/device_farm_schedule_run_android_startergame.bat deleted file mode 100644 index 83bbaed213..0000000000 --- a/Tools/LauncherTestTools/device_farm_schedule_run_android_startergame.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off -REM -REM 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. -REM -REM SPDX-License-Identifier: Apache-2.0 OR MIT -REM -REM -REM - -call ../../python/python.cmd run_launcher_tests_local_validation.py --dev-root-folder "../.." --project "StarterGame" -if %ERRORLEVEL% == 0 ( -call ../../python/python.cmd device_farm_create_bundle.py --project StarterGame --project-launcher-tests-folder "../../StarterGame/LauncherTests" --python-test-tools-folder "../PythonTestTools/test_tools" -call ../../python/python.cmd device_farm_schedule_run.py --app-path "../../BinAndroidArmv8Clang/StarterGameLauncher_w_assets.apk" --project-name "LyAutomatedLauncher" --device-pool-name "LyAndroid" --test-spec-path "device_farm_test_spec_android.yaml" --test-bundle-path "temp/StarterGame/test_bundle.zip" --artifacts-output-folder "temp/StarterGame" -) \ No newline at end of file diff --git a/Tools/LauncherTestTools/device_farm_schedule_run_execution_configuration_template.json b/Tools/LauncherTestTools/device_farm_schedule_run_execution_configuration_template.json deleted file mode 100644 index 55109c32cc..0000000000 --- a/Tools/LauncherTestTools/device_farm_schedule_run_execution_configuration_template.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "jobTimeoutMinutes": %EXECUTION_TIMEOUT%, - "videoCapture": true -} diff --git a/Tools/LauncherTestTools/device_farm_schedule_run_ios_startergame.sh b/Tools/LauncherTestTools/device_farm_schedule_run_ios_startergame.sh deleted file mode 100755 index 1010c8638e..0000000000 --- a/Tools/LauncherTestTools/device_farm_schedule_run_ios_startergame.sh +++ /dev/null @@ -1,9 +0,0 @@ -# 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 -# - -../../python/python.sh run_launcher_tests_local_validation.py --dev-root-folder "../.." --project "StarterGame" || exit -../../python/python.sh device_farm_create_bundle.py --project StarterGame --project-launcher-tests-folder "../../StarterGame/LauncherTests" --python-test-tools-folder "../PythonTestTools/test_tools" -# Current known limitation on iOS, only one test at a time is supported, see run_launcher_tests_ios.py run_test -../../python/python.sh device_farm_schedule_run.py --app-path "$1" --project-name "LyAutomatedLauncherIOS" --device-pool-name "LyIOS" --test-spec-path "device_farm_test_spec_ios.yaml" --test-bundle-path "temp/StarterGame/test_bundle.zip" --artifacts-output-folder "temp/StarterGame" --device-arns "\\\"arn:aws:devicefarm:us-west-2::device:D125AEEE8614463BAE106865CAF4470E\\\"" --test-names "progress" diff --git a/Tools/LauncherTestTools/device_farm_schedule_run_test_template.json b/Tools/LauncherTestTools/device_farm_schedule_run_test_template.json deleted file mode 100644 index 27d66b4a95..0000000000 --- a/Tools/LauncherTestTools/device_farm_schedule_run_test_template.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "APPIUM_NODE", - "testPackageArn": "%TEST_PACKAGE_ARN%", - "testSpecArn": "%TEST_SPEC_ARN%" -} diff --git a/Tools/LauncherTestTools/device_farm_test_spec_android.yaml b/Tools/LauncherTestTools/device_farm_test_spec_android.yaml deleted file mode 100644 index f032f461f9..0000000000 --- a/Tools/LauncherTestTools/device_farm_test_spec_android.yaml +++ /dev/null @@ -1,16 +0,0 @@ -version: 0.1 -phases: - install: - commands: - - pre_test: - commands: - - adb -P 5037 -s "$DEVICEFARM_DEVICE_UDID" install -r $DEVICEFARM_APP_PATH - - test: - commands: - - python ./run_launcher_tests_android.py --project-json-path "./project.json" --project-launcher-tests-folder "./tests" --screenshots-folder "$SCREENSHOT_PATH" %EXTRA_ARGS% - - post_test: - commands: - \ No newline at end of file diff --git a/Tools/LauncherTestTools/device_farm_test_spec_ios.yaml b/Tools/LauncherTestTools/device_farm_test_spec_ios.yaml deleted file mode 100644 index f2bcbaf38f..0000000000 --- a/Tools/LauncherTestTools/device_farm_test_spec_ios.yaml +++ /dev/null @@ -1,16 +0,0 @@ -version: 0.1 -phases: - install: - commands: - - pre_test: - commands: - - idevicedebug -u $DEVICEFARM_DEVICE_UDID run com.amazon.lumberyard.startergame - - sleep 10s - - test: - commands: - - python ./run_launcher_tests_ios.py --project-json-path "./project.json" --project-launcher-tests-folder "./tests" --screenshots-folder "$SCREENSHOT_PATH" %EXTRA_ARGS% - - post_test: - commands: diff --git a/Tools/LauncherTestTools/run_launcher_tests.py b/Tools/LauncherTestTools/run_launcher_tests.py deleted file mode 100755 index 8dbc91ff66..0000000000 --- a/Tools/LauncherTestTools/run_launcher_tests.py +++ /dev/null @@ -1,131 +0,0 @@ -""" -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 -""" - -import json -import logging -import os -import time -import shutil -import subprocess -import sys - -logger = logging.getLogger(__name__) - - -class PlatformDriver: - - def __init__(self, project_json_path, project_launcher_tests_folder, test_names, screenshots_folder, screenshots_interval): - self.project_json_path = project_json_path - self.project_launcher_tests_folder = project_launcher_tests_folder - self.test_names = test_names - self.screenshots_folder = screenshots_folder - self.screenshots_interval = screenshots_interval - - def read_json_data(self, path): - """Read a json file and return the data""" - try: - with open(path) as json_file: - json_data = json.load(json_file) - except Exception, e: - logger.error("Failed to read json file: '{}'".format(path)) - logger.error("Exception: '{}'".format(e)) - sys.exit(1) - return json_data - - def read_project_name(self): - project_data = self.read_json_data(self.project_json_path) - return project_data['project_name'] - - - def run_test(self, map, dynamic_slice, timeout, pass_string, fail_string): - """ Meant to be overridden in derived classes. """ - return True - - def run_launcher_tests(self): - """Discovers all of the available tests in launcher_tests.json and runs them. - """ - # Delete the old screenshots folder if it exists - if os.path.exists(self.screenshots_folder): - shutil.rmtree(self.screenshots_folder) - - # Read the launcher_tests.json file. - launcher_tests_data = self.read_json_data(os.path.join(self.project_launcher_tests_folder, 'launcher_tests.json')) - - # Run each of the tests found in the launcher_tests.json file. - ok = True - for launcher_test_data in launcher_tests_data['launcher_tests']: - - # Skip over this test if specific tests are specified and this is not one of them. - if self.test_names and launcher_test_data.get('name').lower() not in [x.lower() for x in self.test_names]: - continue - - ok = ok and self.run_test( - launcher_test_data.get('name'), - launcher_test_data.get('map'), - launcher_test_data.get('dynamic_slice'), - launcher_test_data.get('timeout'), - launcher_test_data.get('pass_string', 'AUTO_LAUNCHER_TEST_COMPLETE'), - launcher_test_data.get('fail_string', 'AUTO_LAUNCHER_TEST_FAIL')) - return ok - - def monitor_process_output(self, test_name, command, pass_string, fail_string, timeout, log_file=None): - - self.process = subprocess.Popen(command, stdout=subprocess.PIPE) - - # On windows, function was failing (I think) because it checked the poll before the process - # had a chance to start, so added a short delay to give it some time to startup. - # It also failed if the log_file was open()'d when it didn't exist yet. - # Delay seems to have fixed the problem. 0.25 sec was too short. - time.sleep(0.5) - - if log_file: - # The process we're starting sends it's output to the log file instead of stdout - # so we need to monitor that instead of the stdout. - fp = open(log_file) - - # Detect log output messages or timeout exceeded - start = time.time() - last_time = start - screenshot_time_remaining = self.screenshots_interval - screenshot_index = 0 - logger.info('Waiting for test to complete.') - message = "" - result = False - while True: - if log_file: - line = fp.readline() - else: - line = self.process.stdout.readline() - if line == '' and self.process.poll() is not None: - break - if line: - logger.info(line.rstrip()) - if pass_string in line: - message = "Detected {}. Test completed.".format(pass_string) - result = True - break - if fail_string in line: - message = "Detected {}. Test failed.".format(fail_string) - break - if time.time() - start > timeout: - message = "Timeout of {} reached. Test failed.".format(timeout) - break - - rc = self.process.poll() - cur_time = time.time() - screenshot_time_remaining = screenshot_time_remaining - (cur_time - last_time) - last_time = cur_time - if screenshot_time_remaining <= 0: - self.take_screenshot(os.path.join(self.screenshots_folder, "{}_screen{}".format(test_name.replace(' ', '_'), screenshot_index))) - screenshot_index = screenshot_index + 1 - screenshot_time_remaining = self.screenshots_interval - - logger.info(message) - - if log_file: - fp.close() - - return result diff --git a/Tools/LauncherTestTools/run_launcher_tests_android.py b/Tools/LauncherTestTools/run_launcher_tests_android.py deleted file mode 100755 index bf1311924e..0000000000 --- a/Tools/LauncherTestTools/run_launcher_tests_android.py +++ /dev/null @@ -1,108 +0,0 @@ -""" -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 -""" - -import argparse -import itertools -import logging -import os -from run_launcher_tests import PlatformDriver -import subprocess -import time - -logger = logging.getLogger(__name__) - - -class AndroidDriver(PlatformDriver): - - def read_package_name(self): - project_data = self.read_json_data(self.project_json_path) - return project_data['android_settings']['package_name'] - - def run_test(self, test_name, map, dynamic_slice, timeout, pass_string, fail_string): - - package = self.read_package_name() - project = self.read_project_name() - package_and_activity = "{}/{}.{}Activity".format(package, package, project) - - # clear any old logcat - command_line = ['adb', 'logcat', '-c'] - p = subprocess.Popen(command_line) - p.communicate() - - # increase ring buffer size because we are going to be printing a large amount of data in a short time. - command_line = ['adb', 'logcat', '-G', '10m'] - p = subprocess.Popen(command_line) - p.communicate() - - # Start the process and pass in the test args - logger.info("Start the activity {} ...".format(package_and_activity)) - command_line = ['adb', 'shell', 'am', 'start', '-a', 'android.intent.action.MAIN', '-n', package_and_activity] - command_line += ['-e', 'ltest_map', map] - command_line += ['-e', 'ltest_slice', dynamic_slice] - p = subprocess.Popen(command_line) - p.communicate() - - # Get the pid of the app to use in the logcat monitoring. If we don't - # do this we might get residual output from previous test run. Even - # though we do a clear. - for _ in itertools.repeat(None, 10): - command_line = ['adb', 'shell', 'pidof', package] - p = subprocess.Popen(command_line, stdout=subprocess.PIPE) - stdoutdata, stderrdata = p.communicate() - pid = stdoutdata.strip() - if pid: - logger.info("Get pid of {}".format(pid)) - break - else: - logger.info('Failed to get pid, waiting 1 second to retry ...') - time.sleep(1) - if not pid: - raise Exception('Unable to determin the pid of the process.') - - command_line = ['adb', '-d', 'logcat', "--pid={}".format(pid), 'LMBR:I', '*:S'] - test_result = self.monitor_process_output(test_name, command_line, pass_string, fail_string, timeout) - - logger.info("Kill the app ...") - p = subprocess.Popen(['adb', 'shell', 'am', 'force-stop', package]) - p.communicate() - - # Stop here if we failed. - if not test_result: - raise Exception("Test failed.") - - def take_screenshot(self, output_path_no_ext): - # Create the output folder if it is not there - output_folder = os.path.dirname(output_path_no_ext) - if not os.path.exists(output_folder): - os.makedirs(output_folder) - - # Take the screenshot - p = subprocess.Popen(['adb', 'shell', 'screencap', '-p', '/sdcard/screen.png']) - p.communicate() - - # copy it off of the device - p = subprocess.Popen(['adb', 'pull', '/sdcard/screen.png', "{}.png".format(output_path_no_ext)]) - p.communicate() - -def main(): - - parser = argparse.ArgumentParser(description='Sets up and runs Android Launcher Tests.') - parser.add_argument('--project-json-path', required=True, help='Path to the project.json project settings file.') - parser.add_argument('--project-launcher-tests-folder', required=True, help='Path to the LauncherTests folder in a Project.') - parser.add_argument('--test-names', nargs='+', help='A list of test names to run, default runs all tests.') - parser.add_argument('--screenshots-folder', default="./temp/Android/screenshots", help='Output folder for screenshots.') - parser.add_argument('--screenshots-interval', default=5, help='Time interval between taking screenshots in seconds.') - - args = parser.parse_args() - - logging.basicConfig(level=logging.DEBUG) - - logger.info("Running Launcher tests at {} ...".format(args.project_launcher_tests_folder)) - driver = AndroidDriver(args.project_json_path, args.project_launcher_tests_folder, args.test_names, args.screenshots_folder, args.screenshots_interval) - driver.run_launcher_tests() - -if __name__== "__main__": - main() diff --git a/Tools/LauncherTestTools/run_launcher_tests_ios.py b/Tools/LauncherTestTools/run_launcher_tests_ios.py deleted file mode 100755 index 844c7ea9b7..0000000000 --- a/Tools/LauncherTestTools/run_launcher_tests_ios.py +++ /dev/null @@ -1,91 +0,0 @@ -""" -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 -""" - -import argparse -import logging -import os -from run_launcher_tests import PlatformDriver -import subprocess - -logger = logging.getLogger(__name__) - - -class IOSDriver(PlatformDriver): - - def __init__(self, project_json_path, project_launcher_tests_folder, test_names, screenshots_folder, screenshots_interval, device_udid): - self.project_json_path = project_json_path - self.project_launcher_tests_folder = project_launcher_tests_folder - self.test_names = test_names - self.screenshots_folder = screenshots_folder - self.screenshots_interval = screenshots_interval - self.device_udid = device_udid - - def run_test(self, test_name, map, dynamic_slice, timeout, pass_string, fail_string): - - project = self.read_project_name() - bundle_id = "com.amazon.lumberyard.{}".format(project) - - # Start the process and pass in the test args - command_line = ['idevicedebug', '-u', self.device_udid, 'run', bundle_id] - command_line += ['-ltest_map', map] - command_line += ['-ltest_slice', dynamic_slice] - test_result = self.monitor_process_output(test_name, command_line, pass_string, fail_string, timeout) - - # TODO: Figure out some way to kill the running app. Because we dont know how to do this, - # we currently have a limitation on iOS we can only run one test at a time. - - # Stop here if we failed. - if not test_result: - raise Exception("Test failed.") - - def take_screenshot(self, output_path_no_ext): - # Create the output folder if it is not there - output_folder = os.path.dirname(output_path_no_ext) - if not os.path.exists(output_folder): - os.makedirs(output_folder) - - # idevicescreenshot to take a screenshot and save to output path. - p = subprocess.Popen(['idevicescreenshot', "{}.tiff".format(output_path_no_ext)]) - p.communicate() - -def discover_device(): - """ Discover the connected device and get the UDID.""" - logger.info("Getting the connected device UDID ...") - p = subprocess.Popen(['idevice_id', '--list'], stdout=subprocess.PIPE) - out, err = p.communicate() - if not out: - raise Exception("No output.\nout:{}\nerr:{}\n".format(out, err)) - - lines = out.splitlines() - if not len(lines): - raise Exception("No devices connected.\nout:{}\nerr:{}\n".format(out, err)) - if len(lines) != 1: - raise Exception("More than one device connected. Use --device-udid\nout:{}\nerr:{}\n".format(out, err)) - return lines[0] - -def main(): - - parser = argparse.ArgumentParser(description='Sets up and runs iOS Launcher Tests.') - parser.add_argument('--project-json-path', required=True, help='Path to the project.json project settings file.') - parser.add_argument('--project-launcher-tests-folder', required=True, help='Path to the LauncherTests folder in a Project.') - parser.add_argument('--device-udid', help='The UDID of the iOS device. Will auto detect if just one device is attached.') - parser.add_argument('--test-names', nargs='+', help='A list of test names to run, default runs all tests.') - parser.add_argument('--screenshots-folder', default="./temp/iOS/screenshots", help='Output folder for screenshots.') - parser.add_argument('--screenshots-interval', default=5, help='Time interval between taking screenshots in seconds.') - args = parser.parse_args() - - logging.basicConfig(level=logging.DEBUG) - - device_udid = args.device_udid - if not device_udid: - device_udid = discover_device() - - logger.info("Running Launcher tests at {} ...".format(args.project_launcher_tests_folder)) - driver = IOSDriver(args.project_json_path, args.project_launcher_tests_folder, args.test_names, args.screenshots_folder, args.screenshots_interval, device_udid) - driver.run_launcher_tests() - -if __name__== "__main__": - main() diff --git a/Tools/LauncherTestTools/run_launcher_tests_local_validation.py b/Tools/LauncherTestTools/run_launcher_tests_local_validation.py deleted file mode 100755 index 175e809ce2..0000000000 --- a/Tools/LauncherTestTools/run_launcher_tests_local_validation.py +++ /dev/null @@ -1,77 +0,0 @@ -""" -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 -""" - -import argparse -import json -import logging -import os -import sys - -logger = logging.getLogger(__name__) - - -def report_error_and_exit(msg): - """Log an error message and exit with error code 1.""" - logger.error(msg) - sys.exit(1) - -def check_autoexe_cfg(dev_root_folder, project): - """ - Make sure that the project's autoexec.cfg does not contain a Map command. - The Launcher Test framework is responsible for loading the map. - """ - # Open the autoexec.cfg file and read the contents - autoexec_cfg_path = os.path.join(dev_root_folder, project, 'autoexec.cfg') - try: - with open(autoexec_cfg_path) as f: - content = f.readlines() - except: - report_error_and_exit("Failed to read contents of {}".format(autoexec_cfg_path)) - - # Make sure no map command is detected, the Launcher Test code will be in charge of loading a map - for line in content: - if line.lower().startswith('map '): - report_error_and_exit("Map command '{}' detected in {}".format(line.strip(), autoexec_cfg_path)) - -def check_gems_enabled(dev_root_folder, project): - """Check the project's gems to make sure the AutomatedLauncherTesting gem is enabled.""" - # Read the gems.json file - gems_json_path = os.path.join(dev_root_folder, project, 'gems.json') - try: - with open(gems_json_path) as f: - json_data = json.load(f) - except: - report_error_and_exit("Failed to read contents of {}".format(gems_json_path)) - - # Make sure AutomatedLauncherTesting is enabled - found = False - for gem_data in json_data['Gems']: - if 'AutomatedLauncherTesting' in gem_data['Path']: - found = True - break - - if not found: - report_error_and_exit("Automated Launcer Testing GEM not enabled in {}".format(gems_json_path)) - -def main(): - - parser = argparse.ArgumentParser(description='Run validation on the local environment to check for required Launcher Tests config.') - parser.add_argument('--dev-root-folder', required=True, help='Path to the root Lumberyard dev folder.') - parser.add_argument('--project', required=True, help='Lumberyard project.') - args = parser.parse_args() - - logging.basicConfig(level=logging.DEBUG) - - logger.info("Running validation for project {} ...".format(args.project)) - - check_autoexe_cfg(args.dev_root_folder, args.project) - - check_gems_enabled(args.dev_root_folder, args.project) - - logger.info('Validation complete.') - -if __name__== '__main__': - main() diff --git a/Tools/LauncherTestTools/run_launcher_tests_win.py b/Tools/LauncherTestTools/run_launcher_tests_win.py deleted file mode 100755 index ba6e42b8e4..0000000000 --- a/Tools/LauncherTestTools/run_launcher_tests_win.py +++ /dev/null @@ -1,66 +0,0 @@ -""" -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 -""" - -import argparse -import logging -import os -from run_launcher_tests import PlatformDriver - -import test_tools.platforms.win.win as win -from test_tools.shared.platform_map import PLATFORM_MAP - -logger = logging.getLogger(__name__) - -class WinDriver(PlatformDriver): - - def __init__(self, project_json_path, project_launcher_tests_folder): - self.project_json_path = project_json_path - self.project_launcher_tests_folder = project_launcher_tests_folder - - self.platform_map = PLATFORM_MAP[win.platform_name() + "_" + win.default_compiler_option()] - - - def run_test(self, map, dynamic_slice, timeout, pass_string, fail_string): - - project = self.read_project_name() - - # Start the process and pass in the test args - - dev_dir = os.path.dirname(os.path.realpath(__file__)) - dev_dir = os.path.join(dev_dir, os.path.pardir) - dev_dir = os.path.join(dev_dir, os.path.pardir) - dev_dir = os.path.realpath(dev_dir) - launcher_dir = os.path.join(dev_dir, self.platform_map["bin_dir"]) - command_line = [os.path.join(launcher_dir, project + 'Launcher.exe')] - command_line += ['-ltest_map', map] - command_line += ['-ltest_slice', dynamic_slice] - log_file = os.path.join(dev_dir, "cache", project, "pc", "user", "log", "Game.log") - test_result = self.monitor_process_output(command_line, pass_string, fail_string, timeout, log_file) - - if self.process: - self.process.kill() - - # Stop here if we failed. - if not test_result: - raise Exception("Test failed.") - - return test_result - -def main(): - - parser = argparse.ArgumentParser(description='Sets up and runs Windows Launcher Tests.') - parser.add_argument('--project-json-path', required=True, help='Path to the project.json project settings file.') - parser.add_argument('--project-launcher-tests-folder', required=True, help='Path to the LauncherTests folder in a Project.') - args = parser.parse_args() - - logging.basicConfig(level=logging.DEBUG) - - logger.info("Running Launcher tests at {} ...".format(args.project_launcher_tests_folder)) - driver = WinDriver(args.project_json_path, args.project_launcher_tests_folder) - driver.run_launcher_tests() - -if __name__== "__main__": - main() diff --git a/Tools/LauncherTestTools/run_local_launcher_test_win_automatedtesting.bat b/Tools/LauncherTestTools/run_local_launcher_test_win_automatedtesting.bat deleted file mode 100644 index 0fc8ada332..0000000000 --- a/Tools/LauncherTestTools/run_local_launcher_test_win_automatedtesting.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off -REM -REM 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. -REM -REM SPDX-License-Identifier: Apache-2.0 OR MIT -REM -REM -REM - -REM Provided as an example of how to run the Automated Launcher Test on a developer's local machine. -../../python/python.cmd run_launcher_tests_win.py --project-json-path "../../SamplesProject/project.json" --project-launcher-tests-folder "../../SamplesProject/LauncherTests" \ No newline at end of file diff --git a/engine.json b/engine.json index a6f6ecba8c..07b4b7baa2 100644 --- a/engine.json +++ b/engine.json @@ -15,7 +15,6 @@ "Gems/AtomTressFX", "Gems/AudioEngineWwise", "Gems/AudioSystem", - "Gems/AutomatedLauncherTesting", "Gems/AWSClientAuth", "Gems/AWSCore", "Gems/AWSGameLift", From ebf0ea6a6949c522c332677c5e109ce4ca645687 Mon Sep 17 00:00:00 2001 From: srikappa-amzn Date: Fri, 16 Jul 2021 17:03:03 -0700 Subject: [PATCH 30/37] Remove container entity from all maps when entities are cleared from a prefab instance Signed-off-by: srikappa-amzn --- .../AzToolsFramework/Prefab/Instance/Instance.cpp | 6 +++++- .../AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp index fb7ede42fe..750efa1e36 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/Instance.cpp @@ -237,7 +237,6 @@ namespace AzToolsFramework if (m_containerEntity) { - m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId()); m_containerEntity.reset(aznew AZ::Entity()); RegisterEntity(m_containerEntity->GetId(), GenerateEntityAlias()); } @@ -265,6 +264,11 @@ namespace AzToolsFramework void Instance::ClearEntities() { + if (m_containerEntity) + { + m_instanceEntityMapper->UnregisterEntity(m_containerEntity->GetId()); + } + for (const auto&[entityAlias, entity] : m_entities) { if (entity) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp index a2b0f47f57..b5a354ee74 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp @@ -168,7 +168,6 @@ namespace AzToolsFramework if (instance->m_containerEntity) { - instance->m_instanceEntityMapper->UnregisterEntity(instance->m_containerEntity->GetId()); instance->m_containerEntity.reset(); } From 918224e2d53ff7c8f0c02acb01331551c3c05110 Mon Sep 17 00:00:00 2001 From: dmcdiar Date: Fri, 16 Jul 2021 18:21:50 -0700 Subject: [PATCH 31/37] Moved render checks to a ShouldRender() helper function. Skipped attachment readback on RealTime DiffuseProbeGrids if raytracing is not supported by the hardware. Signed-off-by: dmcdiar --- .../DiffuseProbeGridRenderPass.cpp | 55 +++++++++++++------ .../DiffuseProbeGridRenderPass.h | 5 ++ 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp index 29e7d42da8..55d8ca5cba 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include @@ -44,6 +45,7 @@ namespace AZ void DiffuseProbeGridRenderPass::FrameBeginInternal(FramePrepareParams params) { + RHI::Ptr device = RHI::RHISystemInterface::Get()->GetDevice(); RPI::Scene* scene = m_pipeline->GetScene(); DiffuseProbeGridFeatureProcessor* diffuseProbeGridFeatureProcessor = scene->GetFeatureProcessor(); @@ -67,10 +69,13 @@ namespace AZ Base::FrameBeginInternal(params); - for (auto& diffuseProbeGrid : diffuseProbeGridFeatureProcessor->GetRealTimeProbeGrids()) + // process attachment readback for RealTime grids, if raytracing is supported on this device + if (device->GetFeatures().m_rayTracing) { - // process attachment readback - diffuseProbeGrid->GetTextureReadback().FrameBegin(params); + for (auto& diffuseProbeGrid : diffuseProbeGridFeatureProcessor->GetRealTimeProbeGrids()) + { + diffuseProbeGrid->GetTextureReadback().FrameBegin(params); + } } } @@ -81,13 +86,7 @@ namespace AZ for (auto& diffuseProbeGrid : diffuseProbeGridFeatureProcessor->GetProbeGrids()) { - if (diffuseProbeGrid->GetMode() == DiffuseProbeGridMode::Baked && - !diffuseProbeGrid->HasValidBakedTextures()) - { - continue; - } - - if (!diffuseProbeGrid->GetIsVisible()) + if (!ShouldRender(diffuseProbeGrid)) { continue; } @@ -173,13 +172,7 @@ namespace AZ for (auto& diffuseProbeGrid : diffuseProbeGridFeatureProcessor->GetProbeGrids()) { - if (diffuseProbeGrid->GetMode() == DiffuseProbeGridMode::Baked && - !diffuseProbeGrid->HasValidBakedTextures()) - { - continue; - } - - if (!diffuseProbeGrid->GetIsVisible()) + if (!ShouldRender(diffuseProbeGrid)) { continue; } @@ -193,5 +186,33 @@ namespace AZ Base::CompileResources(context); } + + bool DiffuseProbeGridRenderPass::ShouldRender(const AZStd::shared_ptr& diffuseProbeGrid) + { + RHI::Ptr device = RHI::RHISystemInterface::Get()->GetDevice(); + + // check for baked mode with no valid textures + if (diffuseProbeGrid->GetMode() == DiffuseProbeGridMode::Baked && + !diffuseProbeGrid->HasValidBakedTextures()) + { + return false; + } + + // check for RealTime mode without ray tracing + if (diffuseProbeGrid->GetMode() == DiffuseProbeGridMode::RealTime && + !device->GetFeatures().m_rayTracing) + { + return false; + } + + // check if culled out + if (!diffuseProbeGrid->GetIsVisible()) + { + return false; + } + + // DiffuseProbeGrid should be rendered + return true; + } } // namespace Render } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h index 5531364b2d..6f4a91d9c6 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h @@ -14,6 +14,8 @@ namespace AZ { namespace Render { + class DiffuseProbeGrid; + //! This pass renders the diffuse global illumination in the area covered by //! each DiffuseProbeGrid. class DiffuseProbeGridRenderPass final @@ -40,6 +42,9 @@ namespace AZ void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override; void CompileResources(const RHI::FrameGraphCompileContext& context) override; + // helper function to determine if a DiffuseProbeGrid should be rendered based on its state + bool ShouldRender(const AZStd::shared_ptr& diffuseProbeGrid); + Data::Instance m_shader; RHI::Ptr m_srgLayout; }; From 080d10ede9ebee01c69ee46c70eb8144cc37e102 Mon Sep 17 00:00:00 2001 From: hultonha Date: Mon, 19 Jul 2021 11:53:56 +0100 Subject: [PATCH 32/37] continue to show cursor while using RMB until context menu pop-up is fixed Signed-off-by: hultonha --- Code/Editor/EditorViewportWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index d6b7ddc452..b052e7e222 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -103,7 +103,7 @@ AZ_CVAR( bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Output the timing of the new IVisibilitySystem query"); AZ_CVAR(bool, ed_useNewCameraSystem, true, nullptr, AZ::ConsoleFunctorFlags::Null, "Use the new Editor camera system"); -AZ_CVAR(bool, ed_showCursorCameraLook, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Show the cursor when using free look with the new camera system"); +AZ_CVAR(bool, ed_showCursorCameraLook, true, nullptr, AZ::ConsoleFunctorFlags::Null, "Show the cursor when using free look with the new camera system"); namespace SandboxEditor { From b01cd0c788ac54e80de05b767ff8b814a1f53340 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Mon, 19 Jul 2021 17:25:23 +0100 Subject: [PATCH 34/37] UI tweaks of the physics doc link widget (#2259) Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com> --- Gems/PhysX/Code/Editor/DocumentationLinkWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gems/PhysX/Code/Editor/DocumentationLinkWidget.cpp b/Gems/PhysX/Code/Editor/DocumentationLinkWidget.cpp index 348648ed7b..d5f8b0ca5b 100644 --- a/Gems/PhysX/Code/Editor/DocumentationLinkWidget.cpp +++ b/Gems/PhysX/Code/Editor/DocumentationLinkWidget.cpp @@ -21,8 +21,9 @@ namespace PhysX setTextInteractionFlags(Qt::TextBrowserInteraction); setOpenExternalLinks(true); setAlignment(Qt::AlignCenter); - setContentsMargins(60, 15, 60, 15); + setContentsMargins(60, 7, 60, 7); setWordWrap(true); + setStyleSheet(QString::fromUtf8("background-color: rgb(51, 51, 51);")); } } } From 9053079a56b5e750dccf41d63d7619326ae4263c Mon Sep 17 00:00:00 2001 From: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> Date: Mon, 19 Jul 2021 10:03:59 -0700 Subject: [PATCH 35/37] ATOM-15935 Adding draw to pass support to DynamicDrawContext (#2248) The DynamicDrawContext can output to different scopes: Scene, RenderPipeline or RasterPass. Updated RasterPass so it can handle not only draw calls from Views but also from DynamicDrawContexts. --- .../DynamicDraw/DynamicDrawContext.h | 65 ++++++-- .../DynamicDraw/DynamicDrawInterface.h | 13 +- .../DynamicDraw/DynamicDrawSystem.h | 5 +- .../Include/Atom/RPI.Public/Pass/RasterPass.h | 9 +- .../DynamicDraw/DynamicDrawContext.cpp | 154 ++++++++++++++---- .../DynamicDraw/DynamicDrawSystem.cpp | 44 ++--- .../Source/RPI.Public/Pass/RasterPass.cpp | 61 +++++-- .../Source/PerViewportDynamicDrawManager.cpp | 5 +- Gems/LyShine/Code/Source/Draw2d.cpp | 3 +- Gems/LyShine/Code/Source/UiRenderer.cpp | 3 +- 10 files changed, 261 insertions(+), 101 deletions(-) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawContext.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawContext.h index 620d5155ce..93e595243e 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawContext.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawContext.h @@ -18,6 +18,10 @@ namespace AZ { namespace RPI { + class Scene; + class RenderPipeline; + class RasterPass; + //! This class helps setup dynamic draw data as well as provide draw functions to draw dynamic items. //! The draw calls added to the context are only valid for one frame. //! DynamicDrawContext is only associated with @@ -80,17 +84,20 @@ namespace AZ //! This function can only be called before EndInit() is called void AddDrawStateOptions(DrawStateOptions options); + //! Call any one of these functions to decide which scope this DynamicDrawContext may draw to. + //! One of the function has to be called once before EndInit() is called. + //! After DynamicDrawContext is initialized, the output scope can be changed. + //! But it has to be called after existing draw calls are submitted. + //! @Param scene Draw calls made with this DynamicDrawContext will be submit to this scene + //! @Param pipeline Draw calls made with this DynamicDrawContext will be submit to this render pipeline + //! @Param pass Draw calls made with this DynamicDrawContext will only be submit to this pass + void SetOutputScope(Scene* scene); + void SetOutputScope(RenderPipeline* pipeline); + void SetOutputScope(RasterPass* pass); + //! Finalize and validate initialization. Any initialization functions should be called before EndInit is called. void EndInit(); - //! Set up the DynamicDrawContext for the input Scene. - //! This should be called after the last frame is done and before any draw calls. - void SetScene(Scene* scene); - - //! Set up the DynamicDrawContext for the input RenderPipeline. - //! This should be called after the last frame is done and before any draw calls. - void SetRenderPipeline(RenderPipeline* pipeline); - //! Return if this DynamicDrawContext is ready to add draw calls bool IsReady(); @@ -177,14 +184,21 @@ namespace AZ DynamicDrawContext() = default; // Submit draw items to a view - void SubmitDrawData(ViewPtr view); + void SubmitDrawList(ViewPtr view); + + // Finalize the draw list for all submiited draws. + void FinalizeDrawList(); + + RHI::DrawListView GetDrawList(); // Reset cached draw data when frame is end (draw data was submitted) void FrameEnd(); + void ReInit(); + // Get rhi pipeline state which matches current states const RHI::PipelineState* GetCurrentPipelineState(); - + struct MultiStates { // states available for change @@ -230,10 +244,22 @@ namespace AZ // Draw variations allowed in this DynamicDrawContext DrawStateOptions m_drawStateOptions; - // For generate output attachment layout and filter draw items - Scene* m_scene = nullptr; + // DrawListTag used to help setup PipelineState's output + // and also for submitting draw items to views RHI::DrawListTag m_drawListTag; + // Output scope related + enum class OutputScopeType + { + Unset, + Scene, + RenderPipeline, + RasterPass + }; + Scene* m_scene = nullptr; + RasterPass* m_pass = nullptr; + OutputScopeType m_outputScope = OutputScopeType::Unset; + // All draw items use this filter when submit them to views // It's set to RenderPipeline's draw filter mask if the DynamicDrawContext was created for a render pipeline. RHI::DrawFilterMask m_drawFilter = RHI::DrawFilterMaskDefaultValue; @@ -242,19 +268,22 @@ namespace AZ AZStd::vector m_cachedStreamBufferViews; AZStd::vector m_cachedIndexBufferViews; AZStd::vector> m_cachedDrawSrg; - + // structure includes DrawItem and stream and index buffer index - static const uint32_t InvalidIndex = static_cast(-1); + using BufferViewIndexType = uint32_t; + static const BufferViewIndexType InvalidIndex = static_cast(-1); struct DrawItemInfo { RHI::DrawItem m_drawItem; RHI::DrawItemSortKey m_sortKey; - uint32_t m_vertexBufferViewIndex = InvalidIndex; - uint32_t m_indexBufferViewIndex = InvalidIndex; + BufferViewIndexType m_vertexBufferViewIndex = InvalidIndex; + BufferViewIndexType m_indexBufferViewIndex = InvalidIndex; }; - AZStd::vector m_cachedDrawItems; + // Cached draw list for render to rasterpass + RHI::DrawList m_cachedDrawList; + // Flags if this DynamicDrawContext can change shader variants bool m_supportShaderVariants = false; ShaderVariantId m_currentShaderVariantId; @@ -266,6 +295,8 @@ namespace AZ bool m_initialized = false; RHI::DrawItemSortKey m_sortKey = 0; + + bool m_drawFinalized = false; }; AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::RPI::DynamicDrawContext::DrawStateOptions); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawInterface.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawInterface.h index 1b3a2248fb..cc2125af95 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawInterface.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawInterface.h @@ -48,15 +48,9 @@ namespace AZ AZ_DISABLE_COPY_MOVE(DynamicDrawInterface); - //! Create a DynamicDrawContext for specified scene (and render pipeline). - //! Draw calls which are made to this DynamicDrawContext will only be submitted for this scene. + //! Create a DynamicDrawContext //! The created DynamicDrawContext is managed by dynamic draw system. - virtual RHI::Ptr CreateDynamicDrawContext(Scene* scene) = 0; - - //! Create a DynamicDrawContext for specified render pipeline - //! Draw calls submitted through the context created by this function are only submitted - //! to the supplied render pipeline (viewport) - virtual RHI::Ptr CreateDynamicDrawContext(RenderPipeline* pipeline) = 0; + virtual RHI::Ptr CreateDynamicDrawContext() = 0; //! Get a DynamicBuffer from DynamicDrawSystem. //! The returned buffer will be invalidated every time the RPISystem's RenderTick is called @@ -69,6 +63,9 @@ namespace AZ //! Note that ownership of the DrawPacket pointer is passed to the dynamic draw system. //! (it will be cleaned up correctly since the DrawPacket keeps track of the allocator that was used when it was built) virtual void AddDrawPacket(Scene* scene, AZStd::unique_ptr drawPacket) = 0; + + //! Get DrawLists from any DynamicDrawContext which output to the specified RasterPass. + virtual AZStd::vector GetDrawListsForPass(const RasterPass* pass) = 0; }; //! Global function to query the DynamicDrawInterface. diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawSystem.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawSystem.h index 50bf82c79e..4210bca1db 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawSystem.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/DynamicDraw/DynamicDrawSystem.h @@ -31,14 +31,15 @@ namespace AZ void Shutdown(); // DynamicDrawInterface overrides... - RHI::Ptr CreateDynamicDrawContext(Scene* scene) override; - RHI::Ptr CreateDynamicDrawContext(RenderPipeline* pipeline) override; + RHI::Ptr CreateDynamicDrawContext() override; RHI::Ptr GetDynamicBuffer(uint32_t size, uint32_t alignment = 1) override; void DrawGeometry(Data::Instance material, const GeometryData& geometry, ScenePtr scene) override; void AddDrawPacket(Scene* scene, AZStd::unique_ptr drawPacket) override; + AZStd::vector GetDrawListsForPass(const RasterPass* pass) override; // Submit draw data for selected scene and pipeline void SubmitDrawData(Scene* scene, AZStd::vector views); + protected: void FrameEnd(); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RasterPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RasterPass.h index 05bd34a999..847fe36bd0 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RasterPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RasterPass.h @@ -55,6 +55,9 @@ namespace AZ void CompileResources(const RHI::FrameGraphCompileContext& context) override; void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override; + // Retrieve draw lists from view and dynamic draw system and generate final draw list + void UpdateDrawList(); + // The draw list tag used to fetch the draw list from the views RHI::DrawListTag m_drawListTag; @@ -62,8 +65,12 @@ namespace AZ // This is the index of the pipeline state data that corresponds to this pass in the array of pipeline state data RHI::Handle<> m_pipelineStateDataIndex; - // The draw list returned from the view + // The reference of the draw list to be drawn RHI::DrawListView m_drawListView; + + // If there are more than one draw lists from different source: View, DynamicDrawSystem, + // we need to creates a combined draw list which combines all the draw lists to one and cache it until they are submitted. + RHI::DrawList m_combinedDrawList; RHI::Scissor m_scissorState; RHI::Viewport m_viewportState; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp index cee61e27f3..7ca2bdcee5 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -173,9 +174,7 @@ namespace AZ void DynamicDrawContext::EndInit() { - AZ_Assert(m_scene != nullptr, "DynamicDrawContext should always belong to a scene"); - - AZ_Warning("RPI", m_pipelineState, "Failed to initialized shader for DynamicDrawContext"); + AZ_Warning("RPI", m_pipelineState, "Failed to initialize shader for DynamicDrawContext"); AZ_Warning("RPI", m_drawListTag.IsValid(), "DynamicDrawContext doesn't have a valid DrawListTag"); if (!m_drawListTag.IsValid() || m_pipelineState == nullptr) @@ -183,8 +182,27 @@ namespace AZ return; } - m_pipelineState->SetOutputFromScene(m_scene, m_drawListTag); - m_pipelineState->Finalize(); + if (m_outputScope == OutputScopeType::RenderPipeline || m_outputScope == OutputScopeType::Scene) + { + m_pipelineState->SetOutputFromScene(m_scene, m_drawListTag); + } + else if (m_outputScope == OutputScopeType::RasterPass) + { + m_pipelineState->SetOutputFromPass(m_pass); + } + else + { + AZ_Assert(false, "DynamicDrawContext need to set output scope before end initialization"); + return; + } + + m_rhiPipelineState = m_pipelineState->Finalize(); + + if (!m_rhiPipelineState) + { + AZ_Warning("RPI", false, "Failed to initialize PipelineState for DynamicDrawContext"); + return; + } m_initialized = true; // Acquire MultiStates from m_pipelineState @@ -199,16 +217,58 @@ namespace AZ m_rhiPipelineState = m_pipelineState->GetRHIPipelineState(); } - void DynamicDrawContext::SetScene(Scene* scene) + void DynamicDrawContext::SetOutputScope(Scene* scene) { - AZ_Assert(scene, "SetScene called with an invalid scene"); - if (!scene || m_scene == scene) + AZ_Assert(scene, "SetOutputScope was called with an invalid Scene"); + if (!scene) { return; } + + m_outputScope = OutputScopeType::Scene; m_scene = scene; + m_pass = nullptr; m_drawFilter = RHI::DrawFilterMaskDefaultValue; - // Reinitialize if it was initialized + + ReInit(); + } + + void DynamicDrawContext::SetOutputScope(RenderPipeline* pipeline) + { + AZ_Assert(pipeline, "SetOutputScope was called with an invalid RenderPipeline"); + AZ_Assert(pipeline->GetScene(), "SetOutputScope called with a RenderPipeline without adding to a scene"); + if (!pipeline || !pipeline->GetScene()) + { + return; + } + + m_outputScope = OutputScopeType::RenderPipeline; + m_scene = pipeline->GetScene(); + m_pass = nullptr; + m_drawFilter = pipeline->GetDrawFilterMask(); + + ReInit(); + } + + void DynamicDrawContext::SetOutputScope(RasterPass* pass) + { + AZ_Assert(pass, "SetOutputScope was called with an invalid RasterPass"); + if (!pass) + { + return; + } + + m_outputScope = OutputScopeType::RasterPass; + m_scene = nullptr; + m_pass = pass; + m_drawFilter = RHI::DrawFilterMaskDefaultValue; + + ReInit(); + } + + void DynamicDrawContext::ReInit() + { + // Reinitialize if it was initialized if (m_initialized) { // Report warning if there were some draw data @@ -224,17 +284,6 @@ namespace AZ } } - void DynamicDrawContext::SetRenderPipeline(RenderPipeline* pipeline) - { - AZ_Assert(pipeline, "SetRenderPipeline called with an invalid pipeline"); - if (!pipeline) - { - return; - } - SetScene(pipeline->GetScene()); - m_drawFilter = pipeline->GetDrawFilterMask(); - } - bool DynamicDrawContext::IsReady() { return m_initialized; @@ -402,10 +451,16 @@ namespace AZ AZ_Assert(false, "DynamicDrawContext isn't initialized"); return; } - - if (!m_drawSrgLayout) + + if (m_drawFinalized) { - AZ_Assert(false, "PerDrawSrg need to be provided since the shader uses it"); + AZ_Assert(false, "Can't add draw calls after draw data was finalized"); + return; + } + + if (m_drawSrgLayout && !drawSrg) + { + AZ_Assert(false, "drawSrg need to be provided since the shader requires it"); return; } @@ -446,12 +501,12 @@ namespace AZ vertexBuffer->Write(vertexData, vertexDataSize); m_cachedStreamBufferViews.push_back(vertexBuffer->GetStreamBufferView(m_perVertexDataSize)); drawItem.m_streamBufferViewCount = 1; - drawItemInfo.m_vertexBufferViewIndex = uint32_t(m_cachedStreamBufferViews.size() - 1); + drawItemInfo.m_vertexBufferViewIndex = static_cast(m_cachedStreamBufferViews.size() - 1); // Write data to index buffer and set up index buffer view for DrawItem indexBuffer->Write(indexData, indexDataSize); m_cachedIndexBufferViews.push_back(indexBuffer->GetIndexBufferView(indexFormat)); - drawItemInfo.m_indexBufferViewIndex = uint32_t(m_cachedIndexBufferViews.size() - 1); + drawItemInfo.m_indexBufferViewIndex = static_cast(m_cachedIndexBufferViews.size() - 1); // Setup per context srg if it exists if (m_srgPerContext) @@ -487,7 +542,7 @@ namespace AZ drawItemInfo.m_sortKey = m_sortKey++; m_cachedDrawItems.emplace_back(drawItemInfo); } - + void DynamicDrawContext::DrawLinear(const void* vertexData, uint32_t vertexCount, Data::Instance drawSrg) { if (!m_initialized) @@ -496,9 +551,15 @@ namespace AZ return; } - if (!m_drawSrgLayout) + if (m_drawFinalized) { - AZ_Assert(false, "PerDrawSrg need to be provided since the shader uses it"); + AZ_Assert(false, "Can't add draw calls after draw data was finalized"); + return; + } + + if (m_drawSrgLayout && !drawSrg) + { + AZ_Assert(false, "drawSrg need to be provided since the shader requires it"); return; } @@ -569,7 +630,6 @@ namespace AZ m_cachedDrawItems.emplace_back(drawItemInfo); } - Data::Instance DynamicDrawContext::NewDrawSrg() { if (!m_drawSrgLayout) @@ -626,18 +686,14 @@ namespace AZ return m_sortKey; } - void DynamicDrawContext::SubmitDrawData(ViewPtr view) + void DynamicDrawContext::FinalizeDrawList() { - if (!m_initialized) + if (m_drawFinalized) { return; } + AZ_Assert(m_cachedDrawList.size() == 0, "m_cachedDrawList should be cleared ine the end of last frame "); - if (!view->HasDrawListTag(m_drawListTag)) - { - return; - } - for (auto& drawItemInfo : m_cachedDrawItems) { if (drawItemInfo.m_indexBufferViewIndex != InvalidIndex) @@ -654,10 +710,34 @@ namespace AZ drawItemProperties.m_sortKey = drawItemInfo.m_sortKey; drawItemProperties.m_item = &drawItemInfo.m_drawItem; drawItemProperties.m_drawFilterMask = m_drawFilter; + m_cachedDrawList.emplace_back(drawItemProperties); + } + m_drawFinalized = true; + } + + void DynamicDrawContext::SubmitDrawList(ViewPtr view) + { + if (!m_initialized || m_outputScope == OutputScopeType::RasterPass) + { + return; + } + + if (!view->HasDrawListTag(m_drawListTag)) + { + return; + } + + for (auto& drawItemProperties : m_cachedDrawList) + { view->AddDrawItem(m_drawListTag, drawItemProperties); } } + RHI::DrawListView DynamicDrawContext::GetDrawList() + { + return m_cachedDrawList; + } + void DynamicDrawContext::FrameEnd() { m_sortKey = 0; @@ -665,6 +745,8 @@ namespace AZ m_cachedStreamBufferViews.clear(); m_cachedIndexBufferViews.clear(); m_cachedDrawSrg.clear(); + m_cachedDrawList.clear(); + m_drawFinalized = false; } const RHI::PipelineState* DynamicDrawContext::GetCurrentPipelineState() diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawSystem.cpp index fd568d29f4..c38fbc4480 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawSystem.cpp @@ -53,34 +53,14 @@ namespace AZ return m_bufferAlloc->Allocate(size, alignment); } - RHI::Ptr DynamicDrawSystem::CreateDynamicDrawContext(Scene* scene) + RHI::Ptr DynamicDrawSystem::CreateDynamicDrawContext() { - if (!scene) - { - AZ_Error("RPI", false, "Failed to create a DynamicDrawContext: the input scene is invalid"); - return nullptr; - } RHI::Ptr drawContext = aznew DynamicDrawContext(); - drawContext->m_scene = scene; - AZStd::lock_guard lock(m_mutexDrawContext); m_dynamicDrawContexts.push_back(drawContext); return drawContext; } - RHI::Ptr DynamicDrawSystem::CreateDynamicDrawContext(RenderPipeline* pipeline) - { - if (!pipeline || !pipeline->GetScene()) - { - AZ_Error("RPI", false, "Failed to create a DynamicDrawContext: the input RenderPipeline is invalid or wasn't added to a Scene"); - return nullptr; - } - - auto context = CreateDynamicDrawContext(pipeline->GetScene()); - context->m_drawFilter = pipeline->GetDrawFilterMask(); - return context; - } - // [GFX TODO][ATOM-13184] Add support of draw geometry with material for DynamicDrawSystemInterface void DynamicDrawSystem::DrawGeometry([[maybe_unused]] Data::Instance material, [[maybe_unused]] const GeometryData& geometry, [[maybe_unused]] ScenePtr scene) { @@ -101,9 +81,10 @@ namespace AZ { if (drawContext->m_scene == scene) { + drawContext->FinalizeDrawList(); for (auto& view : views) { - drawContext->SubmitDrawData(view); + drawContext->SubmitDrawList(view); } } } @@ -121,6 +102,25 @@ namespace AZ } } + AZStd::vector DynamicDrawSystem::GetDrawListsForPass(const RasterPass* pass) + { + AZStd::vector result; + AZStd::lock_guard lock(m_mutexDrawContext); + for (RHI::Ptr drawContext : m_dynamicDrawContexts) + { + if (drawContext->m_pass == pass) + { + drawContext->FinalizeDrawList(); + auto drawListView = drawContext->GetDrawList(); + if (drawListView.size() > 0) + { + result.push_back(drawListView); + } + } + } + return result; + } + void DynamicDrawSystem::FrameEnd() { { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp index 5e5835e39e..8890499cb7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp @@ -7,17 +7,18 @@ */ #include -#include #include - -#include -#include #include +#include + +#include +#include +#include #include #include #include -#include +#include #include namespace AZ @@ -133,10 +134,19 @@ namespace AZ m_viewportState = params.m_viewportState; } - // -- View & DrawList -- - const AZStd::vector& views = m_pipeline->GetViews(GetPipelineViewTag()); - m_drawListView = {}; + UpdateDrawList(); + RenderPass::FrameBeginInternal(params); + } + + void RasterPass::UpdateDrawList() + { + // DrawLists from dynamic draw + AZStd::vector drawLists = DynamicDrawInterface::Get()->GetDrawListsForPass(this); + + // Get DrawList from view + const AZStd::vector& views = m_pipeline->GetViews(GetPipelineViewTag()); + RHI::DrawListView viewDrawList; if (!views.empty()) { const ViewPtr& view = views.front(); @@ -144,11 +154,40 @@ namespace AZ // Assert the view has our draw list (the view's DrawlistTags are collected from passes using its viewTag) AZ_Assert(view->HasDrawListTag(m_drawListTag), "View's DrawListTags out of sync with pass'. "); - // Draw List - m_drawListView = view->GetDrawList(m_drawListTag); + viewDrawList = view->GetDrawList(m_drawListTag); } - RenderPass::FrameBeginInternal(params); + // clean up data + m_drawListView = {}; + m_combinedDrawList.clear(); + + // draw list from view was sorted and if it's the only draw list then we can use it directly + if (viewDrawList.size() > 0 && drawLists.size() == 0) + { + m_drawListView = viewDrawList; + return; + } + + // add view's draw list to drawLists too + drawLists.push_back(viewDrawList); + + // combine draw items from mutiple draw lists to one draw list and sort it. + size_t itemCount = 0; + for (auto drawList : drawLists) + { + itemCount += drawList.size(); + } + m_combinedDrawList.resize(itemCount); + RHI::DrawItemProperties* currentBuffer = m_combinedDrawList.data(); + for (auto drawList : drawLists) + { + memcpy(currentBuffer, drawList.data(), drawList.size()*sizeof(RHI::DrawItemProperties)); + currentBuffer += drawList.size(); + } + SortDrawList(m_combinedDrawList); + + // have the final draw list point to the combined draw list. + m_drawListView = m_combinedDrawList; } // --- DrawList and PipelineView Tags --- diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp index abd8ce9222..414dd7cdf0 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp @@ -83,7 +83,7 @@ namespace AZ::AtomBridge ViewportData& viewportData = m_viewportData[viewportId]; for (auto& context : viewportData.m_dynamicDrawContexts) { - context.second->SetRenderPipeline(pipeline.get()); + context.second->SetOutputScope(pipeline.get()); } }); viewportData.m_viewportDestroyedHandler = AZ::Event::Handler([this, viewportId](AzFramework::ViewportId id) @@ -106,7 +106,8 @@ namespace AZ::AtomBridge { return nullptr; } - context = RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(pipeline); + context = RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(); + context->SetOutputScope(pipeline); contextFactoryIt->second(context); } diff --git a/Gems/LyShine/Code/Source/Draw2d.cpp b/Gems/LyShine/Code/Source/Draw2d.cpp index 3a6fedfb24..9df411f6a3 100644 --- a/Gems/LyShine/Code/Source/Draw2d.cpp +++ b/Gems/LyShine/Code/Source/Draw2d.cpp @@ -96,7 +96,7 @@ void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapSc AZ_Assert(scene != nullptr, "Attempting to create a DynamicDrawContext for a viewport context that has not been associated with a scene yet."); // Create and initialize a DynamicDrawContext for 2d drawing - m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(scene.get()); + m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(); AZ::RPI::ShaderOptionList shaderOptions; shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("true"))); shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("false"))); @@ -107,6 +107,7 @@ void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapSc {"TEXCOORD0", AZ::RHI::Format::R32G32_FLOAT} }); m_dynamicDraw->AddDrawStateOptions(AZ::RPI::DynamicDrawContext::DrawStateOptions::PrimitiveType | AZ::RPI::DynamicDrawContext::DrawStateOptions::BlendMode); + m_dynamicDraw->SetOutputScope(scene.get()); m_dynamicDraw->EndInit(); AZ::RHI::TargetBlendState targetBlendState; diff --git a/Gems/LyShine/Code/Source/UiRenderer.cpp b/Gems/LyShine/Code/Source/UiRenderer.cpp index 05ea22c045..1b85c75ced 100644 --- a/Gems/LyShine/Code/Source/UiRenderer.cpp +++ b/Gems/LyShine/Code/Source/UiRenderer.cpp @@ -110,7 +110,7 @@ AZ::RPI::ScenePtr UiRenderer::CreateScene(AZStd::shared_ptr uiShader) { - m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(scene.get()); + m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext(); // Initialize the dynamic draw context m_dynamicDraw->InitShader(uiShader); @@ -122,6 +122,7 @@ void UiRenderer::CreateDynamicDrawContext(AZ::RPI::ScenePtr scene, AZ::Data::Ins ); m_dynamicDraw->AddDrawStateOptions(AZ::RPI::DynamicDrawContext::DrawStateOptions::StencilState | AZ::RPI::DynamicDrawContext::DrawStateOptions::BlendMode); + m_dynamicDraw->SetOutputScope(scene.get()); m_dynamicDraw->EndInit(); } From 0ffd151da69636c8577c5c15e427407a9e52afc2 Mon Sep 17 00:00:00 2001 From: Dayo Lawal Date: Mon, 19 Jul 2021 12:40:38 -0500 Subject: [PATCH 36/37] Removing name setting in main.cpp for Atom tools Signed-off-by: Dayo Lawal --- Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp | 4 ---- Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp index 2693101ebf..af14d3555d 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/main.cpp @@ -24,10 +24,6 @@ int main(int argc, char** argv) { - QApplication::setOrganizationName("O3DE"); - QApplication::setOrganizationDomain("o3de.org"); - QApplication::setApplicationName("O3DE Material Editor"); - AzQtComponents::AzQtApplication::InitializeDpiScaling(); MaterialEditor::MaterialEditorApplication app(&argc, &argv); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp index 4ff38ac73f..8989a397e7 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp @@ -24,10 +24,6 @@ int main(int argc, char** argv) { - QApplication::setOrganizationName("O3DE"); - QApplication::setOrganizationDomain("o3de.com"); - QApplication::setApplicationName("O3DE Shader Management Console"); - AzQtComponents::AzQtApplication::InitializeDpiScaling(); ShaderManagementConsole::ShaderManagementConsoleApplication app(&argc, &argv); From 6d563e2e19c8e3b8329af4b2eb7aa752d4d01f6e Mon Sep 17 00:00:00 2001 From: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> Date: Mon, 19 Jul 2021 15:43:56 -0500 Subject: [PATCH 37/37] [GHI 2178] Vegetation Debugger info was sometimes getting culled (#2209) * [GHI 2178] Fixed missing vegetation info The entity debug drawing culling system was removing it due to the level entity not having an AABB. Since this component can draw infinitely far, it just needed a max AABB. With the culling fixed, it made another culling problem evident - a bug in the font code where it wasn't culling 3D text rendered behind the camera. Now it is. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Fix problem with debug rendering not immediately showing up. When using FloatMax for the AABB, it causes math overflows with the initial camera frustrum. Changing to max/2.0f is sufficient to avoid the overflows. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Fixed normals on mesh raycasts. The normals needed to be normalized after transformation, and didn't need the non-uniform scale applied to them, since they're normals. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Fixed the bug that prevented max-size AABBs from working with ShapeIntersection::Overlap. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> --- .../AzCore/AzCore/Math/ShapeIntersection.inl | 6 +++++- .../Tests/Math/ShapeIntersectionTests.cpp | 5 +++++ .../AtomFont/Code/Source/FFont.cpp | 8 ++++++++ .../Code/Source/SurfaceDataUtility.cpp | 2 +- .../Code/Source/Debugger/DebugComponent.cpp | 2 ++ .../Code/Source/Debugger/DebugComponent.h | 19 +++++++++++++++++++ 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Math/ShapeIntersection.inl b/Code/Framework/AzCore/AzCore/Math/ShapeIntersection.inl index b35906a434..0638e070fc 100644 --- a/Code/Framework/AzCore/AzCore/Math/ShapeIntersection.inl +++ b/Code/Framework/AzCore/AzCore/Math/ShapeIntersection.inl @@ -130,7 +130,11 @@ namespace AZ //So for each plane, we can test compare the center-to-plane distance to this interval to see which side of the plane the AABB is on. //The AABB is not overlapping if it is fully behind any of the planes, otherwise it is overlapping. const Vector3 center = aabb.GetCenter(); - const Vector3 extents = 0.5f * aabb.GetExtents(); + + //If the AABB contains FLT_MAX at either (or both) extremes, it would be easy to overflow here by using "0.5f * GetExtents()" + //or "0.5f * (GetMax() - GetMin())". By separating into two separate multiplies before the subtraction, we can ensure + //that we don't overflow. + const Vector3 extents = (0.5f * aabb.GetMax()) - (0.5f * aabb.GetMin()); for (Frustum::PlaneId planeId = Frustum::PlaneId::Near; planeId < Frustum::PlaneId::MAX; ++planeId) { diff --git a/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp b/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp index a28e8a9dbf..659febf564 100644 --- a/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp @@ -42,6 +42,7 @@ namespace UnitTest AZ::Aabb unitBox = AZ::Aabb::CreateCenterHalfExtents(AZ::Vector3::CreateZero(), AZ::Vector3(1.f, 1.f, 1.f)); AZ::Aabb aabb = AZ::Aabb::CreateCenterHalfExtents(AZ::Vector3(10.f, 10.f, 10.f), AZ::Vector3(1.f, 1.f, 1.f)); AZ::Aabb aabb1 = AZ::Aabb::CreateCenterHalfExtents(AZ::Vector3(10.f, 10.f, 10.f), AZ::Vector3(100.f, 100.f, 100.f)); + AZ::Aabb maxSizeAabb = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-AZ::Constants::FloatMax), AZ::Vector3(AZ::Constants::FloatMax)); AZ::Vector3 point(0.f, 0.f, 0.f); AZ::Vector3 point1(10.f, 10.f, 10.f); @@ -73,6 +74,10 @@ namespace UnitTest EXPECT_TRUE(AZ::ShapeIntersection::Overlaps(frustum, aabb1)); EXPECT_TRUE(AZ::ShapeIntersection::Overlaps(sphere1, far_value)); + // Verify that an AABB that covers the max floating point range successfully overlaps with a frustum and doesn't hit any + // floating-point math overflows. + EXPECT_TRUE(AZ::ShapeIntersection::Overlaps(frustum, maxSizeAabb)); + EXPECT_FALSE(AZ::ShapeIntersection::Overlaps(frustum, aabb)); EXPECT_FALSE(AZ::ShapeIntersection::Overlaps(unitSphere, aabb)); EXPECT_FALSE(AZ::ShapeIntersection::Overlaps(unitSphere, sphere2)); diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp index ec50b6f052..d98a3628a8 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp +++ b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp @@ -1732,6 +1732,14 @@ void AZ::FFont::DrawScreenAlignedText3d( currentView->GetWorldToViewMatrix(), currentView->GetViewToClipMatrix() ); + + // Text behind the camera shouldn't get rendered. WorldToScreenNDC returns values in the range 0 - 1, so Z < 0.5 is behind the screen + // and >= 0.5 is in front of the screen. + if (positionNDC.GetZ() < 0.5f) + { + return; + } + internalParams.m_ctx.m_sizeIn800x600 = false; DrawStringUInternal( diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataUtility.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataUtility.cpp index bcadbe7c7d..884ee8e840 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataUtility.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataUtility.cpp @@ -34,7 +34,7 @@ namespace SurfaceData { // Transform everything back to world space outPosition = meshTransform.TransformPoint((rayStartLocal + (rayDirectionLocal * distance)) * clampedScale); - outNormal = meshTransform.TransformVector(normalLocal * clampedScale); + outNormal = meshTransform.TransformVector(normalLocal).GetNormalized(); return true; } diff --git a/Gems/Vegetation/Code/Source/Debugger/DebugComponent.cpp b/Gems/Vegetation/Code/Source/Debugger/DebugComponent.cpp index 527bb26f7d..bfe74a8b28 100644 --- a/Gems/Vegetation/Code/Source/Debugger/DebugComponent.cpp +++ b/Gems/Vegetation/Code/Source/Debugger/DebugComponent.cpp @@ -112,6 +112,7 @@ void DebugComponent::Activate() DebugNotificationBus::Handler::BusConnect(); DebugNotificationBus::AllowFunctionQueuing(true); AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId()); + AzFramework::BoundsRequestBus::Handler::BusConnect(GetEntityId()); SystemConfigurationRequestBus::Handler::BusConnect(); VEG_PROFILE_METHOD(DebugSystemDataBus::BroadcastResult(m_debugData, &DebugSystemDataBus::Events::GetDebugData)); @@ -120,6 +121,7 @@ void DebugComponent::Activate() void DebugComponent::Deactivate() { SystemConfigurationRequestBus::Handler::BusDisconnect(); + AzFramework::BoundsRequestBus::Handler::BusDisconnect(); AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect(); DebugRequestBus::Handler::BusDisconnect(); DebugNotificationBus::Handler::BusDisconnect(); diff --git a/Gems/Vegetation/Code/Source/Debugger/DebugComponent.h b/Gems/Vegetation/Code/Source/Debugger/DebugComponent.h index 346f0918f9..4b927b63b0 100644 --- a/Gems/Vegetation/Code/Source/Debugger/DebugComponent.h +++ b/Gems/Vegetation/Code/Source/Debugger/DebugComponent.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ namespace Vegetation class DebugComponent : public AZ::Component , private AzFramework::EntityDebugDisplayEventBus::Handler + , private AzFramework::BoundsRequestBus::Handler , private DebugRequestBus::Handler , private DebugNotificationBus::Handler , private SystemConfigurationRequestBus::Handler @@ -80,6 +82,9 @@ namespace Vegetation ////////////////////////////////////////////////////////////////////////// // EntityDebugDisplayEventBus + + // Ideally this would use ViewportDebugDisplayEventBus::DisplayViewport, but that doesn't currently work in game mode, + // so instead we use this plus the BoundsRequestBus with a large AABB to get ourselves rendered. void DisplayEntityViewport( const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override; @@ -110,6 +115,20 @@ namespace Vegetation void UpdateSystemConfig(const AZ::ComponentConfig* config) override; void GetSystemConfig([[maybe_unused]] AZ::ComponentConfig* config) const override {}; // ignore this call + ////////////////////////////////////////////////////////////////////////// + // BoundsRequestBus + AZ::Aabb GetWorldBounds() override + { + // DisplayEntityViewport relies on the BoundsRequestBus to get the entity bounds to determine when to call debug drawing + // for that entity. Since this is a level component that can draw infinitely far in every direction, we return an + // effectively infinite AABB so that it always draws. + return AZ::Aabb::CreateFromMinMax(AZ::Vector3(-AZ::Constants::FloatMax), AZ::Vector3(AZ::Constants::FloatMax)); + } + AZ::Aabb GetLocalBounds() override + { + // The local and world bounds will be the same for this component. + return GetWorldBounds(); + } protected: void PrepareNextReport();