1f9b284de2
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> # Conflicts: # Code/Editor/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin_precompiled.h # Code/Editor/Plugins/EditorCommon/EditorCommon_precompiled.h # Code/Editor/Plugins/EditorCommon/stdafx.cpp # Code/Editor/Plugins/FFMPEGPlugin/FFMPEGPlugin_precompiled.h # Code/Editor/Plugins/PerforcePlugin/PerforcePlugin_precompiled.h # Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsTool_precompiled.h # Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFramework_precompiled.h # Code/Tools/AssetProcessor/native/precompiled.h # Code/Tools/Standalone/StandaloneTools_precompiled.h # Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer_precompiled.h # Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageProcessing_precompiled.h # Gems/Atom/RHI/DX12/Code/Source/RHI/Atom_RHI_DX12_precompiled.h # Gems/Atom/RHI/Metal/Code/Include/Platform/Mac/Atom_RHI_Metal_precompiled_Platform.h # Gems/Atom/RHI/Metal/Code/Include/Platform/iOS/Atom_RHI_Metal_precompiled_Platform.h # Gems/Atom/RHI/Metal/Code/Source/Atom_RHI_Metal_precompiled.h # Gems/Atom/RHI/Metal/Code/atom_rhi_metal_common_files.cmake # Gems/Atom/RHI/Null/Code/Source/Atom_RHI_Null_precompiled.h # Gems/Atom/RHI/Null/Code/atom_rhi_null_common_files.cmake # Gems/Atom/RHI/Vulkan/Code/Include/Platform/Android/Atom_RHI_Vulkan_precompiled_Platform.h # Gems/Atom/RHI/Vulkan/Code/Include/Platform/Linux/Atom_RHI_Vulkan_precompiled_Platform.h # Gems/Atom/RHI/Vulkan/Code/Include/Platform/Mac/Atom_RHI_Vulkan_precompiled_Platform.h # Gems/Atom/RHI/Vulkan/Code/Include/Platform/Windows/Atom_RHI_Vulkan_precompiled_Platform.h # Gems/Atom/RHI/Vulkan/Code/Source/Atom_RHI_Vulkan_precompiled.h # Gems/Atom/RHI/Vulkan/Code/Source/RHI/SwapChain.cpp # Gems/Atom/RHI/Vulkan/Code/atom_rhi_vulkan_common_files.cmake # Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/AtomFont_precompiled.h # Gems/Blast/Code/Source/StdAfx.cpp # Gems/Camera/Code/Source/Camera_precompiled.h # Gems/EMotionFX/Code/Source/EMotionFX_precompiled.h # Gems/FastNoise/Code/Source/FastNoise_precompiled.h # Gems/Gestures/Code/Source/Gestures_precompiled.h # Gems/GradientSignal/Code/Source/GradientSignal_precompiled.h # Gems/GraphCanvas/Code/precompiled.h # Gems/ImGui/Code/Source/ImGui_precompiled.h # Gems/InAppPurchases/Code/Source/InAppPurchases_precompiled.h # Gems/LmbrCentral/Code/Source/LmbrCentral_precompiled.h # Gems/LmbrCentral/Code/Tests/ShapeGeometryUtilTest.cpp # Gems/LyShine/Code/Editor/UiCanvasEditor_precompiled.h # Gems/LyShine/Code/Source/Animation/LyShine_precompiled.h # Gems/LyShine/Code/Source/LyShine_precompiled.h # Gems/LyShineExamples/Code/Source/LyShineExamples_precompiled.h # Gems/Maestro/Code/Source/Cinematics/Maestro_precompiled.h # Gems/Maestro/Code/Source/Maestro_precompiled.h # Gems/MessagePopup/Code/Source/MessagePopup_precompiled.h # Gems/Metastream/Code/Source/Metastream_precompiled.h # Gems/Microphone/Code/Source/Microphone_precompiled.h # Gems/Multiplayer/Code/Source/Multiplayer_precompiled.h # Gems/PhysX/Code/NumericalMethods/Source/NumericalMethods_precompiled.h # Gems/PhysX/Code/Source/PhysXUnsupported_precompiled.h # Gems/PhysX/Code/Source/PhysX_precompiled.h # Gems/PhysX/Code/physx_unsupported_files.cmake # Gems/PhysXDebug/Code/Source/PhysXDebugUnsupported_precompiled.h # Gems/PhysXDebug/Code/Source/PhysXDebug_precompiled.h # Gems/ScriptCanvas/Code/Editor/precompiled.h # Gems/ScriptCanvas/Code/Source/precompiled.h # Gems/ScriptCanvasDeveloper/Code/Source/precompiled.h # Gems/ScriptCanvasPhysics/Code/Source/ScriptCanvasPhysics_precompiled.h # Gems/ScriptEvents/Code/Source/precompiled.h # Gems/ScriptEvents/Code/Tests/Editor/EditorTests.cpp # Gems/ScriptedEntityTweener/Code/Source/ScriptedEntityTweener_precompiled.h # Gems/SliceFavorites/Code/Source/SliceFavorites_precompiled.h # Gems/StartingPointCamera/Code/Source/StartingPointCamera_precompiled.h # Gems/StartingPointInput/Code/Source/StartingPointInput_precompiled.h # Gems/StartingPointMovement/Code/Source/StartingPointMovement_precompiled.h # Gems/SurfaceData/Code/Source/SurfaceData_precompiled.h # Gems/TextureAtlas/Code/Source/TextureAtlas_precompiled.h # Gems/TickBusOrderViewer/Code/Source/TickBusOrderViewer_precompiled.h # Gems/Twitch/Code/Source/Twitch_precompiled.h # Gems/VirtualGamepad/Code/Source/VirtualGamepad_precompiled.h # Gems/WhiteBox/Code/Source/WhiteBoxUnsupported_precompiled.h # Gems/WhiteBox/Code/Source/WhiteBox_precompiled.h
300 lines
9.6 KiB
C++
300 lines
9.6 KiB
C++
/*
|
|
* 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 "DrillerContext.h"
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
#include <AzCore/Serialization/EditContext.h>
|
|
#include <AzCore/Component/ComponentApplicationBus.h>
|
|
#include <AzCore/Script/ScriptContext.h>
|
|
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
|
#include <AzCore/StringFunc/StringFunc.h>
|
|
#include <QMessageBox>
|
|
#include <AzToolsFramework/UI/UICore/SaveChangesDialog.hxx>
|
|
#include <AzToolsFramework/UI/LegacyFramework/UIFrameworkAPI.h>
|
|
#include <Source/Telemetry/TelemetryBus.h>
|
|
#include <AzFramework/Asset/AssetSystemBus.h>
|
|
#include <AzFramework/Asset/AssetSystemComponent.h>
|
|
|
|
namespace Driller
|
|
{
|
|
const char* DrillerDebugName = "Profiler";
|
|
const char* DrillerInfoName = "Profiler";
|
|
|
|
class DrillerSavedState
|
|
: public AZ::UserSettings
|
|
{
|
|
public:
|
|
AZ_RTTI(DrillerSavedState, "{CBA064FC-B144-4B9D-92B8-F696B0A15E4D}", AZ::UserSettings);
|
|
AZ_CLASS_ALLOCATOR(DrillerSavedState, AZ::SystemAllocator, 0);
|
|
|
|
bool m_MainDrillerWindowIsVisible;
|
|
bool m_MainDrillerWindowIsOpen;
|
|
|
|
DrillerSavedState()
|
|
: m_MainDrillerWindowIsVisible(true)
|
|
, m_MainDrillerWindowIsOpen(true) {}
|
|
|
|
static void Reflect(AZ::ReflectContext* context)
|
|
{
|
|
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
|
|
if (serialize)
|
|
{
|
|
serialize->Class<DrillerSavedState>()
|
|
->Version(1)
|
|
->Field("m_MainDrillerWindowIsVisible", &DrillerSavedState::m_MainDrillerWindowIsVisible)
|
|
->Field("m_MainDrillerWindowIsOpen", &DrillerSavedState::m_MainDrillerWindowIsOpen);
|
|
}
|
|
}
|
|
};
|
|
|
|
AZ::Uuid ContextID("FB8B7094-63FF-4CD1-9857-3AEFA8E2CFDC");
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//Context
|
|
Context::Context()
|
|
: m_pDrillerMainWindow(NULL)
|
|
{
|
|
}
|
|
|
|
Context::~Context()
|
|
{
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// AZ::Component
|
|
void Context::Init()
|
|
{
|
|
}
|
|
|
|
void Context::Activate()
|
|
{
|
|
ContextInterface::Handler::BusConnect(ContextID);
|
|
LegacyFramework::CoreMessageBus::Handler::BusConnect();
|
|
|
|
AzToolsFramework::MainWindowDescription desc;
|
|
desc.name = "Profiler";
|
|
desc.ContextID = ContextID;
|
|
desc.hotkeyDesc = AzToolsFramework::HotkeyDescription(AZ_CRC("DrillerOpen", 0x1cbbd497), "Ctrl+Shift+D", "Open Profiler", "General", 1, AzToolsFramework::HotkeyDescription::SCOPE_WINDOW);
|
|
EBUS_EVENT(AzToolsFramework::FrameworkMessages::Bus, AddComponentInfo, desc);
|
|
|
|
bool connectedToAssetProcessor = false;
|
|
|
|
// When the AssetProcessor is already launched it should take less than a second to perform a connection
|
|
// but when the AssetProcessor needs to be launch it could take up to 15 seconds to have the AssetProcessor initialize
|
|
// and able to negotiate a connection when running a debug build
|
|
// and to negotiate a connection
|
|
|
|
AzFramework::AssetSystem::ConnectionSettings connectionSettings;
|
|
AzFramework::AssetSystem::ReadConnectionSettingsFromSettingsRegistry(connectionSettings);
|
|
connectionSettings.m_connectionDirection = AzFramework::AssetSystem::ConnectionSettings::ConnectionDirection::ConnectToAssetProcessor;
|
|
connectionSettings.m_connectionIdentifier = desc.name;
|
|
AzFramework::AssetSystemRequestBus::BroadcastResult(connectedToAssetProcessor,
|
|
&AzFramework::AssetSystemRequestBus::Events::EstablishAssetProcessorConnection, connectionSettings);
|
|
}
|
|
|
|
void Context::Deactivate()
|
|
{
|
|
LegacyFramework::CoreMessageBus::Handler::BusDisconnect();
|
|
ContextInterface::Handler::BusDisconnect(ContextID);
|
|
}
|
|
|
|
void Context::Reflect(AZ::ReflectContext* context)
|
|
{
|
|
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
|
|
if (serialize)
|
|
{
|
|
DrillerMainWindow::Reflect(context);
|
|
DrillerSavedState::Reflect(context);
|
|
|
|
serialize->Class<Context, AZ::Component>()
|
|
->Version(1)
|
|
;
|
|
}
|
|
}
|
|
|
|
void Context::ApplicationDeactivated()
|
|
{
|
|
}
|
|
|
|
void Context::ApplicationActivated()
|
|
{
|
|
}
|
|
|
|
void Context::ApplicationShow(AZ::Uuid id)
|
|
{
|
|
if (ContextID == id)
|
|
{
|
|
ProvisionalShowAndFocus(true);
|
|
}
|
|
}
|
|
void Context::ApplicationHide(AZ::Uuid id)
|
|
{
|
|
if (ContextID == id)
|
|
{
|
|
m_pDrillerMainWindow->hide();
|
|
AZStd::intrusive_ptr<DrillerSavedState> newState = AZ::UserSettings::CreateFind<DrillerSavedState>(AZ_CRC("LUA DRILLER CONTEXT STATE", 0x95052376), AZ::UserSettings::CT_GLOBAL);
|
|
newState->m_MainDrillerWindowIsVisible = false;
|
|
}
|
|
}
|
|
|
|
void Context::ApplicationCensus()
|
|
{
|
|
AZStd::intrusive_ptr<DrillerSavedState> newState = AZ::UserSettings::CreateFind<DrillerSavedState>(AZ_CRC("LUA DRILLER CONTEXT STATE", 0x95052376), AZ::UserSettings::CT_GLOBAL);
|
|
EBUS_EVENT(AzToolsFramework::FrameworkMessages::Bus, ApplicationCensusReply, newState->m_MainDrillerWindowIsVisible);
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// EditorFramework CoreMessages
|
|
void Context::OnRestoreState()
|
|
{
|
|
const AZStd::string k_launchString = "launch";
|
|
const AZStd::string k_drillerString = "driller";
|
|
|
|
bool GUIMode = true;
|
|
EBUS_EVENT_RESULT(GUIMode, LegacyFramework::FrameworkApplicationMessages::Bus, IsRunningInGUIMode);
|
|
if (!GUIMode)
|
|
{
|
|
return;
|
|
}
|
|
|
|
const AzFramework::CommandLine* commandLine = nullptr;
|
|
|
|
EBUS_EVENT_RESULT(commandLine, LegacyFramework::FrameworkApplicationMessages::Bus, GetCommandLineParser);
|
|
|
|
bool forceShow = false;
|
|
bool forceHide = false;
|
|
|
|
if (commandLine->HasSwitch(k_launchString))
|
|
{
|
|
forceHide = true;
|
|
|
|
size_t numSwitchValues = commandLine->GetNumSwitchValues(k_launchString);
|
|
|
|
for (size_t i = 0; i < numSwitchValues; ++i)
|
|
{
|
|
AZStd::string inputValue = commandLine->GetSwitchValue(k_launchString, i);
|
|
|
|
if (inputValue.compare(k_drillerString) == 0)
|
|
{
|
|
forceShow = true;
|
|
forceHide = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
ProvisionalShowAndFocus(forceShow, forceHide);
|
|
}
|
|
|
|
bool Context::OnGetPermissionToShutDown() // until everyone returns true, we can't shut down.
|
|
{
|
|
AZ_TracePrintf(DrillerDebugName, "Context::OnGetPermissionToShutDown()\n");
|
|
|
|
if (m_pDrillerMainWindow)
|
|
{
|
|
if (!m_pDrillerMainWindow->OnGetPermissionToShutDown())
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// until everyone returns true, we can't shut down.
|
|
bool Context::CheckOkayToShutDown()
|
|
{
|
|
if (m_pDrillerMainWindow)
|
|
{
|
|
// confirmation that we're quitting.
|
|
if (m_pDrillerMainWindow->isVisible())
|
|
{
|
|
m_pDrillerMainWindow->setEnabled(false);
|
|
m_pDrillerMainWindow->hide();
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void Context::OnSaveState()
|
|
{
|
|
// notify main view to persist?
|
|
if (m_pDrillerMainWindow)
|
|
{
|
|
m_pDrillerMainWindow->SaveWindowState();
|
|
}
|
|
}
|
|
|
|
void Context::OnDestroyState()
|
|
{
|
|
if (m_pDrillerMainWindow)
|
|
{
|
|
delete m_pDrillerMainWindow;
|
|
}
|
|
m_pDrillerMainWindow = NULL;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Utility
|
|
void Context::ProvisionalShowAndFocus(bool forcedShow, bool forcedHide)
|
|
{
|
|
AZStd::intrusive_ptr<DrillerSavedState> newState = AZ::UserSettings::CreateFind<DrillerSavedState>(AZ_CRC("LUA DRILLER CONTEXT STATE", 0x95052376), AZ::UserSettings::CT_GLOBAL);
|
|
|
|
if (forcedShow)
|
|
{
|
|
newState->m_MainDrillerWindowIsOpen = true;
|
|
newState->m_MainDrillerWindowIsVisible = true;
|
|
}
|
|
else if (forcedHide)
|
|
{
|
|
newState->m_MainDrillerWindowIsOpen = false;
|
|
newState->m_MainDrillerWindowIsVisible = false;
|
|
}
|
|
|
|
if (newState->m_MainDrillerWindowIsOpen)
|
|
{
|
|
if (newState->m_MainDrillerWindowIsVisible)
|
|
{
|
|
if (!m_pDrillerMainWindow)
|
|
{
|
|
m_pDrillerMainWindow = aznew DrillerMainWindow();
|
|
}
|
|
|
|
m_pDrillerMainWindow->show();
|
|
m_pDrillerMainWindow->raise();
|
|
m_pDrillerMainWindow->activateWindow();
|
|
m_pDrillerMainWindow->setFocus();
|
|
}
|
|
else
|
|
{
|
|
if (m_pDrillerMainWindow)
|
|
{
|
|
m_pDrillerMainWindow->hide();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//ContextInterface
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
void Context::ShowDrillerView()
|
|
{
|
|
ProvisionalShowAndFocus(true);
|
|
}
|
|
}
|