Changeset - r10145:99ade42f8be3
[Not reviewed]
master
0 17 0
smatz - 16 years ago 2008-09-15 16:29:40
smatz@openttd.org
(svn r14331) -Codechange: use an enum as additional parameter for ShowQueryString()
17 files changed with 49 insertions and 40 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1085,25 +1085,25 @@ struct BuildVehicleWindow : Window {
 
				if (sel_eng != INVALID_ENGINE) {
 
					StringID str = STR_NULL;
 

	
 
					this->rename_engine = sel_eng;
 
					switch (this->vehicle_type) {
 
						default: NOT_REACHED();
 
						case VEH_TRAIN:    str = STR_886A_RENAME_TRAIN_VEHICLE_TYPE; break;
 
						case VEH_ROAD:     str = STR_9036_RENAME_ROAD_VEHICLE_TYPE;  break;
 
						case VEH_SHIP:     str = STR_9838_RENAME_SHIP_TYPE;          break;
 
						case VEH_AIRCRAFT: str = STR_A039_RENAME_AIRCRAFT_TYPE;      break;
 
					}
 
					SetDParam(0, sel_eng);
 
					ShowQueryString(STR_ENGINE_NAME, str, MAX_LENGTH_ENGINE_NAME_BYTES, MAX_LENGTH_ENGINE_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
					ShowQueryString(STR_ENGINE_NAME, str, MAX_LENGTH_ENGINE_NAME_BYTES, MAX_LENGTH_ENGINE_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		this->regenerate_list = true;
 
	}
 

	
 
	virtual void OnPaint()
src/genworld_gui.cpp
Show inline comments
 
@@ -406,43 +406,43 @@ struct GenerateLandscapeWindow : public 
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case GLAND_START_DATE_TEXT: // Year text
 
				this->widget_id = GLAND_START_DATE_TEXT;
 
				SetDParam(0, _settings_newgame.game_creation.starting_year);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case GLAND_SNOW_LEVEL_DOWN:
 
			case GLAND_SNOW_LEVEL_UP: // Snow line buttons
 
				/* Don't allow too fast scrolling */
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case GLAND_SNOW_LEVEL_TEXT: // Snow line text
 
				this->widget_id = GLAND_SNOW_LEVEL_TEXT;
 
				SetDParam(0, _settings_newgame.game_creation.snow_line_height);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case GLAND_TREE_PULLDOWN: // Tree placer
 
				ShowDropDownMenu(this, _tree_placer, _settings_newgame.game_creation.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
 
				break;
 

	
 
			case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation
 
			/* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/
 
				if (mode == GLWP_HEIGHTMAP) {
 
					ShowDropDownMenu(this, _rotation, _settings_newgame.game_creation.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
 
				} else {
 
					ShowDropDownMenu(this, _landscape, _settings_newgame.game_creation.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
 
@@ -700,43 +700,43 @@ struct CreateScenarioWindow : public Win
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case CSCEN_START_DATE_TEXT: // Year text
 
				this->widget_id = CSCEN_START_DATE_TEXT;
 
				SetDParam(0, _settings_newgame.game_creation.starting_year);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case CSCEN_FLAT_LAND_HEIGHT_DOWN:
 
			case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
 
				/* Don't allow too fast scrolling */
 
				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_settings_newgame.game_creation.se_flat_world_height = Clamp(_settings_newgame.game_creation.se_flat_world_height + widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case CSCEN_FLAT_LAND_HEIGHT_TEXT: // Height level text
 
				this->widget_id = CSCEN_FLAT_LAND_HEIGHT_TEXT;
 
				SetDParam(0, _settings_newgame.game_creation.se_flat_world_height);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, this, CS_NUMERAL, QSF_NONE);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		switch (widget) {
 
			case CSCEN_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
 
			case CSCEN_MAPSIZE_Y_PULLDOWN: _settings_newgame.game_creation.map_y = index; break;
 
		}
 
		this->SetDirty();
 
	}
src/group_gui.cpp
Show inline comments
 
@@ -521,25 +521,25 @@ public:
 
				this->group_sel = ALL_GROUP;
 

	
 
				DoCommandP(0, group, 0, NULL, CMD_DELETE_GROUP | CMD_MSG(STR_GROUP_CAN_T_DELETE));
 
				break;
 
			}
 

	
 
			case GRP_WIDGET_RENAME_GROUP: { // Rename the selected roup
 
				assert(IsValidGroupID(this->group_sel));
 

	
 
				const Group *g = GetGroup(this->group_sel);
 

	
 
				SetDParam(0, g->index);
 
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_BYTES, MAX_LENGTH_GROUP_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_BYTES, MAX_LENGTH_GROUP_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
			} break;
 

	
 

	
 
			case GRP_WIDGET_AVAILABLE_VEHICLES:
 
				ShowBuildVehicleWindow(0, this->vehicle_type);
 
				break;
 

	
 
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
 
				ShowGroupActionDropdown(this, this->group_sel);
 
				break;
 

	
 
			case GRP_WIDGET_START_ALL:
src/industry_gui.cpp
Show inline comments
 
@@ -596,25 +596,25 @@ public:
 
							i->production_rate[line] = minu(new_prod, 255);
 
						}
 

	
 
						UpdateIndustryProduction(i);
 
						this->SetDirty();
 
						this->flags4 |= 5 << WF_TIMEOUT_SHL;
 
						this->clicked_line = line + 1;
 
						this->clicked_button = (x < 15 ? 1 : 2);
 
					} else if (IsInsideMM(x, 34, 160)) {
 
						/* clicked the text */
 
						this->editbox_line = line;
 
						SetDParam(0, i->production_rate[line] * 8);
 
						ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, this, CS_ALPHANUMERAL);
 
						ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, this, CS_ALPHANUMERAL, QSF_NONE);
 
					}
 
				}
 
			} break;
 

	
 
			case IVW_GOTO:
 
				i = GetIndustry(this->window_number);
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(i->xy + TileDiffXY(1, 1));
 
				} else {
 
					ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1));
 
				}
 
				break;
src/main_gui.cpp
Show inline comments
 
@@ -113,25 +113,25 @@ bool HandlePlacePushButton(Window *w, in
 

	
 

	
 
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
 
}
 

	
 
#ifdef ENABLE_NETWORK
 
void ShowNetworkGiveMoneyWindow(PlayerID player)
 
{
 
	_rename_id = player;
 
	_rename_what = 3;
 
	ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL);
 
	ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL, QSF_NONE);
 
}
 
#endif /* ENABLE_NETWORK */
 

	
 

	
 
/* Zooms a viewport in a window in or out */
 
/* No button handling or what so ever */
 
bool DoZoomInOutWindow(int how, Window *w)
 
{
 
	ViewPort *vp;
 

	
 
	assert(w != NULL);
 
	vp = w->viewport;
src/misc_gui.cpp
Show inline comments
 
@@ -1145,48 +1145,47 @@ static const Widget _query_string_widget
 
};
 

	
 
static const WindowDesc _query_string_desc = {
 
	190, 219, 260, 42, 260, 42,
 
	WC_QUERY_STRING, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	_query_string_widgets,
 
};
 

	
 
/** Show a query popup window with a textbox in it.
 
 * @param str StringID for the text shown in the textbox
 
 * @param caption StringID of text shown in caption of querywindow
 
 * @param maxlen maximum length in characters allowed. If bit 12 is set we
 
 *               will not check the resulting string against to original string to return success
 
 * @param maxlen maximum length in characters allowed
 
 * @param maxwidth maximum width in pixels allowed
 
 * @param parent pointer to a Window that will handle the events (ok/cancel) of this
 
 *        window. If NULL, results are handled by global function HandleOnEditText
 
 * @param afilter filters out unwanted character input */
 
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter)
 
 * @param afilter filters out unwanted character input
 
 * @param flags various flags, @see QueryStringFlags
 
 */
 
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
 
{
 
	uint realmaxlen = maxlen & ~0x1000;
 

	
 
	DeleteWindowById(WC_QUERY_STRING, 0);
 
	DeleteWindowById(WC_SAVELOAD, 0);
 

	
 
	QueryStringWindow *w = new QueryStringWindow(realmaxlen + 1, &_query_string_desc, parent);
 
	QueryStringWindow *w = new QueryStringWindow(maxlen + 1, &_query_string_desc, parent);
 

	
 
	GetString(w->edit_str_buf, str, &w->edit_str_buf[realmaxlen]);
 
	w->edit_str_buf[realmaxlen] = '\0';
 
	GetString(w->edit_str_buf, str, &w->edit_str_buf[maxlen]);
 
	w->edit_str_buf[maxlen] = '\0';
 

	
 
	if (!(maxlen & 0x1000)) w->orig = strdup(w->edit_str_buf);
 
	if ((flags & QSF_ACCEPT_UNCHANGED) == 0) w->orig = strdup(w->edit_str_buf);
 

	
 
	w->LowerWidget(QUERY_STR_WIDGET_TEXT);
 
	w->caption = caption;
 
	w->afilter = afilter;
 
	InitializeTextBuffer(&w->text, w->edit_str_buf, realmaxlen, maxwidth);
 
	InitializeTextBuffer(&w->text, w->edit_str_buf, maxlen, maxwidth);
 
}
 

	
 

	
 
enum QueryWidgets {
 
	QUERY_WIDGET_CAPTION = 1,
 
	QUERY_WIDGET_NO = 3,
 
	QUERY_WIDGET_YES
 
};
 

	
 
/**
 
 * Window used for asking the user a YES/NO question.
 
 */
src/network/network_gui.cpp
Show inline comments
 
@@ -494,27 +494,27 @@ public:
 
			case NGWW_FIND: // Find server automatically
 
				switch (_settings_client.network.lan_internet) {
 
					case 0: NetworkUDPSearchGame(); break;
 
					case 1: NetworkUDPQueryMasterServer(); break;
 
				}
 
				break;
 

	
 
			case NGWW_ADD: // Add a server
 
				SetDParamStr(0, _settings_client.network.connect_to_ip);
 
				ShowQueryString(
 
					STR_JUST_RAW_STRING,
 
					STR_NETWORK_ENTER_IP,
 
					31 | 0x1000,  // maximum number of characters OR
 
					31,  // maximum number of characters
 
					250, // characters up to this width pixels, whichever is satisfied first
 
					this, CS_ALPHANUMERAL);
 
					this, CS_ALPHANUMERAL, QSF_ACCEPT_UNCHANGED);
 
				break;
 

	
 
			case NGWW_START: // Start server
 
				ShowNetworkStartServerWindow();
 
				break;
 

	
 
			case NGWW_JOIN: // Join Game
 
				if (this->server != NULL) {
 
					snprintf(_settings_client.network.last_host, sizeof(_settings_client.network.last_host), "%s", inet_ntoa(*(struct in_addr *)&this->server->ip));
 
					_settings_client.network.last_port = this->server->port;
 
					ShowNetworkLobbyWindow(this->server);
 
				}
 
@@ -825,25 +825,25 @@ struct NetworkStartServerWindow : public
 
			case NSSW_CLOSE:  // Close 'X'
 
			case NSSW_CANCEL: // Cancel button
 
				ShowNetworkGameWindow();
 
				break;
 

	
 
			case NSSW_GAMENAME:
 
				ShowOnScreenKeyboard(this, NSSW_GAMENAME, 0, 0);
 
				break;
 

	
 
			case NSSW_SETPWD: // Set password button
 
				this->widget_id = NSSW_SETPWD;
 
				SetDParamStr(0, _settings_client.network.server_password);
 
				ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_SET_PASSWORD, 20, 250, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_SET_PASSWORD, 20, 250, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_SELMAP: { // Select map
 
				int y = (pt.y - NSSWND_START) / NSSWND_ROWSIZE;
 

	
 
				y += this->vscroll.pos;
 
				if (y >= this->vscroll.count) return;
 

	
 
				this->map = (y == 0) ? NULL : _fios_items.Get(y - 1);
 
				this->SetDirty();
 
			} break;
 

	
 
@@ -868,37 +868,37 @@ struct NetworkStartServerWindow : public
 
							break;
 
						case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU:
 
							_settings_client.network.max_spectators = Clamp(_settings_client.network.max_spectators + widget - NSSW_SPECTATORS_TXT, 0, MAX_CLIENTS);
 
							break;
 
					}
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case NSSW_CLIENTS_TXT:    // Click on number of players
 
				this->widget_id = NSSW_CLIENTS_TXT;
 
				SetDParam(0, _settings_client.network.max_clients);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS,    3, 50, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS,    3, 50, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_COMPANIES_TXT:  // Click on number of companies
 
				this->widget_id = NSSW_COMPANIES_TXT;
 
				SetDParam(0, _settings_client.network.max_companies);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_COMPANIES,  3, 50, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_COMPANIES,  3, 50, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_SPECTATORS_TXT: // Click on number of spectators
 
				this->widget_id = NSSW_SPECTATORS_TXT;
 
				SetDParam(0, _settings_client.network.max_spectators);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_SPECTATORS, 3, 50, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_SPECTATORS, 3, 50, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_LANGUAGE_BTN: { // Language
 
				uint sel = 0;
 
				for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) {
 
					if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _settings_client.network.server_lang) {
 
						sel = i;
 
						break;
 
					}
 
				}
 
				ShowDropDownMenu(this, _language_dropdown, sel, NSSW_LANGUAGE_BTN, 0, 0);
 
			} break;
 
@@ -1651,25 +1651,25 @@ static NetworkPasswordType pw_type;
 

	
 

	
 
void ShowNetworkNeedPassword(NetworkPasswordType npt)
 
{
 
	StringID caption;
 

	
 
	pw_type = npt;
 
	switch (npt) {
 
		default: NOT_REACHED();
 
		case NETWORK_GAME_PASSWORD:    caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break;
 
		case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break;
 
	}
 
	ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL);
 
	ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL, QSF_NONE);
 
}
 

	
 
// Vars needed for the join-GUI
 
NetworkJoinStatus _network_join_status;
 
uint8 _network_join_waiting;
 
uint16 _network_join_kbytes;
 
uint16 _network_join_kbytes_total;
 

	
 
struct NetworkJoinStatusWindow : Window {
 
	NetworkJoinStatusWindow(const WindowDesc *desc) : Window(desc)
 
	{
 
		this->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
src/newgrf_gui.cpp
Show inline comments
 
@@ -457,25 +457,25 @@ struct NewGRFWindow : public Window {
 
				for (uint i = 0; i < _grf_preset_list.Length(); i++) {
 
					if (_grf_preset_list[i] != NULL) {
 
						list->push_back(new DropDownListPresetItem(i));
 
					}
 
				}
 

	
 
				ShowDropDownList(this, list, this->preset, SNGRFS_PRESET_LIST);
 
				break;
 
			}
 

	
 
			case SNGRFS_PRESET_SAVE:
 
				this->query_widget = widget;
 
				ShowQueryString(STR_EMPTY, STR_NEWGRF_PRESET_SAVE_QUERY, 32, 100, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_EMPTY, STR_NEWGRF_PRESET_SAVE_QUERY, 32, 100, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case SNGRFS_PRESET_DELETE:
 
				if (this->preset == -1) return;
 

	
 
				DeleteGRFPresetFromConfig(_grf_preset_list[this->preset]);
 
				GetGRFPresetList(&_grf_preset_list);
 
				this->preset = -1;
 
				this->SetDirty();
 
				break;
 

	
 
			case SNGRFS_ADD: // Add GRF
 
@@ -566,25 +566,25 @@ struct NewGRFWindow : public Window {
 
					ResetGRFConfig(false);
 
					ReloadNewGRFData();
 
				}
 
				break;
 

	
 
			case SNGRFS_SET_PARAMETERS: { // Edit parameters
 
				if (this->sel == NULL) break;
 

	
 
				this->query_widget = widget;
 
				static char buff[512];
 
				GRFBuildParamList(buff, this->sel, lastof(buff));
 
				SetDParamStr(0, buff);
 
				ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_JUST_RAW_STRING, STR_NEWGRF_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 
			}
 

	
 
			case SNGRFS_TOGGLE_PALETTE: {
 
				if (this->sel != NULL) {
 
					this->sel->windows_paletted ^= true;
 
					this->SetDirty();
 
				}
 
				break;
 
			}
 
		}
 
	}
src/order_gui.cpp
Show inline comments
 
@@ -865,25 +865,25 @@ public:
 
				break;
 

	
 
			case ORDER_WIDGET_COND_COMPARATOR: {
 
				const Order *o = GetVehicleOrder(this->vehicle, this->OrderGetSel());
 
				ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), ORDER_WIDGET_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
 
			} break;
 

	
 
			case ORDER_WIDGET_COND_VALUE: {
 
				const Order *order = GetVehicleOrder(this->vehicle, this->OrderGetSel());
 
				uint value = order->GetConditionValue();
 
				if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
 
				SetDParam(0, value);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, 100, this, CS_NUMERAL);
 
				ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, 100, this, CS_NUMERAL, QSF_NONE);
 
			} break;
 

	
 
			case ORDER_WIDGET_SHARED_ORDER_LIST:
 
				ShowVehicleListWindow(this->vehicle);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (!StrEmpty(str)) {
 
			VehicleOrderID sel = this->OrderGetSel();
src/player_gui.cpp
Show inline comments
 
@@ -907,25 +907,25 @@ public:
 
			/* Load button */
 
			case PFW_WIDGET_LOAD:
 
				this->face = _player_face;
 
				ScaleAllPlayerFaceBits(this->face);
 
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
 
				this->UpdateData();
 
				this->SetDirty();
 
				break;
 

	
 
			/* 'Player face number' button, view and/or set player face number */
 
			case PFW_WIDGET_FACECODE:
 
				SetDParam(0, this->face);
 
				ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL);
 
				ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, 0, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			/* Save button */
 
			case PFW_WIDGET_SAVE:
 
				_player_face = this->face;
 
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_SAVE_DONE, 0, 0);
 
				break;
 

	
 
			/* Toggle gender (male/female) button */
 
			case PFW_WIDGET_MALE:
 
			case PFW_WIDGET_FEMALE:
 
				SetPlayerFaceBits(this->face, PFV_GENDER, this->ge, widget - PFW_WIDGET_MALE);
 
@@ -1248,31 +1248,31 @@ struct PlayerCompanyWindow : Window
 
	{
 
		switch (widget) {
 
			case PCW_WIDGET_NEW_FACE: DoSelectPlayerFace(this, false); break;
 

	
 
			case PCW_WIDGET_COLOR_SCHEME:
 
				if (BringWindowToFrontById(WC_PLAYER_COLOR, this->window_number)) break;
 
				new SelectPlayerLiveryWindow(&_select_player_livery_desc, (PlayerID)this->window_number);
 
				break;
 

	
 
			case PCW_WIDGET_PRESIDENT_NAME:
 
				this->query_widget = PCW_WIDGET_PRESIDENT_NAME;
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case PCW_WIDGET_COMPANY_NAME:
 
				this->query_widget = PCW_WIDGET_COMPANY_NAME;
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case PCW_WIDGET_BUILD_VIEW_HQ: {
 
				TileIndex tile = GetPlayer((PlayerID)this->window_number)->location_of_HQ;
 
				if (tile == 0) {
 
					if ((byte)this->window_number != _local_player) return;
 
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, this);
 
					SetTileSelectSize(2, 2);
 
					this->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
 
					this->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
 
				} else {
 
					if (_ctrl_pressed) {
src/settings_gui.cpp
Show inline comments
 
@@ -918,25 +918,25 @@ struct PatchesSelectionWindow : Window {
 
					if (value != oldvalue) {
 
						SetPatchValue(page->entries[btn].index, value);
 
						this->SetDirty();
 
					}
 
				} else {
 
					/* only open editbox for types that its sensible for */
 
					if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
 
						/* Show the correct currency-translated value */
 
						if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
 

	
 
						this->entry = btn;
 
						SetDParam(0, value);
 
						ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, this, CS_NUMERAL);
 
						ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, this, CS_NUMERAL, QSF_NONE);
 
					}
 
				}
 
			} break;
 

	
 
			case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES:
 
			case PATCHSEL_STATIONS:  case PATCHSEL_ECONOMY:      case PATCHSEL_COMPETITORS:
 
				this->RaiseWidget(this->page + PATCHSEL_INTERFACE);
 
				this->page = widget - PATCHSEL_INTERFACE;
 
				this->LowerWidget(this->page + PATCHSEL_INTERFACE);
 
				DeleteWindowById(WC_QUERY_STRING, 0);
 
				this->SetDirty();
 
				break;
 
@@ -1156,25 +1156,25 @@ struct CustomCurrencyWindow : Window {
 
					}
 
				} else { // enter text
 
					SetDParam(0, _custom_currency.to_euro);
 
					str = STR_CONFIG_PATCHES_INT32;
 
					len = 4;
 
					afilter = CS_NUMERAL;
 
				}
 
				break;
 
		}
 

	
 
		if (len != 0) {
 
			this->query_widget = line;
 
			ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, this, afilter);
 
			ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, this, afilter, QSF_NONE);
 
		}
 

	
 
		this->flags4 |= 5 << WF_TIMEOUT_SHL;
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (str == NULL) return;
 

	
 
		switch (this->query_widget) {
 
			case CUSTCURR_EXCHANGERATE:
src/station_gui.cpp
Show inline comments
 
@@ -903,25 +903,25 @@ struct StationViewWindow : public Window
 
				} else {
 
					/* Switch to accepts view */
 
					this->widget[SVW_RATINGS].data = STR_3032_RATINGS;
 
					this->widget[SVW_RATINGS].tooltips = STR_3054_SHOW_STATION_RATINGS;
 
					ResizeWindowForWidget(this, SVW_ACCEPTLIST, 0, -100);
 
				}
 

	
 
				this->SetDirty();
 
				break;
 

	
 
			case SVW_RENAME:
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case SVW_TRAINS: { // Show a list of scheduled trains to this station
 
				const Station *st = GetStation(this->window_number);
 
				ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)this->window_number);
 
				break;
 
			}
 

	
 
			case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
 
				const Station *st = GetStation(this->window_number);
 
				ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)this->window_number);
 
				break;
src/textbuf_gui.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file textbuf_gui.h Stuff related to the text buffer GUI. */
 

	
 
#ifndef TEXTBUF_GUI_H
 
#define TEXTBUF_GUI_H
 

	
 
#include "window_type.h"
 
#include "string_type.h"
 
#include "strings_type.h"
 
#include "core/enum_type.hpp"
 

	
 
struct Textbuf {
 
	char *buf;                  ///< buffer in which text is saved
 
	uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes
 
	uint16 length, width;       ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
 
	bool caret;                 ///< is the caret ("_") visible or not
 
	uint16 caretpos;            ///< the current position of the caret in the buffer, in bytes
 
	uint16 caretxoffs;          ///< the current position of the caret in pixels
 
};
 

	
 
bool HandleCaret(Textbuf *tb);
 

	
 
void DeleteTextBufferAll(Textbuf *tb);
 
bool DeleteTextBufferChar(Textbuf *tb, int delmode);
 
bool InsertTextBufferChar(Textbuf *tb, uint32 key);
 
bool InsertTextBufferClipboard(Textbuf *tb);
 
bool MoveTextBufferPos(Textbuf *tb, int navmode);
 
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth);
 
void UpdateTextBufferSize(Textbuf *tb);
 

	
 
/** Flags used in ShowQueryString() call */
 
enum QueryStringFlags {
 
	QSF_NONE            =    0,
 
	QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change
 
};
 

	
 
DECLARE_ENUM_AS_BIT_SET(QueryStringFlags)
 

	
 

	
 
typedef void QueryCallbackProc(Window*, bool);
 

	
 
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter);
 
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter, QueryStringFlags flags);
 
void ShowQuery(StringID caption, StringID message, Window *w, QueryCallbackProc *callback);
 

	
 
/** The number of 'characters' on the on-screen keyboard. */
 
static const uint OSK_KEYBOARD_ENTRIES = 50;
 

	
 
/**
 
 * The number of characters has to be OSK_KEYBOARD_ENTRIES. However, these
 
 * have to be UTF-8 encoded, which means up to 4 bytes per character.
 
 * Furthermore the string needs to be '\0'-terminated.
 
 */
 
extern char _keyboard_opt[2][OSK_KEYBOARD_ENTRIES * 4 + 1];
 

	
src/timetable_gui.cpp
Show inline comments
 
@@ -222,25 +222,25 @@ struct TimetableWindow : Window {
 
				StringID current = STR_EMPTY;
 

	
 
				if (order != NULL) {
 
					uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time;
 
					if (!_settings_client.gui.timetable_in_ticks) time /= DAY_TICKS;
 

	
 
					if (time != 0) {
 
						SetDParam(0, time);
 
						current = STR_CONFIG_PATCHES_INT32;
 
					}
 
				}
 

	
 
				ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, this, CS_NUMERAL);
 
				ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, this, CS_NUMERAL, QSF_NONE);
 
			} break;
 

	
 
			case TTV_CLEAR_TIME: { /* Clear waiting time button. */
 
				uint32 p1 = PackTimetableArgs(v, this->sel_index);
 
				DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 
			} break;
 

	
 
			case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */
 
				DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 
				break;
 

	
 
			case TTV_AUTOFILL: /* Autofill the timetable. */
src/town_gui.cpp
Show inline comments
 
@@ -361,25 +361,25 @@ public:
 
					ShowExtraViewPortWindow(this->town->xy);
 
				} else {
 
					ScrollMainWindowToTile(this->town->xy);
 
				}
 
				break;
 

	
 
			case TVW_SHOWAUTORITY: /* town authority */
 
				ShowTownAuthorityWindow(this->window_number);
 
				break;
 

	
 
			case TVW_CHANGENAME: /* rename */
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, MAX_LENGTH_TOWN_NAME_BYTES, MAX_LENGTH_TOWN_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, MAX_LENGTH_TOWN_NAME_BYTES, MAX_LENGTH_TOWN_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case TVW_EXPAND: /* expand town - only available on Scenario editor */
 
				ExpandTown(this->town);
 
				break;
 

	
 
			case TVW_DELETE: /* delete town - only available on Scenario editor */
 
				delete this->town;
 
				break;
 
		}
 
	}
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -1461,25 +1461,25 @@ struct VehicleDetailsWindow : Window {
 
		/** Message strings for renaming vehicles indexed by vehicle type. */
 
		static const StringID _name_vehicle_title[] = {
 
			STR_8865_NAME_TRAIN,
 
			STR_902C_NAME_ROAD_VEHICLE,
 
			STR_9831_NAME_SHIP,
 
			STR_A030_NAME_AIRCRAFT
 
		};
 

	
 
		switch (widget) {
 
			case VLD_WIDGET_RENAME_VEHICLE: {// rename
 
				const Vehicle *v = GetVehicle(this->window_number);
 
				SetDParam(0, v->index);
 
				ShowQueryString(STR_VEHICLE_NAME, _name_vehicle_title[v->type], MAX_LENGTH_VEHICLE_NAME_BYTES, MAX_LENGTH_VEHICLE_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_VEHICLE_NAME, _name_vehicle_title[v->type], MAX_LENGTH_VEHICLE_NAME_BYTES, MAX_LENGTH_VEHICLE_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
			} break;
 

	
 
			case VLD_WIDGET_INCREASE_SERVICING_INTERVAL:   // increase int
 
			case VLD_WIDGET_DECREASE_SERVICING_INTERVAL: { // decrease int
 
				int mod = _ctrl_pressed ? 5 : 10;
 
				const Vehicle *v = GetVehicle(this->window_number);
 

	
 
				mod = (widget == VLD_WIDGET_DECREASE_SERVICING_INTERVAL) ? -mod : mod;
 
				mod = GetServiceIntervalClamped(mod + v->service_interval);
 
				if (mod == v->service_interval) return;
 

	
 
				DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
src/waypoint_gui.cpp
Show inline comments
 
@@ -65,25 +65,25 @@ public:
 
	{
 
		switch (widget) {
 
			case WAYPVW_CENTERVIEW: /* scroll to location */
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(this->wp->xy);
 
				} else {
 
					ScrollMainWindowToTile(this->wp->xy);
 
				}
 
				break;
 

	
 
			case WAYPVW_RENAME: /* rename */
 
				SetDParam(0, this->wp->index);
 
				ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case WAYPVW_SHOW_TRAINS: /* show list of trains having this waypoint in their orders*/
 
				ShowVehicleListWindow(this->wp);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		int x = TileX(this->wp->xy) * TILE_SIZE;
 
		int y = TileY(this->wp->xy) * TILE_SIZE;
0 comments (0 inline, 0 general)