Changeset - r19906:1257c5c4bfd5
[Not reviewed]
master
0 6 0
frosch - 12 years ago 2012-12-26 17:47:02
frosch@openttd.org
(svn r24862) -Add: Settings type filter to adv. settings GUI.
6 files changed with 52 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1063,6 +1063,14 @@ STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAI
 
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
src/script/api/game/game_window.hpp.sq
Show inline comments
 
@@ -988,6 +988,7 @@ void SQGSWindow_Register(Squirrel *engin
 
	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");
src/script/api/script_window.hpp
Show inline comments
 
@@ -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. */
src/settings_gui.cpp
Show inline comments
 
@@ -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(Set
 
	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(Set
 

	
 
				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_setting
 
		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),
src/settings_internal.h
Show inline comments
 
@@ -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
src/widgets/settings_widget.h
Show inline comments
 
@@ -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. */
0 comments (0 inline, 0 general)