GUI for engine force registration and renaming (#6184)
Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -111,6 +112,11 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
}
|
||||
|
||||
if (!RegisterEngine(interactive))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const AZ::CommandLine* commandLine = GetCommandLine();
|
||||
AZ_Assert(commandLine, "Failed to get command line");
|
||||
|
||||
@@ -165,6 +171,86 @@ namespace O3DE::ProjectManager
|
||||
return m_entity != nullptr;
|
||||
}
|
||||
|
||||
bool Application::RegisterEngine(bool interactive)
|
||||
{
|
||||
// get this engine's info
|
||||
auto engineInfoOutcome = m_pythonBindings->GetEngineInfo();
|
||||
if (!engineInfoOutcome)
|
||||
{
|
||||
if (interactive)
|
||||
{
|
||||
QMessageBox::critical(nullptr,
|
||||
QObject::tr("Failed to get engine info"),
|
||||
QObject::tr("A valid engine.json could not be found or loaded. "
|
||||
"Please verify a valid engine.json file exists in %1")
|
||||
.arg(GetEngineRoot()));
|
||||
}
|
||||
|
||||
AZ_Error("Project Manager", false, "Failed to get engine info");
|
||||
return false;
|
||||
}
|
||||
|
||||
EngineInfo engineInfo = engineInfoOutcome.GetValue();
|
||||
if (engineInfo.m_registered)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool forceRegistration = false;
|
||||
|
||||
// check if an engine with this name is already registered
|
||||
auto existingEngineResult = m_pythonBindings->GetEngineInfo(engineInfo.m_name);
|
||||
if (existingEngineResult)
|
||||
{
|
||||
if (!interactive)
|
||||
{
|
||||
AZ_Error("Project Manager", false, "An engine with the name %s is already registered with the path %s",
|
||||
engineInfo.m_name.toUtf8().constData(), engineInfo.m_path.toUtf8().constData());
|
||||
return false;
|
||||
}
|
||||
|
||||
// get the updated engine name unless the user wants to cancel
|
||||
bool okPressed = false;
|
||||
const EngineInfo& otherEngineInfo = existingEngineResult.GetValue();
|
||||
|
||||
engineInfo.m_name = QInputDialog::getText(nullptr,
|
||||
QObject::tr("Engine '%1' already registered").arg(engineInfo.m_name),
|
||||
QObject::tr("An engine named '%1' is already registered.<br /><br />"
|
||||
"<b>Current path</b><br />%2<br/><br />"
|
||||
"<b>New path</b><br />%3<br /><br />"
|
||||
"Press 'OK' to force registration, or provide a new engine name below.<br />"
|
||||
"Alternatively, press `Cancel` to close the Project Manager and resolve the issue manually.")
|
||||
.arg(engineInfo.m_name, otherEngineInfo.m_path, engineInfo.m_path),
|
||||
QLineEdit::Normal,
|
||||
engineInfo.m_name,
|
||||
&okPressed);
|
||||
|
||||
if (!okPressed)
|
||||
{
|
||||
// user elected not to change the name or force registration
|
||||
return false;
|
||||
}
|
||||
|
||||
forceRegistration = true;
|
||||
}
|
||||
|
||||
auto registerOutcome = m_pythonBindings->SetEngineInfo(engineInfo, forceRegistration);
|
||||
if (!registerOutcome)
|
||||
{
|
||||
if (interactive)
|
||||
{
|
||||
ProjectUtils::DisplayDetailedError(QObject::tr("Failed to register engine"), registerOutcome);
|
||||
}
|
||||
|
||||
AZ_Error("Project Manager", false, "Failed to register engine %s : %s",
|
||||
engineInfo.m_path.toUtf8().constData(), registerOutcome.GetError().first.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Application::TearDown()
|
||||
{
|
||||
if (m_entity)
|
||||
|
||||
Reference in New Issue
Block a user