From 2f2f136685fe2a13dcaf099e1413cbb5b9dc1116 Mon Sep 17 00:00:00 2001 From: Micah Acinapura Date: Tue, 12 May 2020 16:55:35 -0400 Subject: [PATCH] fix template and writer for scene license info --- data/web/documentation/scenelicense.hbs | 14 ++++++-------- src/scene/scenelicensewriter.cpp | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/data/web/documentation/scenelicense.hbs b/data/web/documentation/scenelicense.hbs index 0399a74564..ee9bce0479 100644 --- a/data/web/documentation/scenelicense.hbs +++ b/data/web/documentation/scenelicense.hbs @@ -3,14 +3,12 @@

- - {{module}} - -

{{name}}

-
-

{{attribution}}

-

{{url}}

-

{{licenseText}}

+

Asset - {{name}}

+

{{description}}

+

Version - {{version}}

+

Author - {{author}}

+

Associated URL - {{url}}

+

Filepath - {{path}}

diff --git a/src/scene/scenelicensewriter.cpp b/src/scene/scenelicensewriter.cpp index b954008889..bd2e2ff8ec 100644 --- a/src/scene/scenelicensewriter.cpp +++ b/src/scene/scenelicensewriter.cpp @@ -51,6 +51,16 @@ std::string SceneLicenseWriter::generateJson() const { std::vector assets = global::openSpaceEngine.assetManager().rootAsset().subTreeAssets(); + int metaTotal = 0; + for (const Asset* asset : assets) { + std::optional meta = asset->metaInformation(); + if (!meta.has_value()) { + continue; + } + metaTotal++; + } + + int metaCount = 0; for (const Asset* asset : assets) { std::optional meta = asset->metaInformation(); @@ -69,10 +79,12 @@ std::string SceneLicenseWriter::generateJson() const { json << fmt::format(replStr, "author", escapedJson(meta->author)); json << fmt::format(replStr, "url", escapedJson(meta->url)); //json << fmt::format(replStr2, "licenseText", escapedJson(license.licenseText)); - json << fmt::format(replStr2, "license", escapedJson(meta->license)); + json << fmt::format(replStr, "license", escapedJson(meta->license)); + json << fmt::format(replStr2, "path", escapedJson(asset->assetFilePath())); json << "}"; - if (&asset != &(assets.back())) { + metaCount++; + if (metaCount != metaTotal) { json << ","; } }