diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp index cff9a28db3..7004fe24d4 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp @@ -363,7 +363,7 @@ namespace O3DE::ProjectManager const QString selectedGemPath = m_gemModel->GetPath(modelIndex); // Unregister the gem - auto unregisterResult = PythonBindingsInterface::Get()->RegisterGem(selectedGemPath, {}, /*remove*/true); + auto unregisterResult = PythonBindingsInterface::Get()->UnregisterGem(selectedGemPath); if (!unregisterResult) { QMessageBox::critical(this, tr("Failed to unregister gem"), unregisterResult.GetError().c_str()); @@ -419,10 +419,8 @@ namespace O3DE::ProjectManager { // Add all available gems to the model. const QVector& allGemInfos = allGemInfosResult.GetValue(); - for (GemInfo gemInfo : allGemInfos) + for (const GemInfo& gemInfo : allGemInfos) { - // Mark as downloaded because this gem was registered with an existing directory - gemInfo.m_downloadStatus = GemInfo::DownloadStatus::Downloaded; m_gemModel->AddGem(gemInfo); } diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp index 3e68c597de..82d205aab5 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp @@ -41,12 +41,12 @@ namespace O3DE::ProjectManager "Updating this Gem will remove any local changes made to this Gem, " "and may remove old features that are in use.").arg( updateAvaliable ? "" : tr("No update detected for Gem. " - "This will force a redownload of the gem anyways. "))); + "This will force a re-download of the gem. "))); bodyLabel->setWordWrap(true); bodyLabel->setFixedSize(QSize(440, 80)); layout->addWidget(bodyLabel); - layout->addSpacing(); + layout->addSpacing(40); // Buttons QDialogButtonBox* dialogButtons = new QDialogButtonBox(); diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index ef7daa761e..e0208a266c 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -515,7 +515,11 @@ namespace O3DE::ProjectManager auto pyProjectPath = QString_To_Py_Path(projectPath); for (auto path : m_manifest.attr("get_all_gems")(pyProjectPath)) { - gems.push_back(GemInfoFromPath(path, pyProjectPath)); + GemInfo gemInfo = GemInfoFromPath(path, pyProjectPath); + // Mark as downloaded because this gem was registered with an existing directory + gemInfo.m_downloadStatus = GemInfo::DownloadStatus::Downloaded; + + gems.push_back(AZStd::move(gemInfo)); } }); if (!result.IsSuccess()) @@ -560,7 +564,7 @@ namespace O3DE::ProjectManager return AZ::Success(AZStd::move(gemNames)); } - AZ::Outcome PythonBindings::RegisterGem(const QString& gemPath, const QString& projectPath, bool remove) + AZ::Outcome PythonBindings::GemRegistration(const QString& gemPath, const QString& projectPath, bool remove) { bool registrationResult = false; auto result = ExecuteWithLockErrorHandling( @@ -596,12 +600,23 @@ namespace O3DE::ProjectManager } else if (!registrationResult) { - return AZ::Failure(AZStd::string::format("Failed to register gem path %s", gemPath.toUtf8().constData())); + return AZ::Failure(AZStd::string::format( + "Failed to %s gem path %s", remove ? "unregister" : "register", gemPath.toUtf8().constData())); } return AZ::Success(); } + AZ::Outcome PythonBindings::RegisterGem(const QString& gemPath, const QString& projectPath) + { + return GemRegistration(gemPath, projectPath); + } + + AZ::Outcome PythonBindings::UnregisterGem(const QString& gemPath, const QString& projectPath) + { + return GemRegistration(gemPath, projectPath, /*remove*/true); + } + bool PythonBindings::AddProject(const QString& path) { bool registrationResult = false; diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.h b/Code/Tools/ProjectManager/Source/PythonBindings.h index 8a22344596..d258898fae 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.h +++ b/Code/Tools/ProjectManager/Source/PythonBindings.h @@ -42,7 +42,8 @@ namespace O3DE::ProjectManager AZ::Outcome, AZStd::string> GetEngineGemInfos() override; AZ::Outcome, AZStd::string> GetAllGemInfos(const QString& projectPath) override; AZ::Outcome, AZStd::string> GetEnabledGemNames(const QString& projectPath) override; - AZ::Outcome RegisterGem(const QString& gemPath, const QString& projectPath = {}, bool remove = false) override; + AZ::Outcome RegisterGem(const QString& gemPath, const QString& projectPath = {}) override; + AZ::Outcome UnregisterGem(const QString& gemPath, const QString& projectPath = {}) override; // Project AZ::Outcome CreateProject(const QString& projectTemplatePath, const ProjectInfo& projectInfo) override; @@ -78,6 +79,7 @@ namespace O3DE::ProjectManager GemRepoInfo GetGemRepoInfo(pybind11::handle repoUri); ProjectInfo ProjectInfoFromPath(pybind11::handle path); ProjectTemplateInfo ProjectTemplateInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath); + AZ::Outcome GemRegistration(const QString& gemPath, const QString& projectPath, bool remove = false); bool RegisterThisEngine(); bool StopPython(); diff --git a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h index 07d4551c60..6c8b0c89a6 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h +++ b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h @@ -95,10 +95,17 @@ namespace O3DE::ProjectManager * Registers the gem to the specified project, or to the o3de_manifest.json if no project path is given * @param gemPath the path to the gem * @param projectPath the path to the project. If empty, will register the external path in o3de_manifest.json - * @param remove Unregister instead of registering this gem * @return An outcome with the success flag as well as an error message in case of a failure. */ - virtual AZ::Outcome RegisterGem(const QString& gemPath, const QString& projectPath = {}, bool remove = false) = 0; + virtual AZ::Outcome RegisterGem(const QString& gemPath, const QString& projectPath = {}) = 0; + + /** + * Unregisters the gem from the specified project, or from the o3de_manifest.json if no project path is given + * @param gemPath the path to the gem + * @param projectPath the path to the project. If empty, will unregister the external path in o3de_manifest.json + * @return An outcome with the success flag as well as an error message in case of a failure. + */ + virtual AZ::Outcome UnregisterGem(const QString& gemPath, const QString& projectPath = {}) = 0; // Projects