summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lang/english.txt8
-rw-r--r--src/script/api/game/game_window.hpp.sq1
-rw-r--r--src/script/api/script_window.hpp1
-rw-r--r--src/settings_gui.cpp41
-rw-r--r--src/settings_internal.h2
-rw-r--r--src/widgets/settings_widget.h1
6 files changed, 52 insertions, 2 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 420dc4510..894474706 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1063,6 +1063,14 @@ STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT :Settings with a
STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT_WO_LOCAL :Non-client settings with a different value than the default
STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW :Settings with a different value than your new-game settings
+STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT :{BLACK}Restricts the list below to certain setting types
+STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL :All settings
+STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT :Client settings (not stored in saves; affects all games)
+STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU :Game settings (stored in saves; affects only new games)
+STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME :Game settings (stored in save; affects only current game)
+STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU :Company settings (stored in saves; affects only new games)
+STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME :Company settings (stored in save; affects only current company)
+
STR_CONFIG_SETTING_OFF :Off
STR_CONFIG_SETTING_ON :On
STR_CONFIG_SETTING_DISABLED :Disabled
diff --git a/src/script/api/game/game_window.hpp.sq b/src/script/api/game/game_window.hpp.sq
index 4702f672d..51a281553 100644
--- a/src/script/api/game/game_window.hpp.sq
+++ b/src/script/api/game/game_window.hpp.sq
@@ -988,6 +988,7 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GS_COLLAPSE_ALL, "WID_GS_COLLAPSE_ALL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GS_RESTRICT_LABEL, "WID_GS_RESTRICT_LABEL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GS_RESTRICT_DROPDOWN, "WID_GS_RESTRICT_DROPDOWN");
+ SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GS_TYPE_DROPDOWN, "WID_GS_TYPE_DROPDOWN");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CC_RATE_DOWN, "WID_CC_RATE_DOWN");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CC_RATE_UP, "WID_CC_RATE_UP");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_CC_RATE, "WID_CC_RATE");
diff --git a/src/script/api/script_window.hpp b/src/script/api/script_window.hpp
index 679e43add..e3f8740ba 100644
--- a/src/script/api/script_window.hpp
+++ b/src/script/api/script_window.hpp
@@ -2089,6 +2089,7 @@ public:
WID_GS_COLLAPSE_ALL = ::WID_GS_COLLAPSE_ALL, ///< Collapse all button.
WID_GS_RESTRICT_LABEL = ::WID_GS_RESTRICT_LABEL, ///< Label upfront to drop down box to restrict the list of settings to show
WID_GS_RESTRICT_DROPDOWN = ::WID_GS_RESTRICT_DROPDOWN, ///< The drop down box to restrict the list of settings
+ WID_GS_TYPE_DROPDOWN = ::WID_GS_TYPE_DROPDOWN, ///< The drop down box to choose client/game/company/all settings
};
/** Widgets of the #CustomCurrencyWindow class. */
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 930dc31da..0c3ecbccd 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -734,6 +734,7 @@ enum RestrictionMode {
struct SettingFilter {
StringFilter string; ///< Filter string.
RestrictionMode mode; ///< Filter based on category.
+ SettingType type; ///< Filter based on type.
};
/** Data structure describing a single setting in a tab */
@@ -1077,11 +1078,11 @@ bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
bool visible = true;
switch (this->flags & SEF_KIND_MASK) {
case SEF_SETTING_KIND: {
+ const SettingDesc *sd = this->d.entry.setting;
if (!force_visible && !filter.string.IsEmpty()) {
/* Process the search text filter for this item. */
filter.string.ResetState();
- const SettingDesc *sd = this->d.entry.setting;
const SettingDescBase *sdb = &sd->desc;
SetDParam(0, STR_EMPTY);
@@ -1090,6 +1091,7 @@ bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
visible = filter.string.GetState();
}
+ if (filter.type != ST_ALL) visible = visible && sd->GetType() == filter.type;
visible = visible && this->IsVisibleByRestrictionMode(filter.mode);
break;
}
@@ -1749,6 +1751,7 @@ struct GameSettingsWindow : Window {
static bool first_time = true;
filter.mode = (RestrictionMode)_settings_client.gui.settings_restriction_mode;
+ filter.type = ST_ALL;
settings_ptr = &GetGameSettings();
/* Build up the dynamic settings-array only once per OpenTTD session */
@@ -1824,6 +1827,15 @@ struct GameSettingsWindow : Window {
case WID_GS_RESTRICT_DROPDOWN:
SetDParam(0, _game_settings_restrict_dropdown[this->filter.mode]);
break;
+
+ case WID_GS_TYPE_DROPDOWN:
+ switch (this->filter.type) {
+ case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break;
+ case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break;
+ case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT); break;
+ default: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break;
+ }
+ break;
}
}
@@ -1842,6 +1854,14 @@ struct GameSettingsWindow : Window {
list->push_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
}
break;
+
+ case WID_GS_TYPE_DROPDOWN:
+ list = new DropDownList();
+ list->push_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
+ list->push_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false));
+ list->push_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false));
+ list->push_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
+ break;
}
return list;
}
@@ -1912,6 +1932,15 @@ struct GameSettingsWindow : Window {
if (list != NULL) {
ShowDropDownList(this, list, this->filter.mode, widget);
}
+ break;
+ }
+
+ case WID_GS_TYPE_DROPDOWN: {
+ DropDownList *list = this->BuildDropDownList(widget);
+ if (list != NULL) {
+ ShowDropDownList(this, list, this->filter.type, widget);
+ }
+ break;
}
}
@@ -2120,6 +2149,11 @@ struct GameSettingsWindow : Window {
this->InvalidateData();
break;
+ case WID_GS_TYPE_DROPDOWN:
+ this->filter.type = (SettingType)index;
+ this->InvalidateData();
+ break;
+
default:
if (widget < 0) {
/* Deal with drop down boxes on the panel. */
@@ -2207,7 +2241,10 @@ static const NWidgetPart _nested_settings_selection_widgets[] = {
NWidget(NWID_HORIZONTAL), SetPadding(WD_TEXTPANEL_TOP, 0, WD_TEXTPANEL_BOTTOM, 0),
SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_LABEL), SetDataTip(STR_CONFIG_SETTING_RESTRICT_LABEL, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_RESTRICT_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
+ NWidget(NWID_VERTICAL), SetPIP(0, WD_PAR_VSEP_NORMAL, 0),
+ NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_RESTRICT_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
+ NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_TYPE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
+ EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL), SetPadding(0, 0, WD_TEXTPANEL_BOTTOM, 0),
SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
diff --git a/src/settings_internal.h b/src/settings_internal.h
index a6953e36d..851496c96 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -83,6 +83,8 @@ enum SettingType {
ST_GAME, ///< Game setting.
ST_COMPANY, ///< Company setting.
ST_CLIENT, ///< Client setting.
+
+ ST_ALL, ///< Used in setting filter to match all types.
};
typedef bool OnChange(int32 var); ///< callback prototype on data modification
diff --git a/src/widgets/settings_widget.h b/src/widgets/settings_widget.h
index ad9c4067c..baebdace5 100644
--- a/src/widgets/settings_widget.h
+++ b/src/widgets/settings_widget.h
@@ -47,6 +47,7 @@ enum GameSettingsWidgets {
WID_GS_COLLAPSE_ALL, ///< Collapse all button.
WID_GS_RESTRICT_LABEL, ///< Label upfront to drop down box to restrict the list of settings to show
WID_GS_RESTRICT_DROPDOWN, ///< The drop down box to restrict the list of settings
+ WID_GS_TYPE_DROPDOWN, ///< The drop down box to choose client/game/company/all settings
};
/** Widgets of the #CustomCurrencyWindow class. */