Changeset - r19393:fb056f72c99f
[Not reviewed]
master
0 6 0
frosch - 12 years ago 2012-06-01 14:41:09
frosch@openttd.org
(svn r24310) -Codechange: Add named constants for the dimensions of settings buttons, and generally make their usage more consistent.
6 files changed with 38 insertions and 35 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -346,27 +346,27 @@ struct AISettingsWindow : public Window 
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != WID_AIS_BACKGROUND) return;
 

	
 
		ScriptConfig *config = this->ai_config;
 
		VisibleSettingsList::const_iterator it = this->visible_settings.begin();
 
		int i = 0;
 
		for (; !this->vscroll->IsVisible(i); i++) it++;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint buttons_left = rtl ? r.right - 23 : r.left + 4;
 
		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : 28);
 
		uint text_right   = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT);
 
		uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
 
		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
 
		uint text_right   = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
 

	
 

	
 
		int y = r.top;
 
		for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
 
			const ScriptConfigItem &config_item = **it;
 
			int current_value = config->GetSetting((config_item).name);
 
			bool editable = _game_mode == GM_MENU || ((this->slot != OWNER_DEITY) && !Company::IsValidID(this->slot)) || (config_item.flags & SCRIPTCONFIG_INGAME) != 0;
 

	
 
			StringID str;
 
			TextColour colour;
 
			uint idx = 0;
 
			if (StrEmpty(config_item.description)) {
 
@@ -428,30 +428,30 @@ struct AISettingsWindow : public Window 
 

	
 
				VisibleSettingsList::const_iterator it = this->visible_settings.begin();
 
				for (int i = 0; i < num; i++) it++;
 
				const ScriptConfigItem config_item = **it;
 
				if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return;
 

	
 
				bool bool_item = (config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0;
 

	
 
				int x = pt.x - wid->pos_x;
 
				if (_current_text_dir == TD_RTL) x = wid->current_x - x;
 
				x -= 4;
 
				/* One of the arrows is clicked (or green/red rect in case of bool value) */
 
				if (IsInsideMM(x, 0, 21)) {
 
				if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
 
					int new_val = this->ai_config->GetSetting(config_item.name);
 
					int old_val = new_val;
 
					if (bool_item) {
 
						new_val = !new_val;
 
					} else if (x >= 10) {
 
					} else if (x >= SETTING_BUTTON_WIDTH / 2) {
 
						/* Increase button clicked */
 
						new_val += config_item.step_size;
 
						if (new_val > config_item.max_value) new_val = config_item.max_value;
 
						this->clicked_increase = true;
 
					} else {
 
						/* Decrease button clicked */
 
						new_val -= config_item.step_size;
 
						if (new_val < config_item.min_value) new_val = config_item.min_value;
 
						this->clicked_increase = false;
 
					}
 

	
 
					if (new_val != old_val) {
src/cheat_gui.cpp
Show inline comments
 
@@ -175,27 +175,27 @@ struct CheatWindow : Window {
 
		this->InitNested(desc);
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != WID_C_PANEL) return;
 

	
 
		int y = r.top + WD_FRAMERECT_TOP + this->header_height;
 
		DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, y, STR_CHEATS_WARNING, TC_FROMSTRING, SA_CENTER);
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint box_left    = rtl ? r.right - 12 : r.left + 5;
 
		uint button_left = rtl ? r.right - 40 : r.left + 20;
 
		uint text_left   = r.left + (rtl ? WD_FRAMERECT_LEFT: 50);
 
		uint text_right  = r.right - (rtl ? 50 : WD_FRAMERECT_RIGHT);
 
		uint button_left = rtl ? r.right - 20 - SETTING_BUTTON_WIDTH : r.left + 20;
 
		uint text_left   = r.left + (rtl ? WD_FRAMERECT_LEFT : 30 + SETTING_BUTTON_WIDTH);
 
		uint text_right  = r.right - (rtl ? 30 + SETTING_BUTTON_WIDTH : WD_FRAMERECT_RIGHT);
 

	
 
		for (int i = 0; i != lengthof(_cheats_ui); i++) {
 
			const CheatEntry *ce = &_cheats_ui[i];
 

	
 
			DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, box_left, y + 2);
 

	
 
			switch (ce->type) {
 
				case SLE_BOOL: {
 
					bool on = (*(bool*)ce->variable);
 

	
 
					DrawBoolButton(button_left, y, on, true);
 
					SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
 
@@ -282,48 +282,48 @@ struct CheatWindow : Window {
 
		const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_C_PANEL);
 
		uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / (FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL);
 
		uint x = pt.x - wid->pos_x;
 
		bool rtl = _current_text_dir == TD_RTL;
 
		if (rtl) x = wid->current_x - x;
 

	
 
		if (btn >= lengthof(_cheats_ui)) return;
 

	
 
		const CheatEntry *ce = &_cheats_ui[btn];
 
		int value = (int32)ReadValue(ce->variable, ce->type);
 
		int oldvalue = value;
 

	
 
		if (btn == CHT_CHANGE_DATE && x >= 40) {
 
		if (btn == CHT_CHANGE_DATE && x >= 20 + SETTING_BUTTON_WIDTH) {
 
			/* Click at the date text directly. */
 
			SetDParam(0, value);
 
			ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
 
			return;
 
		}
 

	
 
		/* Not clicking a button? */
 
		if (!IsInsideMM(x, 20, 40)) return;
 
		if (!IsInsideMM(x, 20, 20 + SETTING_BUTTON_WIDTH)) return;
 

	
 
		*ce->been_used = true;
 

	
 
		switch (ce->type) {
 
			case SLE_BOOL:
 
				value ^= 1;
 
				if (ce->proc != NULL) ce->proc(value, 0);
 
				break;
 

	
 
			default:
 
				/* Take whatever the function returns */
 
				value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1);
 
				value = ce->proc(value + ((x >= 20 + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 20 + SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
 

	
 
				/* The first cheat (money), doesn't return a different value. */
 
				if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 30) != rtl ? 1 : 0);
 
				if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 20 + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
 
				break;
 
		}
 

	
 
		if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
 

	
 
		this->SetTimeout();
 

	
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
src/industry_gui.cpp
Show inline comments
 
@@ -740,40 +740,40 @@ public:
 
			if (first) {
 
				if (has_accept) y += WD_PAR_VSEP_WIDE;
 
				DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
 
				y += FONT_HEIGHT_NORMAL;
 
				if (this->editable == EA_RATE) this->production_offset_y = y;
 
				first = false;
 
			}
 

	
 
			SetDParam(0, i->produced_cargo[j]);
 
			SetDParam(1, i->last_month_production[j]);
 
			SetDParamStr(2, cargo_suffix[j]);
 
			SetDParam(3, ToPercent8(i->last_month_pct_transported[j]));
 
			uint x = left + WD_FRAMETEXT_LEFT + (this->editable == EA_RATE ? 30 : 0);
 
			uint x = left + WD_FRAMETEXT_LEFT + (this->editable == EA_RATE ? SETTING_BUTTON_WIDTH + 10 : 0);
 
			DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_TRANSPORTED);
 
			/* Let's put out those buttons.. */
 
			if (this->editable == EA_RATE) {
 
				DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == IL_RATE1 + j) ? this->clicked_button : 0,
 
						i->production_rate[j] > 0, i->production_rate[j] < 255);
 
			}
 
			y += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		/* Display production multiplier if editable */
 
		if (this->editable == EA_MULTIPLIER) {
 
			y += WD_PAR_VSEP_WIDE;
 
			this->production_offset_y = y;
 
			SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT));
 
			uint x = left + WD_FRAMETEXT_LEFT + 30;
 
			uint x = left + WD_FRAMETEXT_LEFT + SETTING_BUTTON_WIDTH + 10;
 
			DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LEVEL);
 
			DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == IL_MULTIPLIER) ? this->clicked_button : 0,
 
					i->prod_level > PRODLEVEL_MINIMUM, i->prod_level < PRODLEVEL_MAXIMUM);
 
			y += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		/* Get the extra message for the GUI */
 
		if (HasBit(ind->callback_mask, CBM_IND_WINDOW_MORE_TEXT)) {
 
			uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->location.tile);
 
			if (callback_res != CALLBACK_FAILED && callback_res != 0x400) {
 
				if (callback_res > 0x400) {
 
					ErrorUnknownCallbackResult(ind->grf_prop.grffile->grfid, CBID_INDUSTRY_WINDOW_MORE_TEXT, callback_res);
 
@@ -829,27 +829,27 @@ public:
 
									line = (InfoLine)(IL_RATE1 + j);
 
									break;
 
								}
 
							}
 
						}
 
						break;
 
				}
 
				if (line == IL_NONE) return;
 

	
 
				NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
 
				int left = nwi->pos_x + WD_FRAMETEXT_LEFT;
 
				int right = nwi->pos_x + nwi->current_x - 1 - WD_FRAMERECT_RIGHT;
 
				if (IsInsideMM(pt.x, left, left + 20)) {
 
				if (IsInsideMM(pt.x, left, left + SETTING_BUTTON_WIDTH)) {
 
					/* Clicked buttons, decrease or increase production */
 
					byte button = (pt.x < left + 10) ? 1 : 2;
 
					byte button = (pt.x < left + SETTING_BUTTON_WIDTH / 2) ? 1 : 2;
 
					switch (this->editable) {
 
						case EA_MULTIPLIER:
 
							if (button == 1) {
 
								if (i->prod_level <= PRODLEVEL_MINIMUM) return;
 
								i->prod_level = max<uint>(i->prod_level / 2, PRODLEVEL_MINIMUM);
 
							} else {
 
								if (i->prod_level >= PRODLEVEL_MAXIMUM) return;
 
								i->prod_level = minu(i->prod_level * 2, PRODLEVEL_MAXIMUM);
 
							}
 
							break;
 

	
 
						case EA_RATE:
 
@@ -863,25 +863,25 @@ public:
 
								i->production_rate[line - IL_RATE1] = minu(new_prod, 255);
 
							}
 
							break;
 

	
 
						default: NOT_REACHED();
 
					}
 

	
 
					UpdateIndustryProduction(i);
 
					this->SetDirty();
 
					this->SetTimeout();
 
					this->clicked_line = line;
 
					this->clicked_button = button;
 
				} else if (IsInsideMM(pt.x, left + 30, right)) {
 
				} else if (IsInsideMM(pt.x, left + SETTING_BUTTON_WIDTH + 10, right)) {
 
					/* clicked the text */
 
					this->editbox_line = line;
 
					switch (this->editable) {
 
						case EA_MULTIPLIER:
 
							SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT));
 
							ShowQueryString(STR_JUST_INT, STR_CONFIG_GAME_PRODUCTION_LEVEL, 10, this, CS_ALPHANUMERAL, QSF_NONE);
 
							break;
 

	
 
						case EA_RATE:
 
							SetDParam(0, i->production_rate[line - IL_RATE1] * 8);
 
							ShowQueryString(STR_JUST_INT, STR_CONFIG_GAME_PRODUCTION, 10, this, CS_ALPHANUMERAL, QSF_NONE);
 
							break;
src/newgrf_gui.cpp
Show inline comments
 
@@ -238,27 +238,27 @@ struct NewGRFParametersWindow : public W
 
		if (widget == WID_NP_DESCRIPTION) {
 
			const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL;
 
			if (par_info == NULL) return;
 
			const char *desc = GetGRFStringFromGRFText(par_info->desc);
 
			if (desc == NULL) return;
 
			DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_TEXTPANEL_TOP, r.bottom - WD_TEXTPANEL_BOTTOM, desc, TC_BLACK);
 
			return;
 
		} else if (widget != WID_NP_BACKGROUND) {
 
			return;
 
		}
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint buttons_left = rtl ? r.right - 23 : r.left + 4;
 
		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : 28);
 
		uint text_right   = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT);
 
		uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
 
		uint text_left    = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
 
		uint text_right   = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
 

	
 
		int y = r.top;
 
		for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
 
			GRFParameterInfo *par_info = (i < this->grf_config->param_info.Length()) ? this->grf_config->param_info[i] : NULL;
 
			if (par_info == NULL) par_info = GetDummyParameterInfo(i);
 
			uint32 current_value = par_info->GetValue(this->grf_config);
 
			bool selected = (i == this->clicked_row);
 

	
 
			if (par_info->type == PTYPE_BOOL) {
 
				DrawBoolButton(buttons_left, y + 2, current_value != 0, this->editable);
 
				SetDParam(2, par_info->GetValue(this->grf_config) == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
 
			} else if (par_info->type == PTYPE_UINT_ENUM) {
 
@@ -318,31 +318,31 @@ struct NewGRFParametersWindow : public W
 
					this->clicked_row = num;
 
				}
 

	
 
				const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_NP_BACKGROUND);
 
				int x = pt.x - wid->pos_x;
 
				if (_current_text_dir == TD_RTL) x = wid->current_x - x;
 
				x -= 4;
 

	
 
				GRFParameterInfo *par_info = (num < this->grf_config->param_info.Length()) ? this->grf_config->param_info[num] : NULL;
 
				if (par_info == NULL) par_info = GetDummyParameterInfo(num);
 

	
 
				/* One of the arrows is clicked */
 
				if (IsInsideMM(x, 0, 21)) {
 
				if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
 
					uint32 val = par_info->GetValue(this->grf_config);
 
					uint32 old_val = val;
 
					if (par_info->type == PTYPE_BOOL) {
 
						val = !val;
 
					} else {
 
						if (x >= 10) {
 
						if (x >= SETTING_BUTTON_WIDTH / 2) {
 
							/* Increase button clicked */
 
							if (val < par_info->max_value) val++;
 
							this->clicked_increase = true;
 
						} else {
 
							/* Decrease button clicked */
 
							if (val > par_info->min_value) val--;
 
							this->clicked_increase = false;
 
						}
 
					}
 
					if (val != old_val) {
 
						par_info->SetValue(this->grf_config, val);
 

	
src/settings_gui.cpp
Show inline comments
 
@@ -1309,28 +1309,28 @@ void SettingEntry::SetValueDParams(uint 
 
 * @param y            Upper-most position in window/panel to start drawing
 
 * @param state        State of the left + right arrow buttons to draw for the setting
 
 * @param highlight    Highlight entry.
 
 */
 
void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, int state, bool highlight)
 
{
 
	const SettingDesc *sd = this->d.entry.setting;
 
	const SettingDescBase *sdb = &sd->desc;
 
	const void *var = ResolveVariableAddress(settings_ptr, sd);
 
	bool editable = true;
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	uint buttons_left = rtl ? right - 19 : left;
 
	uint text_left  = left + (rtl ? 0 : 25);
 
	uint text_right = right - (rtl ? 25 : 0);
 
	uint button_y = y + (SETTING_HEIGHT - 11) / 2;
 
	uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
 
	uint text_left  = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + 5);
 
	uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + 5 : 0);
 
	uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
 

	
 
	/* We do not allow changes of some items when we are a client in a networkgame */
 
	if (!(sd->save.conv & SLF_NO_NETWORK_SYNC) && _networking && !_network_server && !(sdb->flags & SGF_PER_COMPANY)) editable = false;
 
	if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
 
	if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
 

	
 
	SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
 
	int32 value = (int32)ReadValue(var, sd->save.conv);
 
	if (sdb->cmd == SDT_BOOLX) {
 
		/* Draw checkbox for boolean-value either on/off */
 
		DrawBoolButton(buttons_left, button_y, value != 0, editable);
 
	} else {
 
@@ -1813,68 +1813,68 @@ struct GameSettingsWindow : Window {
 

	
 
		/* return if action is only active in network, or only settable by server */
 
		if ((!(sd->save.conv & SLF_NO_NETWORK_SYNC) && _networking && !_network_server && !(sd->desc.flags & SGF_PER_COMPANY)) ||
 
				((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) || ((sd->desc.flags & SGF_NO_NETWORK) && _networking)) {
 
			this->SetDisplayedHelpText(pe);
 
			return;
 
		}
 

	
 
		const void *var = ResolveVariableAddress(settings_ptr, sd);
 
		int32 value = (int32)ReadValue(var, sd->save.conv);
 

	
 
		/* clicked on the icon on the left side. Either scroller or bool on/off */
 
		if (x < 21) {
 
		if (x < SETTING_BUTTON_WIDTH) {
 
			this->SetDisplayedHelpText(pe);
 
			const SettingDescBase *sdb = &sd->desc;
 
			int32 oldvalue = value;
 

	
 
			switch (sdb->cmd) {
 
				case SDT_BOOLX: value ^= 1; break;
 
				case SDT_ONEOFMANY:
 
				case SDT_NUMX: {
 
					/* Add a dynamic step-size to the scroller. In a maximum of
 
					 * 50-steps you should be able to get from min to max,
 
					 * unless specified otherwise in the 'interval' variable
 
					 * of the current setting. */
 
					uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
 
					if (step == 0) step = 1;
 

	
 
					/* don't allow too fast scrolling */
 
					if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
 
						_left_button_clicked = false;
 
						return;
 
					}
 

	
 
					/* Increase or decrease the value and clamp it to extremes */
 
					if (x >= 10) {
 
					if (x >= SETTING_BUTTON_WIDTH / 2) {
 
						value += step;
 
						if (sdb->min < 0) {
 
							assert((int32)sdb->max >= 0);
 
							if (value > (int32)sdb->max) value = (int32)sdb->max;
 
						} else {
 
							if ((uint32)value > sdb->max) value = (int32)sdb->max;
 
						}
 
						if (value < sdb->min) value = sdb->min; // skip between "disabled" and minimum
 
					} else {
 
						value -= step;
 
						if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
 
					}
 

	
 
					/* Set up scroller timeout for numeric values */
 
					if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
 
						if (this->clicked_entry != NULL) { // Release previous buttons if any
 
							this->clicked_entry->SetButtons(0);
 
						}
 
						this->clicked_entry = pe;
 
						this->clicked_entry->SetButtons((x >= 10) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
 
						this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
 
						this->SetTimeout();
 
						_left_button_clicked = false;
 
					}
 
					break;
 
				}
 

	
 
				default: NOT_REACHED();
 
			}
 

	
 
			if (value != oldvalue) {
 
				if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
 
					SetCompanySetting(pe->d.entry.index, value);
 
@@ -1981,50 +1981,50 @@ void ShowGameSettings()
 
 * Draw [<][>] boxes.
 
 * @param x the x position to draw
 
 * @param y the y position to draw
 
 * @param button_colour the colour of the button
 
 * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
 
 * @param clickable_left is the left button clickable?
 
 * @param clickable_right is the right button clickable?
 
 */
 
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
 
{
 
	int colour = _colour_gradient[button_colour][2];
 

	
 
	DrawFrameRect(x,      y + 1, x +  9, y + 9, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
 
	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
 
	DrawFrameRect(x,                            y, x + SETTING_BUTTON_WIDTH / 2 - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
 
	DrawFrameRect(x + SETTING_BUTTON_WIDTH / 2, y, x + SETTING_BUTTON_WIDTH     - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
 
	DrawSprite(SPR_ARROW_LEFT, PAL_NONE, x + WD_IMGBTN_LEFT, y + WD_IMGBTN_TOP);
 
	DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + 10, y + WD_IMGBTN_TOP);
 
	DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + SETTING_BUTTON_WIDTH / 2, y + WD_IMGBTN_TOP);
 

	
 
	/* Grey out the buttons that aren't clickable */
 
	bool rtl = _current_text_dir == TD_RTL;
 
	if (rtl ? !clickable_right : !clickable_left) {
 
		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, colour, FILLRECT_CHECKER);
 
		GfxFillRect(x                            + 1, y, x + SETTING_BUTTON_WIDTH / 2 - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
 
	}
 
	if (rtl ? !clickable_left : !clickable_right) {
 
		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, colour, FILLRECT_CHECKER);
 
		GfxFillRect(x + SETTING_BUTTON_WIDTH / 2 + 1, y, x + SETTING_BUTTON_WIDTH     - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
 
	}
 
}
 

	
 
/**
 
 * Draw a toggle button.
 
 * @param x the x position to draw
 
 * @param y the y position to draw
 
 * @param state true = lowered
 
 * @param clickable is the button clickable?
 
 */
 
void DrawBoolButton(int x, int y, bool state, bool clickable)
 
{
 
	static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
 
	DrawFrameRect(x, y + 1, x + 19, y + 9, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
 
	DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
 
}
 

	
 
struct CustomCurrencyWindow : Window {
 
	int query_widget;
 

	
 
	CustomCurrencyWindow(const WindowDesc *desc) : Window()
 
	{
 
		this->InitNested(desc);
 

	
 
		SetButtonState();
 
	}
 

	
src/settings_gui.h
Show inline comments
 
@@ -5,17 +5,20 @@
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file settings_gui.h Functions for setting GUIs. */
 

	
 
#ifndef SETTING_GUI_H
 
#define SETTING_GUI_H
 

	
 
#include "gfx_type.h"
 

	
 
static const int SETTING_BUTTON_WIDTH  = 20; ///< Width of setting buttons
 
static const int SETTING_BUTTON_HEIGHT = 10; ///< Height of setting buttons
 

	
 
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right);
 
void DrawBoolButton(int x, int y, bool state, bool clickable);
 

	
 
#endif /* SETTING_GUI_H */
 

	
0 comments (0 inline, 0 general)