From accd473ff5cd03a9e003dee4476c7c2581f4f125 Mon Sep 17 00:00:00 2001 From: mgwynn Date: Fri, 4 Jun 2021 20:19:38 -0400 Subject: [PATCH] Adding python bindings for modifying project properties --- .../ProjectManager/Source/PythonBindings.cpp | 18 ++++++++++++++++++ .../ProjectManager/Source/PythonBindings.h | 6 ++++++ .../Source/PythonBindingsInterface.h | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index 37e636caef..0acbf8ffaf 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -289,6 +289,7 @@ namespace O3DE::ProjectManager m_engineTemplate = pybind11::module::import("o3de.engine_template"); m_enableGemProject = pybind11::module::import("o3de.enable_gem"); m_disableGemProject = pybind11::module::import("o3de.disable_gem"); + m_editProjectProperties = pybind11::module::import("o3de.project_properties"); // make sure the engine is registered RegisterThisEngine(); @@ -686,6 +687,23 @@ namespace O3DE::ProjectManager return projectInfo; } + AZ::Outcome PythonBindings::ModifyProjectProperties(const QString& path, const QString& origin, const QString& displayName, + const QString& summary, const QString& icon, const QString& addTag, const QString& removeTag) + { + return ExecuteWithLockErrorHandling([&] + { + m_editProjectProperties.attr("edit_project_props")( + pybind11::str(path.toStdString()), //proj_path + pybind11::none(), //proj_name not used + origin.isNull() ? pybind11::none() : pybind11::str(origin.toStdString()), //new_origin + displayName.isNull() ? pybind11::none() : pybind11::str(displayName.toStdString()), //new_display + summary.isNull() ? pybind11::none() : pybind11::str(summary.toStdString()), //new_summary + icon.isNull() ? pybind11::none() : pybind11::str(icon.toStdString()), //new_icon + addTag.isNull() ? pybind11::none() : pybind11::str(addTag.toStdString()), //new_tag + removeTag.isNull() ? pybind11::none() : pybind11::str(removeTag.toStdString())); //remove_tag + }); + } + AZ::Outcome> PythonBindings::GetProjects() { QVector projects; diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.h b/Code/Tools/ProjectManager/Source/PythonBindings.h index 278aa2d5d7..5f03d0ab28 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.h +++ b/Code/Tools/ProjectManager/Source/PythonBindings.h @@ -53,6 +53,11 @@ namespace O3DE::ProjectManager bool UpdateProject(const ProjectInfo& projectInfo) override; AZ::Outcome AddGemToProject(const QString& gemPath, const QString& projectPath) override; AZ::Outcome RemoveGemFromProject(const QString& gemPath, const QString& projectPath) override; + AZ::Outcome ModifyProjectProperties( + const QString& path, + const QString& origin = 0, + const QString& displayName = 0, + const QString& summary = 0, const QString& icon = 0, const QString& addTag = 0, const QString& removeTag = 0) override; // ProjectTemplate AZ::Outcome> GetProjectTemplates() override; @@ -78,5 +83,6 @@ namespace O3DE::ProjectManager pybind11::handle m_manifest; pybind11::handle m_enableGemProject; pybind11::handle m_disableGemProject; + pybind11::handle m_editProjectProperties; }; } diff --git a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h index 09d9187dbd..edc9510236 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h +++ b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h @@ -132,6 +132,25 @@ namespace O3DE::ProjectManager */ virtual AZ::Outcome AddGemToProject(const QString& gemPath, const QString& projectPath) = 0; + /** + * Change property in project json file + * @param path the absolute path to the gem + * @param origin the description or url for project origin (such as project host, repository, owner...etc) + * @param displayName the project display name + * @param summary short description of the project + * @param icon image used to represent the project + * @param addTag user tag to be added + * @param removeTag user tag to be removed + */ + virtual AZ::Outcome ModifyProjectProperties( + const QString& path, + const QString& origin = 0, + const QString& displayName = 0, + const QString& summary = 0, + const QString& icon = 0, + const QString& addTag = 0, + const QString& removeTag = 0) = 0; + /** * Remove gem to a project * @param gemPath the absolute path to the gem