Add Project Manager File menu options to Editor

This commit is contained in:
Alex Peterson
2021-06-01 15:30:14 -07:00
committed by GitHub
parent 9e3b7b45d9
commit afe20906db
14 changed files with 147 additions and 17 deletions
@@ -78,7 +78,7 @@ namespace AzFramework::ProjectManager
projectJsonPath.c_str());
}
if (LaunchProjectManager(engineRootPath))
if (LaunchProjectManager())
{
AZ_TracePrintf("ProjectManager", "Project Manager launched successfully, requesting exit.");
return ProjectPathCheckResult::ProjectManagerLaunched;
@@ -87,7 +87,7 @@ namespace AzFramework::ProjectManager
return ProjectPathCheckResult::ProjectManagerLaunchFailed;
}
bool LaunchProjectManager([[maybe_unused]] const AZ::IO::FixedMaxPath& engineRootPath)
bool LaunchProjectManager(const AZStd::string& commandLineArgs)
{
bool launchSuccess = false;
#if (AZ_TRAIT_AZFRAMEWORK_USE_PROJECT_MANAGER)
@@ -109,7 +109,7 @@ namespace AzFramework::ProjectManager
}
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
processLaunchInfo.m_commandlineParameters = executablePath.String();
processLaunchInfo.m_commandlineParameters = executablePath.String() + commandLineArgs;
launchSuccess = AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo);
}
if (ownsSystemAllocator)
@@ -12,6 +12,7 @@
#pragma once
#include <AzCore/IO/Path/Path_fwd.h>
#include <AzCore/std/string/string.h>
namespace AzFramework::ProjectManager
{
@@ -21,8 +22,16 @@ namespace AzFramework::ProjectManager
ProjectManagerLaunched = 0,
ProjectPathFound = 1
};
// Check for a project name, if not found, attempts to launch project manager and returns false
//! Check for a project name, if not found, attempts to launch project manager and returns false
//! @param argc the number of arguments in argv
//! @param argv arguments provided to this executable
//! @return a ProjectPathCheckResult
ProjectPathCheckResult CheckProjectPathProvided(const int argc, char* argv[]);
// Attempt to Launch the project manager. Requires locating the engine root, project manager script, and python.
bool LaunchProjectManager(const AZ::IO::FixedMaxPath& engineRootPath);
//! Attempt to Launch the project manager, assuming the o3de executable exists in same folder as
//! current executable. Requires the o3de cli and python.
//! @param commandLineArgs additional command line arguments to provide to the project manager
//! @return true on success, false if failed to find or launch the executable
bool LaunchProjectManager(const AZStd::string& commandLineArgs = "");
} // AzFramework::ProjectManager
@@ -421,17 +421,18 @@ QMenu* LevelEditorMenuHandler::CreateFileMenu()
fileMenu.AddSeparator();
// Project Settings
auto projectSettingMenu = fileMenu.AddMenu(tr("Project Settings"));
fileMenu.AddAction(ID_FILE_PROJECT_MANAGER_SETTINGS);
// Project Settings Tool
// Platform Settings - Project Settings Tool
// Shortcut must be set while adding the action otherwise it doesn't work
projectSettingMenu.Get()->addAction(
fileMenu.Get()->addAction(
tr(LyViewPane::ProjectSettingsTool),
[]() { QtViewPaneManager::instance()->OpenPane(LyViewPane::ProjectSettingsTool); },
tr("Ctrl+Shift+P"));
projectSettingMenu.AddSeparator();
fileMenu.AddSeparator();
fileMenu.AddAction(ID_FILE_PROJECT_MANAGER_NEW);
fileMenu.AddAction(ID_FILE_PROJECT_MANAGER_OPEN);
fileMenu.AddSeparator();
// NEWMENUS: NEEDS IMPLEMENTATION
+34
View File
@@ -58,6 +58,7 @@ AZ_POP_DISABLE_WARNING
#include <AzFramework/Components/CameraBus.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
#include <AzFramework/ProjectManager/ProjectManager.h>
// AzToolsFramework
#include <AzToolsFramework/Component/EditorComponentAPIBus.h>
@@ -477,6 +478,11 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_FILE_SAVE_LEVEL, OnFileSave)
ON_COMMAND(ID_FILE_EXPORTOCCLUSIONMESH, OnFileExportOcclusionMesh)
// Project Manager
ON_COMMAND(ID_FILE_PROJECT_MANAGER_SETTINGS, OnOpenProjectManagerSettings)
ON_COMMAND(ID_FILE_PROJECT_MANAGER_NEW, OnOpenProjectManagerNew)
ON_COMMAND(ID_FILE_PROJECT_MANAGER_OPEN, OnOpenProjectManager)
}
CCryEditApp* CCryEditApp::s_currentInstance = nullptr;
@@ -2854,6 +2860,34 @@ void CCryEditApp::OnPreferences()
*/
}
void CCryEditApp::OnOpenProjectManagerSettings()
{
OpenProjectManager("UpdateProject");
}
void CCryEditApp::OnOpenProjectManagerNew()
{
OpenProjectManager("CreateProject");
}
void CCryEditApp::OnOpenProjectManager()
{
OpenProjectManager("Projects");
}
void CCryEditApp::OpenProjectManager(const AZStd::string& screen)
{
// provide the current project path for in case we want to update the project
AZ::IO::FixedMaxPathString projectPath = AZ::Utils::GetProjectPath();
const AZStd::string commandLineOptions = AZStd::string::format(" --screen %s --project_path %s", screen.c_str(), projectPath.c_str());
bool launchSuccess = AzFramework::ProjectManager::LaunchProjectManager(commandLineOptions);
if (!launchSuccess)
{
QMessageBox::critical(AzToolsFramework::GetActiveWindow(), QObject::tr("Failed to launch O3DE Project Manager"), QObject::tr("Failed to find or start the O3dE Project Manager"));
}
}
//////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnUndo()
{
+4
View File
@@ -229,6 +229,9 @@ public:
void OnFileResaveSlices();
void OnFileEditEditorini();
void OnPreferences();
void OnOpenProjectManagerSettings();
void OnOpenProjectManagerNew();
void OnOpenProjectManager();
void OnRedo();
void OnUpdateRedo(QAction* action);
void OnUpdateUndo(QAction* action);
@@ -366,6 +369,7 @@ private:
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
friend struct PythonTestOutputHandler;
void OpenProjectManager(const AZStd::string& screen);
void OnWireframe();
void OnUpdateWireframe(QAction* action);
void OnViewConfigureLayout();
+1 -1
View File
@@ -30,7 +30,7 @@ namespace LyViewPane
static const char* const EntityInspector = "Entity Inspector";
static const char* const EntityInspectorPinned = "Pinned Entity Inspector";
static const char* const LevelInspector = "Level Inspector";
static const char* const ProjectSettingsTool = "Project Settings Tool";
static const char* const ProjectSettingsTool = "Edit Platform Settings...";
static const char* const ErrorReport = "Error Report";
static const char* const Console = "Console";
static const char* const ConsoleMenuName = "&Console";
+3
View File
@@ -748,6 +748,9 @@ void MainWindow::InitActions()
am->AddAction(ID_FILE_EXPORTOCCLUSIONMESH, tr("Export Occlusion Mesh"));
am->AddAction(ID_FILE_EDITLOGFILE, tr("Show Log File"));
am->AddAction(ID_FILE_RESAVESLICES, tr("Resave All Slices"));
am->AddAction(ID_FILE_PROJECT_MANAGER_SETTINGS, tr("Edit Project Settings..."));
am->AddAction(ID_FILE_PROJECT_MANAGER_NEW, tr("New Project..."));
am->AddAction(ID_FILE_PROJECT_MANAGER_OPEN, tr("Open Project..."));
am->AddAction(ID_GAME_PC_ENABLEVERYHIGHSPEC, tr("Very High")).SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateGameSpec);
am->AddAction(ID_GAME_PC_ENABLEHIGHSPEC, tr("High")).SetCheckable(true)
+3
View File
@@ -313,6 +313,9 @@
#define ID_CREATE_LEVEL_FG_MODULE_FROM_SELECTION 35077
#define ID_GRAPHVIEW_ADD_BLACK_BOX 35078
#define ID_GRAPHVIEW_UNGROUP 35079
#define ID_FILE_PROJECT_MANAGER_NEW 35080
#define ID_FILE_PROJECT_MANAGER_OPEN 35081
#define ID_FILE_PROJECT_MANAGER_SETTINGS 35082
#define ID_TV_TRACKS_TOOLBAR_BASE 35083 // range between ID_TV_TRACKS_TOOLBAR_BASE to ID_TV_TRACKS_TOOLBAR_LAST reserved
#define ID_TV_TRACKS_TOOLBAR_LAST 35183 // for up to 100 "Add Tracks..." dynamically added Track View Track buttons
#define ID_OPEN_TERRAIN_EDITOR 36007
@@ -14,13 +14,16 @@
#include <ScreensCtrl.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/Path/Path.h>
#include <AzFramework/CommandLine/CommandLine.h>
#include <AzFramework/Application/Application.h>
#include <QDir>
namespace O3DE::ProjectManager
{
ProjectManagerWindow::ProjectManagerWindow(QWidget* parent, const AZ::IO::PathView& engineRootPath)
ProjectManagerWindow::ProjectManagerWindow(QWidget* parent, const AZ::IO::PathView& engineRootPath, const AZ::IO::PathView& projectPath, ProjectManagerScreen startScreen)
: QMainWindow(parent)
{
m_pythonBindings = AZStd::make_unique<PythonBindings>(engineRootPath);
@@ -50,7 +53,18 @@ namespace O3DE::ProjectManager
// set stylesheet after creating the screens or their styles won't get updated
AzQtComponents::StyleManager::setStyleSheet(this, QStringLiteral("style:ProjectManager.qss"));
screensCtrl->ForceChangeToScreen(ProjectManagerScreen::Projects, false);
// always push the projects screen first so we have something to come back to
if (startScreen != ProjectManagerScreen::Projects)
{
screensCtrl->ForceChangeToScreen(ProjectManagerScreen::Projects);
}
screensCtrl->ForceChangeToScreen(startScreen);
if (!projectPath.empty())
{
const QString path = QString::fromUtf8(projectPath.Native().data(), aznumeric_cast<int>(projectPath.Native().size()));
emit screensCtrl->NotifyCurrentProject(path);
}
}
ProjectManagerWindow::~ProjectManagerWindow()
@@ -14,6 +14,7 @@
#if !defined(Q_MOC_RUN)
#include <QMainWindow>
#include <PythonBindings.h>
#include <ScreenDefs.h>
#endif
namespace O3DE::ProjectManager
@@ -24,7 +25,8 @@ namespace O3DE::ProjectManager
Q_OBJECT
public:
explicit ProjectManagerWindow(QWidget* parent, const AZ::IO::PathView& engineRootPath);
explicit ProjectManagerWindow(QWidget* parent, const AZ::IO::PathView& engineRootPath, const AZ::IO::PathView& projectPath,
ProjectManagerScreen startScreen = ProjectManagerScreen::Projects);
~ProjectManagerWindow();
private:
@@ -192,5 +192,16 @@ namespace O3DE::ProjectManager
return true;
}
ProjectManagerScreen GetProjectManagerScreen(const QString& screen)
{
auto iter = s_ProjectManagerStringNames.find(screen);
if (iter != s_ProjectManagerStringNames.end())
{
return iter.value();
}
return ProjectManagerScreen::Invalid;
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
@@ -11,6 +11,7 @@
*/
#pragma once
#include <ScreenDefs.h>
#include <QWidget>
namespace O3DE::ProjectManager
@@ -24,5 +25,6 @@ namespace O3DE::ProjectManager
bool CopyProject(const QString& origPath, const QString& newPath);
bool DeleteProjectFiles(const QString& path, bool force = false);
bool MoveProject(const QString& origPath, const QString& newPath, QWidget* parent = nullptr);
ProjectManagerScreen GetProjectManagerScreen(const QString& screen);
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager
+22 -1
View File
@@ -11,9 +11,13 @@
*/
#pragma once
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
#include <QHash>
namespace O3DE::ProjectManager
{
enum ProjectManagerScreen
enum class ProjectManagerScreen
{
Invalid = -1,
Empty,
@@ -25,4 +29,21 @@ namespace O3DE::ProjectManager
ProjectSettings,
EngineSettings
};
static QHash<QString, ProjectManagerScreen> s_ProjectManagerStringNames = {
{ "Empty", ProjectManagerScreen::Empty},
{ "CreateProject", ProjectManagerScreen::CreateProject},
{ "NewProjectSettings", ProjectManagerScreen::NewProjectSettings},
{ "GemCatalog", ProjectManagerScreen::GemCatalog},
{ "Projects", ProjectManagerScreen::Projects},
{ "UpdateProject", ProjectManagerScreen::UpdateProject},
{ "ProjectSettings", ProjectManagerScreen::ProjectSettings},
{ "EngineSettings", ProjectManagerScreen::EngineSettings}
};
// need to define qHash for ProjectManagerScreen when using scoped enums
inline uint qHash(ProjectManagerScreen key, uint seed)
{
return ::qHash(static_cast<uint>(key), seed);
}
} // namespace O3DE::ProjectManager
+27 -1
View File
@@ -15,13 +15,17 @@
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/IO/Path/Path.h>
#include <AzFramework/CommandLine/CommandLine.h>
#include <ProjectManagerWindow.h>
#include <ProjectUtils.h>
#include <QApplication>
#include <QCoreApplication>
#include <QGuiApplication>
using namespace O3DE::ProjectManager;
int main(int argc, char* argv[])
{
QApplication::setOrganizationName("O3DE");
@@ -51,7 +55,29 @@ int main(int argc, char* argv[])
AzQtComponents::StyleManager styleManager(&app);
styleManager.initialize(&app, engineRootPath);
O3DE::ProjectManager::ProjectManagerWindow window(nullptr, engineRootPath);
// Get the initial start screen if one is provided via command line
constexpr char optionPrefix[] = "--";
AZ::CommandLine commandLine(optionPrefix);
commandLine.Parse(argc, argv);
ProjectManagerScreen startScreen = ProjectManagerScreen::Projects;
if(commandLine.HasSwitch("screen"))
{
QString screenOption = commandLine.GetSwitchValue("screen", 0).c_str();
ProjectManagerScreen screen = ProjectUtils::GetProjectManagerScreen(screenOption);
if (screen != ProjectManagerScreen::Invalid)
{
startScreen = screen;
}
}
AZ::IO::FixedMaxPath projectPath;
if (commandLine.HasSwitch("project-path"))
{
projectPath = commandLine.GetSwitchValue("project-path", 0).c_str();
}
ProjectManagerWindow window(nullptr, engineRootPath, projectPath, startScreen);
window.show();
// somethings is preventing us from moving the window to the center of the