Fixing errors and streamlining more to base class
Signed-off-by: Dayo Lawal <lawalfua@amazon.com>
This commit is contained in:
+19
-3
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* 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 <AtomToolsFramework/Communication/LocalServer.h>
|
||||
@@ -25,11 +32,10 @@ namespace AtomToolsFramework
|
||||
, protected AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler
|
||||
, protected AzFramework::AssetSystemStatusBus::Handler
|
||||
, protected AzToolsFramework::EditorPythonConsoleNotificationBus::Handler
|
||||
, protected AZ::Debug::TraceMessageBus::Handler
|
||||
, protected AZ::UserSettingsOwnerRequestBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(AtomTools::AtomToolsApplication, "{30F90CA5-1253-49B5-8143-19CEE37E22BB}");
|
||||
AZ_TYPE_INFO(AtomTools::AtomToolsApplication, "{A0DF25BA-6F74-4F11-9F85-0F99278D5986}");
|
||||
|
||||
using Base = AzFramework::Application;
|
||||
|
||||
@@ -68,14 +74,24 @@ namespace AtomToolsFramework
|
||||
void SaveSettings() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// EditorPythonConsoleNotificationBus::Handler overrides...
|
||||
void OnTraceMessage(AZStd::string_view message) override;
|
||||
void OnErrorMessage(AZStd::string_view message) override;
|
||||
void OnExceptionMessage(AZStd::string_view message) override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void LoadSettings();
|
||||
virtual void UnloadSettings();
|
||||
virtual void CompileCriticalAssets();
|
||||
virtual void CompileCriticalAssets(const AZStd::vector<AZStd::string> &assetFiltersArray);
|
||||
virtual void ProcessCommandLine(const AZ::CommandLine& commandLine);
|
||||
virtual bool LaunchDiscoveryService();
|
||||
virtual void StartInternal();
|
||||
|
||||
static void PyIdleWaitFrames(uint32_t frames);
|
||||
void setTargetName(AZStd::string newTargetName);
|
||||
|
||||
AZStd::string targetName = "AtomTools";
|
||||
|
||||
AzToolsFramework::TraceLogger m_traceLogger;
|
||||
|
||||
|
||||
+81
-54
@@ -1,12 +1,18 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
#include <AtomToolsFramework/Application/AtomToolsApplication.h>
|
||||
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzFramework/Asset/AssetSystemComponent.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
@@ -26,15 +32,6 @@
|
||||
#include <AzToolsFramework/UI/UICore/QTreeViewStateSaver.hxx>
|
||||
#include <AzToolsFramework/UI/UICore/QWidgetSavedState.h>
|
||||
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
|
||||
#include <AtomToolsFramework/Application/AtomToolsApplication.h>
|
||||
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
@@ -42,15 +39,6 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
//! This function returns the build system target name of "AtomTools
|
||||
// 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 };
|
||||
// }
|
||||
|
||||
const char* AtomToolsApplication::GetCurrentConfigurationName() const
|
||||
{
|
||||
#if defined(_RELEASE)
|
||||
@@ -62,7 +50,6 @@ namespace AtomToolsFramework
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
AtomToolsApplication::AtomToolsApplication(int* argc, char*** argv)
|
||||
: Application(argc, argv)
|
||||
, AzQtApplication(*argc, *argv)
|
||||
@@ -152,22 +139,14 @@ namespace AtomToolsFramework
|
||||
{
|
||||
AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusDisconnect();
|
||||
AZ::Debug::TraceMessageBus::Handler::BusDisconnect();
|
||||
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::StartDisconnectingAssetProcessor);
|
||||
Application::Destroy();
|
||||
}
|
||||
|
||||
void AtomToolsApplication::CompileCriticalAssets()
|
||||
void AtomToolsApplication::CompileCriticalAssets(const AZStd::vector<AZStd::string> &assetFiltersArray)
|
||||
{
|
||||
AZ_TracePrintf("AtomTools", "Compiling critical assets.\n");
|
||||
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
const AZStd::string assetFiltersArray[] = {
|
||||
"passes/",
|
||||
"config/",
|
||||
};
|
||||
AZ_TracePrintf(targetName.c_str(), "Compiling critical assets.\n");
|
||||
|
||||
QStringList failedAssets;
|
||||
|
||||
@@ -208,13 +187,14 @@ namespace AtomToolsFramework
|
||||
AZ_Assert(context, "No serialize context");
|
||||
|
||||
char resolvedPath[AZ_MAX_PATH_LEN] = "";
|
||||
AZStd::string fileName = "@user@/" + targetName + "UserSettings.xml";
|
||||
|
||||
AZ::IO::FileIOBase::GetInstance()->ResolvePath(
|
||||
"@user@/MaterialEditorUserSettings.xml", resolvedPath, AZ_ARRAY_SIZE(resolvedPath));
|
||||
fileName.c_str(), resolvedPath, AZ_ARRAY_SIZE(resolvedPath));
|
||||
m_localUserSettings.Save(resolvedPath, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AtomToolsApplication::LoadSettings()
|
||||
{
|
||||
AZ::SerializeContext* context = nullptr;
|
||||
@@ -222,7 +202,9 @@ namespace AtomToolsFramework
|
||||
AZ_Assert(context, "No serialize context");
|
||||
|
||||
char resolvedPath[AZ_MAX_PATH_LEN] = "";
|
||||
AZ::IO::FileIOBase::GetInstance()->ResolvePath("@user@/EditorUserSettings.xml", resolvedPath, AZ_MAX_PATH_LEN);
|
||||
AZStd::string fileName = "@user@/" + targetName + "UserSettings.xml";
|
||||
|
||||
AZ::IO::FileIOBase::GetInstance()->ResolvePath(fileName.c_str(), resolvedPath, AZ_MAX_PATH_LEN);
|
||||
|
||||
m_localUserSettings.Load(resolvedPath, context);
|
||||
m_localUserSettings.Activate(AZ::UserSettings::CT_LOCAL);
|
||||
@@ -234,7 +216,7 @@ namespace AtomToolsFramework
|
||||
{
|
||||
if (m_activatedLocalUserSettings)
|
||||
{
|
||||
//SaveSettings();
|
||||
SaveSettings();
|
||||
m_localUserSettings.Deactivate();
|
||||
AZ::UserSettingsOwnerRequestBus::Handler::BusDisconnect();
|
||||
m_activatedLocalUserSettings = false;
|
||||
@@ -243,6 +225,34 @@ namespace AtomToolsFramework
|
||||
|
||||
void AtomToolsApplication::ProcessCommandLine(const AZ::CommandLine& commandLine)
|
||||
{
|
||||
const AZStd::string timeoputSwitchName = "timeout";
|
||||
if (commandLine.HasSwitch(timeoputSwitchName))
|
||||
{
|
||||
const AZStd::string& timeoutValue = commandLine.GetSwitchValue(timeoputSwitchName, 0);
|
||||
const uint32_t timeoutInMs = atoi(timeoutValue.c_str());
|
||||
AZ_Printf(targetName.c_str(), "Timeout scheduled, shutting down in %u ms", timeoutInMs);
|
||||
QTimer::singleShot(
|
||||
timeoutInMs,
|
||||
[this]
|
||||
{
|
||||
AZ_Printf(targetName.c_str(), "Timeout reached, shutting down");
|
||||
ExitMainLoop();
|
||||
});
|
||||
}
|
||||
|
||||
// Process command line options for running one or more python scripts on startup
|
||||
const AZStd::string runPythonScriptSwitchName = "runpython";
|
||||
size_t runPythonScriptCount = commandLine.GetNumSwitchValues(runPythonScriptSwitchName);
|
||||
for (size_t runPythonScriptIndex = 0; runPythonScriptIndex < runPythonScriptCount; ++runPythonScriptIndex)
|
||||
{
|
||||
const AZStd::string runPythonScriptPath = commandLine.GetSwitchValue(runPythonScriptSwitchName, runPythonScriptIndex);
|
||||
AZStd::vector<AZStd::string_view> runPythonArgs;
|
||||
|
||||
AZ_Printf(targetName.c_str(), "Launching script: %s", runPythonScriptPath.c_str());
|
||||
AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(
|
||||
&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilenameWithArgs, runPythonScriptPath, runPythonArgs);
|
||||
}
|
||||
|
||||
const AZStd::string exitAfterCommandsSwitchName = "exitaftercommands";
|
||||
if (commandLine.HasSwitch(exitAfterCommandsSwitchName))
|
||||
{
|
||||
@@ -313,7 +323,9 @@ namespace AtomToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
m_traceLogger.WriteStartupLog("AtomTools.log");
|
||||
AZStd::string fileName = targetName + ".log";
|
||||
|
||||
m_traceLogger.WriteStartupLog(fileName.c_str());
|
||||
|
||||
if (!LaunchDiscoveryService())
|
||||
{
|
||||
@@ -330,23 +342,6 @@ namespace AtomToolsFramework
|
||||
AZ::RPI::RPISystemInterface::Get()->InitializeSystemAssets();
|
||||
|
||||
LoadSettings();
|
||||
|
||||
auto editorPythonEventsInterface = AZ::Interface<AzToolsFramework::EditorPythonEventsInterface>::Get();
|
||||
if (editorPythonEventsInterface)
|
||||
{
|
||||
// The PythonSystemComponent does not call StartPython to allow for lazy python initialization, so start it here
|
||||
// The PythonSystemComponent will call StopPython when it deactivates, so we do not need our own corresponding call to
|
||||
// StopPython
|
||||
editorPythonEventsInterface->StartPython();
|
||||
}
|
||||
|
||||
// Delay execution of commands and scripts post initialization
|
||||
QTimer::singleShot(
|
||||
0,
|
||||
[this]()
|
||||
{
|
||||
ProcessCommandLine(m_commandLine);
|
||||
});
|
||||
}
|
||||
|
||||
bool AtomToolsApplication::GetAssetDatabaseLocation(AZStd::string& result)
|
||||
@@ -387,6 +382,34 @@ namespace AtomToolsFramework
|
||||
appType.m_maskValue = AZ::ApplicationTypeQuery::Masks::Game;
|
||||
}
|
||||
|
||||
void AtomToolsApplication::OnTraceMessage([[maybe_unused]] AZStd::string_view message)
|
||||
{
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
AZStd::vector<AZStd::string> lines;
|
||||
AzFramework::StringFunc::Tokenize(
|
||||
message, lines, "\n",
|
||||
false, // Keep empty strings
|
||||
false // Keep space strings
|
||||
);
|
||||
|
||||
for (auto& line : lines)
|
||||
{
|
||||
AZ_TracePrintf(targetName.c_str(), "Python: %s\n", line.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomToolsApplication::OnErrorMessage(AZStd::string_view message)
|
||||
{
|
||||
// Use AZ_TracePrintf instead of AZ_Error or AZ_Warning to avoid all the metadata noise
|
||||
OnTraceMessage(message);
|
||||
}
|
||||
|
||||
void AtomToolsApplication::OnExceptionMessage([[maybe_unused]] AZStd::string_view message)
|
||||
{
|
||||
AZ_Error(targetName.c_str(), false, "Python: " AZ_STRING_FORMAT, AZ_STRING_ARG(message));
|
||||
}
|
||||
|
||||
// Copied from PyIdleWaitFrames in CryEdit.cpp
|
||||
void AtomToolsApplication::PyIdleWaitFrames(uint32_t frames)
|
||||
{
|
||||
@@ -421,5 +444,9 @@ namespace AtomToolsFramework
|
||||
Ticker ticker(&loop, frames);
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
|
||||
void AtomToolsApplication::setTargetName(AZStd::string newTargetName)
|
||||
{
|
||||
targetName = newTargetName;
|
||||
}
|
||||
} // namespace AtomToolsFramework
|
||||
|
||||
@@ -5,7 +5,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
|
||||
#include <Atom/Document/MaterialDocumentModule.h>
|
||||
#include <Atom/Document/MaterialDocumentSystemRequestBus.h>
|
||||
|
||||
#include <Atom/Viewport/MaterialViewportModule.h>
|
||||
|
||||
#include <Atom/Window/MaterialEditorWindowModule.h>
|
||||
#include <Atom/Window/MaterialEditorWindowFactoryRequestBus.h>
|
||||
#include <Atom/Window/MaterialEditorWindowRequestBus.h>
|
||||
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
@@ -25,24 +40,9 @@
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyManagerComponent.h>
|
||||
#include <AzToolsFramework/SourceControl/SourceControlAPI.h>
|
||||
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
|
||||
#include <Source/MaterialEditorApplication.h>
|
||||
#include <MaterialEditor_Traits_Platform.h>
|
||||
|
||||
#include <Atom/Document/MaterialDocumentModule.h>
|
||||
#include <Atom/Document/MaterialDocumentSystemRequestBus.h>
|
||||
|
||||
#include <Atom/Viewport/MaterialViewportModule.h>
|
||||
|
||||
#include <Atom/Window/MaterialEditorWindowModule.h>
|
||||
#include <Atom/Window/MaterialEditorWindowFactoryRequestBus.h>
|
||||
#include <Atom/Window/MaterialEditorWindowRequestBus.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <QObject>
|
||||
#include <QMessageBox>
|
||||
@@ -75,6 +75,7 @@ namespace MaterialEditor
|
||||
|
||||
{
|
||||
QApplication::setApplicationName("O3DE Material Editor");
|
||||
setTargetName("MaterialEditor");
|
||||
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization(
|
||||
*AZ::SettingsRegistry::Get(), GetBuildTargetName());
|
||||
@@ -95,8 +96,7 @@ namespace MaterialEditor
|
||||
|
||||
void MaterialEditorApplication::CreateStaticModules(AZStd::vector<AZ::Module*>& outModules)
|
||||
{
|
||||
Application::CreateStaticModules(outModules);
|
||||
outModules.push_back(aznew AzToolsFramework::AzToolsFrameworkModule);
|
||||
Base::CreateStaticModules(outModules);
|
||||
outModules.push_back(aznew MaterialDocumentModule);
|
||||
outModules.push_back(aznew MaterialViewportModule);
|
||||
outModules.push_back(aznew MaterialEditorWindowModule);
|
||||
@@ -108,14 +108,7 @@ namespace MaterialEditor
|
||||
//[GFX TODO][ATOM-408] This needs to be updated in some way to support the MaterialViewport render widget
|
||||
}
|
||||
|
||||
AzFramework::AssetSystemStatusBus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusConnect();
|
||||
|
||||
AzFramework::Application::StartCommon(systemEntity);
|
||||
|
||||
StartInternal();
|
||||
|
||||
m_timer.start();
|
||||
Base::StartCommon(systemEntity);
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::OnMaterialEditorWindowClosing()
|
||||
@@ -129,16 +122,9 @@ namespace MaterialEditor
|
||||
MaterialEditor::MaterialEditorWindowFactoryRequestBus::Broadcast(
|
||||
&MaterialEditor::MaterialEditorWindowFactoryRequestBus::Handler::DestroyMaterialEditorWindow);
|
||||
|
||||
AzToolsFramework::EditorPythonConsoleNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusDisconnect();
|
||||
MaterialEditorWindowNotificationBus::Handler::BusDisconnect();
|
||||
AZ::Debug::TraceMessageBus::Handler::BusDisconnect();
|
||||
|
||||
m_logFile = {};
|
||||
m_startupLogSink = {};
|
||||
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::StartDisconnectingAssetProcessor);
|
||||
Application::Destroy();
|
||||
Base::Destroy();
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::AssetSystemAvailable()
|
||||
@@ -160,75 +146,17 @@ namespace MaterialEditor
|
||||
};
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(connectedToAssetProcessor,
|
||||
&AzFramework::AssetSystemRequestBus::Events::EstablishAssetProcessorConnection, connectionSettings);
|
||||
if (connectedToAssetProcessor)
|
||||
{
|
||||
CompileCriticalAssets();
|
||||
}
|
||||
|
||||
AzFramework::AssetSystemStatusBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
|
||||
void MaterialEditorApplication::CompileCriticalAssets()
|
||||
{
|
||||
AZ_TracePrintf("MaterialEditor", "Compiling critical assets.\n");
|
||||
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
const AZStd::string assetFiltersArray[] =
|
||||
const AZStd::vector<AZStd::string> assetFiltersArray = { "passes/", "config/", "MaterialEditor/" };
|
||||
|
||||
if (connectedToAssetProcessor)
|
||||
{
|
||||
"passes/",
|
||||
"config/",
|
||||
"MaterialEditor/",
|
||||
};
|
||||
|
||||
QStringList failedAssets;
|
||||
|
||||
// Forced asset processor to synchronously process all critical assets
|
||||
// Note: with AssetManager's current implementation, a compiled asset won't be added in asset registry until next system tick.
|
||||
// So the asset id won't be found right after CompileAssetSync call.
|
||||
for (const AZStd::string& assetFilters : assetFiltersArray)
|
||||
{
|
||||
AZ_TracePrintf("MaterialEditor", "Compiling critical asset matching: %s.\n", assetFilters.c_str());
|
||||
|
||||
// Wait for the asset be compiled
|
||||
AzFramework::AssetSystem::AssetStatus status = AzFramework::AssetSystem::AssetStatus_Unknown;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, assetFilters);
|
||||
if (status != AzFramework::AssetSystem::AssetStatus_Compiled)
|
||||
{
|
||||
failedAssets.append(assetFilters.c_str());
|
||||
}
|
||||
CompileCriticalAssets(assetFiltersArray);
|
||||
}
|
||||
|
||||
if (!failedAssets.empty())
|
||||
{
|
||||
QMessageBox::critical(activeWindow(),
|
||||
QString("Failed to compile critical assets"),
|
||||
QString("Failed to compile the following critical assets:\n%1\n%2")
|
||||
.arg(failedAssets.join(",\n"))
|
||||
.arg("Make sure this is an Atom project."));
|
||||
ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
AzFramework::AssetSystemStatusBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::ProcessCommandLine(const AZ::CommandLine& commandLine)
|
||||
@@ -286,27 +214,7 @@ namespace MaterialEditor
|
||||
|
||||
void MaterialEditorApplication::StartInternal()
|
||||
{
|
||||
if (WasExitMainLoopRequested())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_traceLogger.WriteStartupLog("MaterialEditor.log");
|
||||
|
||||
if (!LaunchDiscoveryService())
|
||||
{
|
||||
ExitMainLoop();
|
||||
return;
|
||||
}
|
||||
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusConnect();
|
||||
AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotificationBus::Broadcast(&AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotifications::OnDatabaseInitialized);
|
||||
|
||||
AZ::Data::AssetCatalogRequestBus::Broadcast(&AZ::Data::AssetCatalogRequestBus::Events::LoadCatalog, "@assets@/assetcatalog.xml");
|
||||
|
||||
AZ::RPI::RPISystemInterface::Get()->InitializeSystemAssets();
|
||||
|
||||
LoadSettings();
|
||||
Base::StartInternal();
|
||||
|
||||
MaterialEditorWindowNotificationBus::Handler::BusConnect();
|
||||
|
||||
@@ -325,54 +233,11 @@ namespace MaterialEditor
|
||||
QTimer::singleShot(0, [this]() { ProcessCommandLine(m_commandLine); });
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::Tick(float deltaOverride)
|
||||
{
|
||||
TickSystem();
|
||||
Application::Tick(deltaOverride);
|
||||
|
||||
if (WasExitMainLoopRequested())
|
||||
{
|
||||
m_timer.disconnect();
|
||||
quit();
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::Stop()
|
||||
{
|
||||
MaterialEditor::MaterialEditorWindowFactoryRequestBus::Broadcast(
|
||||
&MaterialEditor::MaterialEditorWindowFactoryRequestBus::Handler::DestroyMaterialEditorWindow);
|
||||
|
||||
UnloadSettings();
|
||||
AzFramework::Application::Stop();
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::OnTraceMessage([[maybe_unused]] AZStd::string_view message)
|
||||
{
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
AZStd::vector<AZStd::string> lines;
|
||||
AzFramework::StringFunc::Tokenize(
|
||||
message,
|
||||
lines,
|
||||
"\n",
|
||||
false, // Keep empty strings
|
||||
false // Keep space strings
|
||||
);
|
||||
|
||||
for (auto& line : lines)
|
||||
{
|
||||
AZ_TracePrintf("MaterialEditor", "Python: %s\n", line.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::OnErrorMessage(AZStd::string_view message)
|
||||
{
|
||||
// Use AZ_TracePrintf instead of AZ_Error or AZ_Warning to avoid all the metadata noise
|
||||
OnTraceMessage(message);
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::OnExceptionMessage([[maybe_unused]] AZStd::string_view message)
|
||||
{
|
||||
AZ_Error("MaterialEditor", false, "Python: " AZ_STRING_FORMAT, AZ_STRING_ARG(message));
|
||||
Base::Stop();
|
||||
}
|
||||
} // namespace MaterialEditor
|
||||
|
||||
@@ -9,19 +9,6 @@
|
||||
|
||||
#include <Atom/Document/MaterialDocumentSystemRequestBus.h>
|
||||
#include <Atom/Window/MaterialEditorWindowNotificationBus.h>
|
||||
#include <AtomToolsFramework/Communication/LocalServer.h>
|
||||
#include <AtomToolsFramework/Communication/LocalSocket.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzCore/UserSettings/UserSettingsProvider.h>
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
#include <AzFramework/Logging/LogFile.h>
|
||||
#include <AzToolsFramework/API/AssetDatabaseBus.h>
|
||||
#include <AzToolsFramework/API/EditorPythonConsoleBus.h>
|
||||
#include <AzToolsFramework/Logger/TraceLogger.h>
|
||||
#include <AzQtComponents/Application/AzQtApplication.h>
|
||||
#include <AtomToolsFramework/Application/AtomToolsApplication.h>
|
||||
|
||||
#include <QTimer>
|
||||
@@ -47,7 +34,6 @@ namespace MaterialEditor
|
||||
void CreateStaticModules(AZStd::vector<AZ::Module*>& outModules) override;
|
||||
const char* GetCurrentConfigurationName() const override;
|
||||
void StartCommon(AZ::Entity* systemEntity) override;
|
||||
void Tick(float deltaOverride = -1.f) override;
|
||||
void Stop() override;
|
||||
|
||||
private:
|
||||
@@ -61,34 +47,12 @@ namespace MaterialEditor
|
||||
void Destroy() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// EditorPythonConsoleNotificationBus::Handler overrides...
|
||||
void OnTraceMessage(AZStd::string_view message) override;
|
||||
void OnErrorMessage(AZStd::string_view message) override;
|
||||
void OnExceptionMessage(AZStd::string_view message) override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzFramework::AssetSystemStatusBus::Handler overrides...
|
||||
void AssetSystemAvailable() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Debug::TraceMessageBus::Handler overrides...
|
||||
bool OnOutput(const char* window, const char* message) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CompileCriticalAssets() override;
|
||||
void ProcessCommandLine(const AZ::CommandLine& commandLine) override;
|
||||
void StartInternal() override;
|
||||
|
||||
struct LogMessage
|
||||
{
|
||||
AZStd::string window;
|
||||
AZStd::string message;
|
||||
};
|
||||
|
||||
AZStd::vector<LogMessage> m_startupLogSink;
|
||||
AZStd::unique_ptr<AzFramework::LogFile> m_logFile;
|
||||
};
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
|
||||
+16
-96
@@ -70,6 +70,7 @@ namespace ShaderManagementConsole
|
||||
: AtomToolsApplication(argc, argv)
|
||||
{
|
||||
QApplication::setApplicationName("O3DE Shader Management Console");
|
||||
setTargetName("ShaderManagementConsole");
|
||||
|
||||
// The settings registry has been created at this point, so add the CMake target
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddBuildSystemTargetSpecialization(
|
||||
@@ -98,7 +99,6 @@ namespace ShaderManagementConsole
|
||||
|
||||
ShaderManagementConsoleWindowNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusDisconnect();
|
||||
AZ::Debug::TraceMessageBus::Handler::BusDisconnect();
|
||||
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::StartDisconnectingAssetProcessor);
|
||||
|
||||
@@ -129,66 +129,28 @@ namespace ShaderManagementConsole
|
||||
};
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(ConnectToAssetProcessorWithIdentifier);
|
||||
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
const AZStd::vector<AZStd::string> assetFiltersArray = { "passes/", "config/"};
|
||||
|
||||
if (connected)
|
||||
{
|
||||
CompileCriticalAssets();
|
||||
CompileCriticalAssets(assetFiltersArray);
|
||||
}
|
||||
|
||||
AzFramework::AssetSystemStatusBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::CompileCriticalAssets()
|
||||
{
|
||||
AZ_TracePrintf("Shader Management Console", "Compiling critical assets.\n");
|
||||
|
||||
// List of common asset filters for things that need to be compiled to run
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
const AZStd::string assetFilterss[] =
|
||||
{
|
||||
"passes/",
|
||||
"config/",
|
||||
};
|
||||
|
||||
QStringList failedAssets;
|
||||
|
||||
// Forced asset processor to synchronously process all critical assets
|
||||
// Note: with AssetManager's current implementation, a compiled asset won't be added in asset registry until next system tick.
|
||||
// So the asset id won't be found right after CompileAssetSync call.
|
||||
for (const AZStd::string& assetFilters : assetFilterss)
|
||||
{
|
||||
AZ_TracePrintf("Shader Management Console", "Compiling critical asset matching: %s.\n", assetFilters.c_str());
|
||||
|
||||
// Wait for the asset be compiled
|
||||
AzFramework::AssetSystem::AssetStatus status = AzFramework::AssetSystem::AssetStatus_Unknown;
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
status, &AzFramework::AssetSystemRequestBus::Events::CompileAssetSync, assetFilters);
|
||||
if (status != AzFramework::AssetSystem::AssetStatus_Compiled)
|
||||
{
|
||||
failedAssets.append(assetFilters.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (!failedAssets.empty())
|
||||
{
|
||||
QMessageBox::critical(activeWindow(),
|
||||
QString("Failed to compile critical assets"),
|
||||
QString("Failed to compile the following critical assets:\n%1\n%2")
|
||||
.arg(failedAssets.join(",\n"))
|
||||
.arg("Make sure this is an Atom project."));
|
||||
ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
bool ShaderManagementConsoleApplication::OnPrintf(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;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// bool ShaderManagementConsoleApplication::OnPrintf(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;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
void ShaderManagementConsoleApplication::ProcessCommandLine()
|
||||
{
|
||||
@@ -263,46 +225,4 @@ namespace ShaderManagementConsole
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::Tick(float deltaOverride)
|
||||
{
|
||||
TickSystem();
|
||||
Application::Tick(deltaOverride);
|
||||
|
||||
if (WasExitMainLoopRequested())
|
||||
{
|
||||
m_timer.disconnect();
|
||||
quit();
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::OnTraceMessage([[maybe_unused]] AZStd::string_view message)
|
||||
{
|
||||
#if defined(AZ_ENABLE_TRACING)
|
||||
AZStd::vector<AZStd::string> lines;
|
||||
AzFramework::StringFunc::Tokenize(
|
||||
message,
|
||||
lines,
|
||||
"\n",
|
||||
false, // Keep empty strings
|
||||
false // Keep space strings
|
||||
);
|
||||
|
||||
for (auto& line : lines)
|
||||
{
|
||||
AZ_TracePrintf("Shader Management Console", "Python: %s\n", line.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::OnErrorMessage(AZStd::string_view message)
|
||||
{
|
||||
// Use AZ_TracePrintf instead of AZ_Error or AZ_Warning to avoid all the metadata noise
|
||||
OnTraceMessage(message);
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::OnExceptionMessage([[maybe_unused]] AZStd::string_view message)
|
||||
{
|
||||
AZ_Error("Shader Management Console", false, "Python: " AZ_STRING_FORMAT, AZ_STRING_ARG(message));
|
||||
}
|
||||
} // namespace ShaderManagementConsole
|
||||
|
||||
+1
-29
@@ -7,22 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Entity.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <AzCore/UserSettings/UserSettingsProvider.h>
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
|
||||
#include <AzFramework/Application/Application.h>
|
||||
#include <AzFramework/Asset/AssetSystemBus.h>
|
||||
|
||||
#include <AzToolsFramework/API/AssetDatabaseBus.h>
|
||||
#include <AzToolsFramework/API/EditorPythonConsoleBus.h>
|
||||
#include <AzToolsFramework/Logger/TraceLogger.h>
|
||||
|
||||
#include <Atom/Document/ShaderManagementConsoleDocumentSystemRequestBus.h>
|
||||
#include <Atom/Window/ShaderManagementConsoleWindowNotificationBus.h>
|
||||
|
||||
#include <AzQtComponents/Application/AzQtApplication.h>
|
||||
#include <AtomToolsFramework/Application/AtomToolsApplication.h>
|
||||
|
||||
#include <QTimer>
|
||||
@@ -34,7 +20,7 @@ namespace ShaderManagementConsole
|
||||
, private ShaderManagementConsoleWindowNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(ShaderManagementConsole::ShaderManagementConsoleApplication, "{30F90CA5-1253-49B5-8143-19CEE37E22BB}");
|
||||
AZ_TYPE_INFO(ShaderManagementConsole::ShaderManagementConsoleApplication, "{A31B1AEB-4DA3-49CD-884A-CC998FF7546F}");
|
||||
|
||||
using Base = AzFramework::Application;
|
||||
|
||||
@@ -45,7 +31,6 @@ namespace ShaderManagementConsole
|
||||
// AzFramework::Application
|
||||
void CreateStaticModules(AZStd::vector<AZ::Module*>& outModules) override;
|
||||
const char* GetCurrentConfigurationName() const override;
|
||||
void Tick(float deltaOverride = -1.f) override;
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -63,24 +48,11 @@ namespace ShaderManagementConsole
|
||||
void Destroy() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// EditorPythonConsoleNotificationBus::Handler overrides...
|
||||
void OnTraceMessage(AZStd::string_view message) override;
|
||||
void OnErrorMessage(AZStd::string_view message) override;
|
||||
void OnExceptionMessage(AZStd::string_view message) override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzFramework::AssetSystemStatusBus::Handler overrides...
|
||||
void AssetSystemAvailable() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Debug::TraceMessageBus::Handler overrides...
|
||||
bool OnPrintf(const char* window, const char* message) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CompileCriticalAssets() override;
|
||||
void ProcessCommandLine();
|
||||
void StartInternal() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user