Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add setSettingName and setSettingDescription methods to Mod #1246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions loader/include/Geode/loader/Mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions loader/include/Geode/loader/SettingV3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
12 changes: 12 additions & 0 deletions loader/src/loader/Mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions loader/src/loader/SettingV3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down