diff options
-rw-r--r-- | source/core/StarJson.cpp | 6 | ||||
-rw-r--r-- | source/core/StarJson.hpp | 2 | ||||
-rw-r--r-- | source/frontend/StarModsMenu.cpp | 2 | ||||
-rw-r--r-- | source/game/StarRoot.cpp | 2 |
4 files changed, 10 insertions, 2 deletions
diff --git a/source/core/StarJson.cpp b/source/core/StarJson.cpp index 7cf1cda..15b7092 100644 --- a/source/core/StarJson.cpp +++ b/source/core/StarJson.cpp @@ -868,6 +868,12 @@ String Json::printJson(int pretty, bool sort) const { return repr(pretty, sort); } +String Json::printString() const { + if (type() == Type::String) + return *m_data.get<StringConstPtr>(); + return repr(); +} + std::ostream& operator<<(std::ostream& os, Json const& v) { outputUtf8Json(v, std::ostream_iterator<char>(os), 0, false); return os; diff --git a/source/core/StarJson.hpp b/source/core/StarJson.hpp index b58b9a0..fb4c229 100644 --- a/source/core/StarJson.hpp +++ b/source/core/StarJson.hpp @@ -253,6 +253,8 @@ public: String repr(int pretty = 0, bool sort = false) const; // Prints JSON object or array only (only top level types allowed by JSON) String printJson(int pretty = 0, bool sort = false) const; + // Same but avoids quotation marks if this is a string + String printString() const; // operator== and operator!= compare for exact equality with all types, and // additionally equality with numeric conversion with Int <-> Float diff --git a/source/frontend/StarModsMenu.cpp b/source/frontend/StarModsMenu.cpp index 039a94a..f74d5e7 100644 --- a/source/frontend/StarModsMenu.cpp +++ b/source/frontend/StarModsMenu.cpp @@ -68,7 +68,7 @@ void ModsMenu::update(float dt) { m_modName->setText(bestModName(assetsSourceMetadata, assetsSource)); m_modAuthor->setText(assetsSourceMetadata.value("author", "No Author Set").toString()); - m_modVersion->setText(assetsSourceMetadata.value("version", "No Version Set").toString()); + m_modVersion->setText(assetsSourceMetadata.value("version", "No Version Set").printString()); m_modPath->setText(assetsSource); m_modDescription->setText(assetsSourceMetadata.value("description", "").toString()); diff --git a/source/game/StarRoot.cpp b/source/game/StarRoot.cpp index bda228c..fbf818f 100644 --- a/source/game/StarRoot.cpp +++ b/source/game/StarRoot.cpp @@ -613,7 +613,7 @@ StringList Root::scanForAssetSources(StringList const& directories, StringList c auto assetSource = make_shared<AssetSource>(); assetSource->path = sourcePath; assetSource->name = metadata.maybe("name").apply(mem_fn(&Json::toString)); - assetSource->version = metadata.maybe("version").apply(mem_fn(&Json::toString)); + assetSource->version = metadata.maybe("version").apply(mem_fn(&Json::printString)); assetSource->priority = metadata.value("priority", 0.0f).toFloat(); assetSource->requires_ = jsonToStringList(metadata.value("requires", JsonArray{})); assetSource->includes = jsonToStringList(metadata.value("includes", JsonArray{})); |