mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-15 14:34:50 -04:00
(feat) add way for mod devs to programatically update setting names and descriptions
This commit is contained in:
parent
cdb78f6c48
commit
22add14a9f
4 changed files with 40 additions and 0 deletions
loader
|
@ -293,6 +293,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
|
||||
|
|
|
@ -150,6 +150,14 @@ namespace geode {
|
|||
* Get the description of this setting
|
||||
*/
|
||||
std::optional<std::string> 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
|
||||
*/
|
||||
|
|
|
@ -163,6 +163,18 @@ std::shared_ptr<Setting> 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);
|
||||
}
|
||||
|
|
|
@ -585,6 +585,12 @@ std::string SettingV3::getDisplayName() const {
|
|||
std::optional<std::string> 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<std::string> SettingV3::getEnableIf() const {
|
||||
return m_impl->enableIf;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue