Atom Tools: Created base class for document-based applications
Moving some duplicated code to a common base class Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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/Application/AtomToolsApplication.h>
|
||||
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
class AtomToolsDocumentApplication
|
||||
: public AtomToolsApplication
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(AtomToolsDocumentApplication, "{F4B43677-EB95-4CBB-8B8E-9EF4247E6F0D}");
|
||||
|
||||
using Base = AtomToolsApplication;
|
||||
|
||||
AtomToolsDocumentApplication(int* argc, char*** argv);
|
||||
|
||||
// AtomToolsApplication overrides...
|
||||
void ProcessCommandLine(const AZ::CommandLine& commandLine) override;
|
||||
};
|
||||
} // namespace AtomToolsFramework
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 <AtomToolsFramework/Document/AtomToolsDocumentApplication.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
AtomToolsDocumentApplication::AtomToolsDocumentApplication(int* argc, char*** argv)
|
||||
: Base(argc, argv)
|
||||
{
|
||||
}
|
||||
|
||||
void AtomToolsDocumentApplication::ProcessCommandLine(const AZ::CommandLine& commandLine)
|
||||
{
|
||||
// Process command line options for opening documents on startup
|
||||
size_t openDocumentCount = commandLine.GetNumMiscValues();
|
||||
for (size_t openDocumentIndex = 0; openDocumentIndex < openDocumentCount; ++openDocumentIndex)
|
||||
{
|
||||
const AZStd::string openDocumentPath = commandLine.GetMiscValue(openDocumentIndex);
|
||||
|
||||
AZ_Printf(GetBuildTargetName().c_str(), "Opening document: %s", openDocumentPath.c_str());
|
||||
AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::OpenDocument, openDocumentPath);
|
||||
}
|
||||
|
||||
Base::ProcessCommandLine(commandLine);
|
||||
}
|
||||
} // namespace AtomToolsFramework
|
||||
@@ -12,6 +12,7 @@ set(FILES
|
||||
Include/AtomToolsFramework/Communication/LocalSocket.h
|
||||
Include/AtomToolsFramework/Debug/TraceRecorder.h
|
||||
Include/AtomToolsFramework/Document/AtomToolsDocument.h
|
||||
Include/AtomToolsFramework/Document/AtomToolsDocumentApplication.h
|
||||
Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h
|
||||
Include/AtomToolsFramework/Document/AtomToolsDocumentSystemSettings.h
|
||||
Include/AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h
|
||||
@@ -40,6 +41,7 @@ set(FILES
|
||||
Source/Communication/LocalSocket.cpp
|
||||
Source/Debug/TraceRecorder.cpp
|
||||
Source/Document/AtomToolsDocument.cpp
|
||||
Source/Document/AtomToolsDocumentApplication.cpp
|
||||
Source/Document/AtomToolsDocumentMainWindow.cpp
|
||||
Source/Document/AtomToolsDocumentSystemSettings.cpp
|
||||
Source/Document/AtomToolsDocumentSystemComponent.cpp
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <Atom/Document/MaterialDocumentModule.h>
|
||||
#include <Atom/Viewport/MaterialViewportModule.h>
|
||||
#include <Atom/Window/MaterialEditorWindowModule.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <MaterialEditorApplication.h>
|
||||
#include <MaterialEditor_Traits_Platform.h>
|
||||
@@ -37,7 +36,7 @@ namespace MaterialEditor
|
||||
}
|
||||
|
||||
MaterialEditorApplication::MaterialEditorApplication(int* argc, char*** argv)
|
||||
: AtomToolsApplication(argc, argv)
|
||||
: Base(argc, argv)
|
||||
{
|
||||
QApplication::setApplicationName("O3DE Material Editor");
|
||||
|
||||
@@ -58,19 +57,4 @@ namespace MaterialEditor
|
||||
{
|
||||
return AZStd::vector<AZStd::string>({ "passes/", "config/", "MaterialEditor/" });
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::ProcessCommandLine(const AZ::CommandLine& commandLine)
|
||||
{
|
||||
// Process command line options for opening one or more material documents on startup
|
||||
size_t openDocumentCount = commandLine.GetNumMiscValues();
|
||||
for (size_t openDocumentIndex = 0; openDocumentIndex < openDocumentCount; ++openDocumentIndex)
|
||||
{
|
||||
const AZStd::string openDocumentPath = commandLine.GetMiscValue(openDocumentIndex);
|
||||
|
||||
AZ_Printf(GetBuildTargetName().c_str(), "Opening document: %s", openDocumentPath.c_str());
|
||||
AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, openDocumentPath);
|
||||
}
|
||||
|
||||
Base::ProcessCommandLine(commandLine);
|
||||
}
|
||||
} // namespace MaterialEditor
|
||||
|
||||
@@ -8,30 +8,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AtomToolsFramework/Application/AtomToolsApplication.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentApplication.h>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class MaterialThumbnailRenderer;
|
||||
|
||||
class MaterialEditorApplication
|
||||
: public AtomToolsFramework::AtomToolsApplication
|
||||
: public AtomToolsFramework::AtomToolsDocumentApplication
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(MaterialEditor::MaterialEditorApplication, "{30F90CA5-1253-49B5-8143-19CEE37E22BB}");
|
||||
|
||||
using Base = AtomToolsFramework::AtomToolsApplication;
|
||||
using Base = AtomToolsFramework::AtomToolsDocumentApplication;
|
||||
|
||||
MaterialEditorApplication(int* argc, char*** argv);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzFramework::Application
|
||||
// AzFramework::Application overrides...
|
||||
void CreateStaticModules(AZStd::vector<AZ::Module*>& outModules) override;
|
||||
const char* GetCurrentConfigurationName() const override;
|
||||
|
||||
private:
|
||||
void ProcessCommandLine(const AZ::CommandLine& commandLine) override;
|
||||
// AtomToolsFramework::AtomToolsApplication overrides...
|
||||
AZStd::string GetBuildTargetName() const override;
|
||||
AZStd::vector<AZStd::string> GetCriticalAssetFilters() const override;
|
||||
};
|
||||
|
||||
+1
-18
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <Atom/Document/ShaderManagementConsoleDocumentModule.h>
|
||||
#include <Atom/Window/ShaderManagementConsoleWindowModule.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <ShaderManagementConsoleApplication.h>
|
||||
#include <ShaderManagementConsole_Traits_Platform.h>
|
||||
@@ -36,7 +35,7 @@ namespace ShaderManagementConsole
|
||||
}
|
||||
|
||||
ShaderManagementConsoleApplication::ShaderManagementConsoleApplication(int* argc, char*** argv)
|
||||
: AtomToolsApplication(argc, argv)
|
||||
: Base(argc, argv)
|
||||
{
|
||||
QApplication::setApplicationName("O3DE Shader Management Console");
|
||||
|
||||
@@ -56,20 +55,4 @@ namespace ShaderManagementConsole
|
||||
{
|
||||
return AZStd::vector<AZStd::string>({ "passes/", "config/" });
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::ProcessCommandLine(const AZ::CommandLine& commandLine)
|
||||
{
|
||||
// Process command line options for opening one or more documents on startup
|
||||
size_t openDocumentCount = commandLine.GetNumMiscValues();
|
||||
for (size_t openDocumentIndex = 0; openDocumentIndex < openDocumentCount; ++openDocumentIndex)
|
||||
{
|
||||
const AZStd::string openDocumentPath = commandLine.GetMiscValue(openDocumentIndex);
|
||||
|
||||
AZ_Printf(GetBuildTargetName().c_str(), "Opening document: %s", openDocumentPath.c_str());
|
||||
AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(
|
||||
&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, openDocumentPath);
|
||||
}
|
||||
|
||||
Base::ProcessCommandLine(commandLine);
|
||||
}
|
||||
} // namespace ShaderManagementConsole
|
||||
|
||||
+5
-8
@@ -8,28 +8,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AtomToolsFramework/Application/AtomToolsApplication.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentApplication.h>
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
class ShaderManagementConsoleApplication
|
||||
: public AtomToolsFramework::AtomToolsApplication
|
||||
: public AtomToolsFramework::AtomToolsDocumentApplication
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(ShaderManagementConsole::ShaderManagementConsoleApplication, "{A31B1AEB-4DA3-49CD-884A-CC998FF7546F}");
|
||||
|
||||
using Base = AtomToolsFramework::AtomToolsApplication;
|
||||
using Base = AtomToolsFramework::AtomToolsDocumentApplication;
|
||||
|
||||
ShaderManagementConsoleApplication(int* argc, char*** argv);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzFramework::Application
|
||||
// AzFramework::Application overrides...
|
||||
void CreateStaticModules(AZStd::vector<AZ::Module*>& outModules) override;
|
||||
const char* GetCurrentConfigurationName() const override;
|
||||
|
||||
private:
|
||||
void ProcessCommandLine(const AZ::CommandLine& commandLine);
|
||||
// AtomToolsFramework::AtomToolsApplication overrides...
|
||||
AZStd::string GetBuildTargetName() const override;
|
||||
AZStd::vector<AZStd::string> GetCriticalAssetFilters() const override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user