diff --git a/loader/include/Geode/loader/Mod.hpp b/loader/include/Geode/loader/Mod.hpp index 2a6d72bd3..6ea8f2c21 100644 --- a/loader/include/Geode/loader/Mod.hpp +++ b/loader/include/Geode/loader/Mod.hpp @@ -297,6 +297,20 @@ namespace geode { saved[key] = value; return old; } + + /** + * Set the name of setting. + * @param key Setting key + * @param name New name + */ + void setSettingName(std::string_view key, std::string_view name); + + /** + * Set the description of a setting. + * @param key Setting key + * @param desc New description + */ + void setSettingDescription(std::string_view key, std::string_view description); /** * Get the Mod of the current mod being developed diff --git a/loader/include/Geode/loader/SettingV3.hpp b/loader/include/Geode/loader/SettingV3.hpp index dd232a0aa..311bfc449 100644 --- a/loader/include/Geode/loader/SettingV3.hpp +++ b/loader/include/Geode/loader/SettingV3.hpp @@ -150,6 +150,14 @@ namespace geode { * Get the description of this setting */ std::optional getDescription() const; + /** + * Set the display name of this setting + */ + void setDisplayName(std::string_view name); + /** + * Set the description of this setting + */ + void setDescription(std::string_view desc); /** * Get the "enable-if" scheme for this setting */ diff --git a/loader/src/loader/Mod.cpp b/loader/src/loader/Mod.cpp index 560069e86..2c61f52c1 100644 --- a/loader/src/loader/Mod.cpp +++ b/loader/src/loader/Mod.cpp @@ -167,6 +167,18 @@ std::shared_ptr Mod::getSetting(std::string_view key) const { return m_impl->m_settings->get(std::string(key)); } +void Mod::setSettingName(std::string_view key, std::string_view name) { + if (auto setting = getSetting(key)) { + setting->setDisplayName(name); + } +} + +void Mod::setSettingDescription(std::string_view key, std::string_view desc) { + if (auto setting = getSetting(key)) { + setting->setDescription(desc); + } +} + Result<> Mod::registerCustomSettingType(std::string_view type, SettingGenerator generator) { return m_impl->m_settings->registerCustomSettingType(type, generator); } diff --git a/loader/src/loader/SettingV3.cpp b/loader/src/loader/SettingV3.cpp index 9296723e4..537f6fa51 100644 --- a/loader/src/loader/SettingV3.cpp +++ b/loader/src/loader/SettingV3.cpp @@ -585,6 +585,12 @@ std::string SettingV3::getDisplayName() const { std::optional SettingV3::getDescription() const { return m_impl->description; } +void SettingV3::setDisplayName(std::string_view name) { + m_impl->name = name; +} +void SettingV3::setDescription(std::string_view description) { + m_impl->description = description; +} std::optional SettingV3::getEnableIf() const { return m_impl->enableIf; }