implement tags key in ModMetadata

This commit is contained in:
HJfod 2024-03-24 11:05:51 +02:00
parent f40ced5bff
commit 4447153f24
3 changed files with 17 additions and 3 deletions

View file

@ -185,6 +185,10 @@ namespace geode {
* @note Not a map because insertion order must be preserved
*/
[[nodiscard]] std::vector<std::pair<std::string, Setting>> getSettings() const;
/**
* Get the tags for this mod
*/
[[nodiscard]] std::unordered_set<std::string> getTags() const;
/**
* Whether this mod has to be loaded before the loading screen or not
*/
@ -229,6 +233,7 @@ namespace geode {
void setIncompatibilities(std::vector<Incompatibility> const& value);
void setSpritesheets(std::vector<std::string> const& value);
void setSettings(std::vector<std::pair<std::string, Setting>> const& value);
void setTags(std::unordered_set<std::string> const& value);
void setNeedsEarlyLoad(bool const& value);
void setIsAPI(bool const& value);
ModMetadataLinks& getLinksMut();

View file

@ -161,9 +161,6 @@ Result<ModMetadata> ModMetadata::Impl::createFromSchemaV010(ModJson const& rawJs
return Err("[mod.json] is missing target GD version");
}
// don't think its used locally yet
root.addKnownKey("tags");
root.needs("id")
// todo: make this use validateID in full 2.0.0 release
.validate(MiniFunction<bool(std::string const&)>(&ModMetadata::Impl::validateOldID))
@ -290,6 +287,11 @@ Result<ModMetadata> ModMetadata::Impl::createFromSchemaV010(ModJson const& rawJs
// do not check unknown for future compat
}
// Tags. Actual validation is done when interacting with the server in the UI
for (auto& tag : root.has("tags").iterate()) {
impl->m_tags.insert(tag.template get<std::string>());
}
// with new cli, binary name is always mod id
impl->m_binaryName = impl->m_id + GEODE_PLATFORM_EXTENSION;
@ -531,6 +533,9 @@ std::vector<std::string> ModMetadata::getSpritesheets() const {
std::vector<std::pair<std::string, Setting>> ModMetadata::getSettings() const {
return m_impl->m_settings;
}
std::unordered_set<std::string> ModMetadata::getTags() const {
return m_impl->m_tags;
}
bool ModMetadata::needsEarlyLoad() const {
return m_impl->m_needsEarlyLoad;
}
@ -614,6 +619,9 @@ void ModMetadata::setSpritesheets(std::vector<std::string> const& value) {
void ModMetadata::setSettings(std::vector<std::pair<std::string, Setting>> const& value) {
m_impl->m_settings = value;
}
void ModMetadata::setTags(std::unordered_set<std::string> const& value) {
m_impl->m_tags = value;
}
void ModMetadata::setNeedsEarlyLoad(bool const& value) {
m_impl->m_needsEarlyLoad = value;
}

View file

@ -35,6 +35,7 @@ namespace geode {
std::vector<Incompatibility> m_incompatibilities;
std::vector<std::string> m_spritesheets;
std::vector<std::pair<std::string, Setting>> m_settings;
std::unordered_set<std::string> m_tags;
bool m_needsEarlyLoad = false;
bool m_isAPI = false;