Settings: Add a guiproc callback for general settings GUI operations

This commit is contained in:
Jonathan G Rennison
2021-09-29 19:13:22 +01:00
parent 1820408bf6
commit 47156122fa
11 changed files with 134 additions and 102 deletions

View File

@@ -843,15 +843,7 @@ struct SettingEntry : BaseSettingEntry {
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
void SetButtons(byte new_val);
/**
* Get the help text of a single setting.
* @return The requested help text.
*/
inline StringID GetHelpText() const
{
return this->setting->desc.str_help;
}
StringID GetHelpText() const;
struct SetValueDParamsTempData {
char buffer[512];
@@ -868,6 +860,24 @@ private:
bool IsVisibleByRestrictionMode(RestrictionMode mode) const;
};
/**
* Get the help text of a single setting.
* @return The requested help text.
*/
StringID SettingEntry::GetHelpText() const
{
StringID str = this->setting->desc.str_help;
if (this->setting->desc.guiproc != nullptr) {
SettingOnGuiCtrlData data;
data.type = SOGCT_DESCRIPTION_TEXT;
data.text = str;
if (this->setting->desc.guiproc(data)) {
str = data.text;
}
}
return str;
}
/** Cargodist per-cargo setting */
struct CargoDestPerCargoSettingEntry : SettingEntry {
CargoID cargo;