123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /*
- * 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 "ScriptCanvasApplication.h"
- #include "Document/ScriptCanvasDocument.h"
- #include <AzFramework/Network/IRemoteTools.h>
- #include <AzFramework/Script/ScriptRemoteDebuggingConstants.h>
- #include <QApplication>
- #include <QIcon>
- #if defined(EXTERNAL_CRASH_REPORTING)
- #include <ToolsCrashHandler.h>
- #endif
- // This has to live outside of any namespaces due to issues on Linux with calls to Q_INIT_RESOURCE if they are inside a namespace
- void InitScriptCanvasApplicationResources()
- {
- Q_INIT_RESOURCE(ScriptCanvasApplicationResources);
- }
- namespace ScriptCanvas
- {
- static const char* 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 LY_CMAKE_TARGET;
- }
- ScriptCanvasApplication::ScriptCanvasApplication(int* argc, char*** argv)
- : Base(GetBuildTargetName(), argc, argv)
- {
- #if defined(EXTERNAL_CRASH_REPORTING)
- CrashHandler::ToolsCrashHandler::InitCrashHandler(GetBuildTargetName(), {});
- #endif
- InitScriptCanvasApplicationResources();
- QApplication::setOrganizationName("O3DE");
- QApplication::setApplicationName("O3DE Script Canvas");
- QApplication::setWindowIcon(QIcon(":/Resources/application.svg"));
- AzToolsFramework::EditorWindowRequestBus::Handler::BusConnect();
- AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusConnect(m_toolId);
- }
- ScriptCanvasApplication::~ScriptCanvasApplication()
- {
- AtomToolsFramework::AtomToolsDocumentNotificationBus::Handler::BusDisconnect();
- AzToolsFramework::EditorWindowRequestBus::Handler::BusDisconnect();
- }
- void ScriptCanvasApplication::Reflect(AZ::ReflectContext* context)
- {
- Base::Reflect(context);
- ScriptCanvasDocument::Reflect(context);
- }
- void ScriptCanvasApplication::StartCommon(AZ::Entity* systemEntity)
- {
- Base::StartCommon(systemEntity);
- auto documentTypeInfo = ScriptCanvasDocument::BuildDocumentTypeInfo();
- AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Event(
- m_toolId, &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Handler::RegisterDocumentType, documentTypeInfo);
- #if defined(ENABLE_REMOTE_TOOLS)
- if (auto* remoteToolsInterface = AzFramework::RemoteToolsInterface::Get())
- {
- remoteToolsInterface->RegisterToolingServiceHost(
- AzFramework::ScriptCanvasToolsKey, AzFramework::ScriptCanvasToolsName, AzFramework::ScriptCanvasToolsPort);
- }
- #endif
- InitMainWindow();
- }
- void ScriptCanvasApplication::Destroy()
- {
- m_window.reset();
- Base::Destroy();
- }
- QWidget* ScriptCanvasApplication::GetAppMainWindow()
- {
- return m_window.get();
- }
- void ScriptCanvasApplication::InitMainWindow()
- {
- m_window.reset(aznew ScriptCanvasEditor::MainWindow(m_toolId));
- m_window->show();
- }
- } // namespace ScriptCanvas
|