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
 
@@ -1094,7 +1094,7 @@ struct BuildVehicleWindow : Window {
 
						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;
 
			}
src/genworld_gui.cpp
Show inline comments
 
@@ -415,7 +415,7 @@ struct GenerateLandscapeWindow : public 
 
			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:
 
@@ -433,7 +433,7 @@ struct GenerateLandscapeWindow : public 
 
			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
 
@@ -709,7 +709,7 @@ struct CreateScenarioWindow : public Win
 
			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:
 
@@ -727,7 +727,7 @@ struct CreateScenarioWindow : public Win
 
			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;
 
		}
 
	}
src/group_gui.cpp
Show inline comments
 
@@ -530,7 +530,7 @@ public:
 
				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;
 

	
 

	
src/industry_gui.cpp
Show inline comments
 
@@ -605,7 +605,7 @@ public:
 
						/* 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;
src/main_gui.cpp
Show inline comments
 
@@ -122,7 +122,7 @@ void ShowNetworkGiveMoneyWindow(PlayerID
 
{
 
	_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 */
 

	
src/misc_gui.cpp
Show inline comments
 
@@ -1154,30 +1154,29 @@ static const WindowDesc _query_string_de
 
/** 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);
 
}
 

	
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -503,9 +503,9 @@ public:
 
				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
 
@@ -834,7 +834,7 @@ struct NetworkStartServerWindow : public
 
			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
 
@@ -877,19 +877,19 @@ struct NetworkStartServerWindow : public
 
			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
 
@@ -1660,7 +1660,7 @@ void ShowNetworkNeedPassword(NetworkPass
 
		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
src/newgrf_gui.cpp
Show inline comments
 
@@ -466,7 +466,7 @@ struct NewGRFWindow : public Window {
 

	
 
			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:
 
@@ -575,7 +575,7 @@ struct NewGRFWindow : public Window {
 
				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;
 
			}
 

	
src/order_gui.cpp
Show inline comments
 
@@ -874,7 +874,7 @@ public:
 
				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:
src/player_gui.cpp
Show inline comments
 
@@ -916,7 +916,7 @@ public:
 
			/* '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 */
 
@@ -1257,13 +1257,13 @@ struct PlayerCompanyWindow : Window
 
			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: {
src/settings_gui.cpp
Show inline comments
 
@@ -927,7 +927,7 @@ struct PatchesSelectionWindow : Window {
 

	
 
						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;
 
@@ -1165,7 +1165,7 @@ struct CustomCurrencyWindow : Window {
 

	
 
		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;
src/station_gui.cpp
Show inline comments
 
@@ -912,7 +912,7 @@ struct StationViewWindow : public Window
 

	
 
			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
src/textbuf_gui.h
Show inline comments
 
@@ -8,6 +8,7 @@
 
#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
 
@@ -28,9 +29,18 @@ bool MoveTextBufferPos(Textbuf *tb, int 
 
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. */
src/timetable_gui.cpp
Show inline comments
 
@@ -231,7 +231,7 @@ struct TimetableWindow : Window {
 
					}
 
				}
 

	
 
				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. */
src/town_gui.cpp
Show inline comments
 
@@ -370,7 +370,7 @@ public:
 

	
 
			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 */
src/vehicle_gui.cpp
Show inline comments
 
@@ -1470,7 +1470,7 @@ struct VehicleDetailsWindow : Window {
 
			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
src/waypoint_gui.cpp
Show inline comments
 
@@ -74,7 +74,7 @@ public:
 

	
 
			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*/
0 comments (0 inline, 0 general)