Mercurial > hg > openttd
changeset 19928:fb5e0e5c0df3 draft
(svn r24862) -Add: Settings type filter to adv. settings GUI.
author | frosch <frosch@openttd.org> |
---|---|
date | Wed, 26 Dec 2012 17:47:02 +0000 |
parents | 9a4e5c5449b0 |
children | 06d32770bfb1 |
files | src/lang/english.txt src/script/api/game/game_window.hpp.sq src/script/api/script_window.hpp src/settings_gui.cpp src/settings_internal.h src/widgets/settings_widget.h |
diffstat | 6 files changed, 52 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1063,6 +1063,14 @@ 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
--- a/src/script/api/game/game_window.hpp.sq +++ b/src/script/api/game/game_window.hpp.sq @@ -988,6 +988,7 @@ 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");
--- a/src/script/api/script_window.hpp +++ b/src/script/api/script_window.hpp @@ -2089,6 +2089,7 @@ 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. */
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -734,6 +734,7 @@ 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 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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),
--- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -83,6 +83,8 @@ 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
--- a/src/widgets/settings_widget.h +++ b/src/widgets/settings_widget.h @@ -47,6 +47,7 @@ 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. */