1
0
Fork 0

Codechange: Pass raw string to editable query window. (#13481)

This avoids separating string id and parameters. EncodedString is not needed as it is the raw text that is editable.
pull/13484/head
Peter Nelson 2025-02-07 17:03:53 +00:00 committed by GitHub
parent 8c48f9fc49
commit c3643e3ee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 60 additions and 115 deletions

View File

@ -1701,8 +1701,7 @@ struct BuildVehicleWindow : Window {
EngineID sel_eng = this->sel_engine; EngineID sel_eng = this->sel_engine;
if (sel_eng != INVALID_ENGINE) { if (sel_eng != INVALID_ENGINE) {
this->rename_engine = sel_eng; this->rename_engine = sel_eng;
SetDParam(0, PackEngineNameDParam(sel_eng, EngineNameContext::Generic)); ShowQueryString(GetString(STR_ENGINE_NAME, PackEngineNameDParam(sel_eng, EngineNameContext::Generic)), STR_QUERY_RENAME_TRAIN_TYPE_CAPTION + this->vehicle_type, MAX_LENGTH_ENGINE_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
ShowQueryString(STR_ENGINE_NAME, STR_QUERY_RENAME_TRAIN_TYPE_CAPTION + this->vehicle_type, MAX_LENGTH_ENGINE_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
} }
break; break;
} }

View File

@ -451,13 +451,11 @@ struct CheatWindow : Window {
if (btn == CHT_CHANGE_DATE && x >= SETTING_BUTTON_WIDTH) { if (btn == CHT_CHANGE_DATE && x >= SETTING_BUTTON_WIDTH) {
/* Click at the date text directly. */ /* Click at the date text directly. */
clicked_cheat = CHT_CHANGE_DATE; clicked_cheat = CHT_CHANGE_DATE;
SetDParam(0, value); ShowQueryString(GetString(STR_JUST_INT, value), STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
return; return;
} else if (btn == CHT_EDIT_MAX_HL && x >= SETTING_BUTTON_WIDTH) { } else if (btn == CHT_EDIT_MAX_HL && x >= SETTING_BUTTON_WIDTH) {
clicked_cheat = CHT_EDIT_MAX_HL; clicked_cheat = CHT_EDIT_MAX_HL;
SetDParam(0, value); ShowQueryString(GetString(STR_JUST_INT, value), STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
ShowQueryString(STR_JUST_INT, STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
return; return;
} }
@ -518,10 +516,9 @@ struct CheatWindow : Window {
if (sd->min < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input if (sd->min < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input
this->valuewindow_entry = sd; this->valuewindow_entry = sd;
SetDParam(0, value64);
/* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */ /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QSF_ENABLE_DEFAULT); ShowQueryString(GetString(STR_JUST_INT, value64), STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QSF_ENABLE_DEFAULT);
} }
this->clicked_setting = sd; this->clicked_setting = sd;

View File

@ -1631,8 +1631,7 @@ public:
/* 'Company manager face number' button, view and/or set company manager face number */ /* 'Company manager face number' button, view and/or set company manager face number */
case WID_SCMF_FACECODE: case WID_SCMF_FACECODE:
SetDParam(0, this->face); ShowQueryString(GetString(STR_JUST_INT, this->face), STR_FACE_FACECODE_CAPTION, 10 + 1, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_FACE_FACECODE_CAPTION, 10 + 1, this, CS_NUMERAL, QSF_NONE);
break; break;
/* Save button */ /* Save button */
@ -2458,14 +2457,12 @@ struct CompanyWindow : Window
case WID_C_PRESIDENT_NAME: case WID_C_PRESIDENT_NAME:
this->query_widget = WID_C_PRESIDENT_NAME; this->query_widget = WID_C_PRESIDENT_NAME;
SetDParam(0, this->window_number); ShowQueryString(GetString(STR_PRESIDENT_NAME, this->window_number), STR_COMPANY_VIEW_PRESIDENT_S_NAME_QUERY_CAPTION, MAX_LENGTH_PRESIDENT_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
ShowQueryString(STR_PRESIDENT_NAME, STR_COMPANY_VIEW_PRESIDENT_S_NAME_QUERY_CAPTION, MAX_LENGTH_PRESIDENT_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break; break;
case WID_C_COMPANY_NAME: case WID_C_COMPANY_NAME:
this->query_widget = WID_C_COMPANY_NAME; this->query_widget = WID_C_COMPANY_NAME;
SetDParam(0, this->window_number); ShowQueryString(GetString(STR_COMPANY_NAME, this->window_number), STR_COMPANY_VIEW_COMPANY_NAME_QUERY_CAPTION, MAX_LENGTH_COMPANY_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
ShowQueryString(STR_COMPANY_NAME, STR_COMPANY_VIEW_COMPANY_NAME_QUERY_CAPTION, MAX_LENGTH_COMPANY_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break; break;
case WID_C_VIEW_HQ: { case WID_C_VIEW_HQ: {
@ -2509,7 +2506,7 @@ struct CompanyWindow : Window
case WID_C_GIVE_MONEY: case WID_C_GIVE_MONEY:
this->query_widget = WID_C_GIVE_MONEY; this->query_widget = WID_C_GIVE_MONEY;
ShowQueryString(STR_EMPTY, STR_COMPANY_VIEW_GIVE_MONEY_QUERY_CAPTION, 30, this, CS_NUMERAL, QSF_NONE); ShowQueryString({}, STR_COMPANY_VIEW_GIVE_MONEY_QUERY_CAPTION, 30, this, CS_NUMERAL, QSF_NONE);
break; break;
case WID_C_HOSTILE_TAKEOVER: case WID_C_HOSTILE_TAKEOVER:

View File

@ -808,9 +808,8 @@ struct DepotWindow : Window {
break; break;
case WID_D_RENAME: // Rename button case WID_D_RENAME: // Rename button
SetDParam(0, this->type); ShowQueryString(GetString(STR_DEPOT_NAME, this->type, Depot::GetByTile(TileIndex(this->window_number))->index), STR_DEPOT_RENAME_DEPOT_CAPTION,
SetDParam(1, Depot::GetByTile(TileIndex(this->window_number))->index); MAX_LENGTH_DEPOT_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
ShowQueryString(STR_DEPOT_NAME, STR_DEPOT_RENAME_DEPOT_CAPTION, MAX_LENGTH_DEPOT_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break; break;
case WID_D_STOP_ALL: case WID_D_STOP_ALL:

View File

@ -345,8 +345,7 @@ struct GSConfigWindow : public Window {
} }
} else if (!bool_item && !config_item.complete_labels) { } else if (!bool_item && !config_item.complete_labels) {
/* Display a query box so users can enter a custom value. */ /* Display a query box so users can enter a custom value. */
SetDParam(0, old_val); ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QSF_NONE);
} }
this->SetDirty(); this->SetDirty();
break; break;

View File

@ -737,8 +737,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT; this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
SetDParam(0, _settings_newgame.game_creation.heightmap_height); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height), STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
break; break;
@ -756,8 +755,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_START_DATE_TEXT: // Year text case WID_GL_START_DATE_TEXT: // Year text
this->widget_id = WID_GL_START_DATE_TEXT; this->widget_id = WID_GL_START_DATE_TEXT;
SetDParam(0, _settings_newgame.game_creation.starting_year); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
break; break;
case WID_GL_SNOW_COVERAGE_DOWN: case WID_GL_SNOW_COVERAGE_DOWN:
@ -774,8 +772,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
this->widget_id = WID_GL_SNOW_COVERAGE_TEXT; this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
SetDParam(0, _settings_newgame.game_creation.snow_coverage); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.snow_coverage), STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
break; break;
case WID_GL_DESERT_COVERAGE_DOWN: case WID_GL_DESERT_COVERAGE_DOWN:
@ -792,8 +789,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
this->widget_id = WID_GL_DESERT_COVERAGE_TEXT; this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
SetDParam(0, _settings_newgame.game_creation.desert_coverage); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.desert_coverage), STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
break; break;
case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
@ -890,8 +886,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_TOWN_PULLDOWN: case WID_GL_TOWN_PULLDOWN:
if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) { if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
this->widget_id = widget; this->widget_id = widget;
SetDParam(0, _settings_newgame.game_creation.custom_town_number); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_town_number), STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, QSF_NONE);
} }
_settings_newgame.difficulty.number_towns = index; _settings_newgame.difficulty.number_towns = index;
break; break;
@ -906,8 +901,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_INDUSTRY_PULLDOWN: case WID_GL_INDUSTRY_PULLDOWN:
if ((uint)index == ID_CUSTOM) { if ((uint)index == ID_CUSTOM) {
this->widget_id = widget; this->widget_id = widget;
SetDParam(0, _settings_newgame.game_creation.custom_industry_number); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_industry_number), STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, QSF_NONE);
} }
_settings_newgame.difficulty.industry_density = index; _settings_newgame.difficulty.industry_density = index;
break; break;
@ -915,8 +909,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_TERRAIN_PULLDOWN: { case WID_GL_TERRAIN_PULLDOWN: {
if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) { if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
this->widget_id = widget; this->widget_id = widget;
SetDParam(0, _settings_newgame.game_creation.custom_terrain_type); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_terrain_type), STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
} }
_settings_newgame.difficulty.terrain_type = index; _settings_newgame.difficulty.terrain_type = index;
break; break;
@ -925,8 +918,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_WATER_PULLDOWN: { case WID_GL_WATER_PULLDOWN: {
if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) { if ((uint)index == CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY) {
this->widget_id = widget; this->widget_id = widget;
SetDParam(0, _settings_newgame.game_creation.custom_sea_level); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.custom_sea_level), STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_SEA_LEVEL, 3, this, CS_NUMERAL, QSF_NONE);
} }
_settings_newgame.difficulty.quantity_sea_lakes = index; _settings_newgame.difficulty.quantity_sea_lakes = index;
break; break;
@ -1191,8 +1183,7 @@ struct CreateScenarioWindow : public Window
case WID_CS_START_DATE_TEXT: // Year text case WID_CS_START_DATE_TEXT: // Year text
this->widget_id = WID_CS_START_DATE_TEXT; this->widget_id = WID_CS_START_DATE_TEXT;
SetDParam(0, _settings_newgame.game_creation.starting_year); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE);
break; break;
case WID_CS_FLAT_LAND_HEIGHT_DOWN: case WID_CS_FLAT_LAND_HEIGHT_DOWN:
@ -1209,8 +1200,7 @@ struct CreateScenarioWindow : public Window
case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT; this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;
SetDParam(0, _settings_newgame.game_creation.se_flat_world_height); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.se_flat_world_height), STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
break; break;
} }
} }

View File

@ -1099,12 +1099,11 @@ public:
{ {
assert(Group::IsValidID(group)); assert(Group::IsValidID(group));
this->group_rename = group; this->group_rename = group;
/* Show empty query for new groups */ /* Show empty query for new groups */
StringID str = STR_EMPTY; std::string str;
if (!empty) { if (!empty) str = GetString(STR_GROUP_NAME, group);
SetDParam(0, group);
str = STR_GROUP_NAME;
}
ShowQueryString(str, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS); ShowQueryString(str, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
} }

View File

@ -1090,13 +1090,11 @@ public:
this->editbox_line = line; this->editbox_line = line;
switch (this->editable) { switch (this->editable) {
case EA_MULTIPLIER: case EA_MULTIPLIER:
SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT)); ShowQueryString(GetString(STR_JUST_INT, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT)), STR_CONFIG_GAME_PRODUCTION_LEVEL, 10, this, CS_ALPHANUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_CONFIG_GAME_PRODUCTION_LEVEL, 10, this, CS_ALPHANUMERAL, QSF_NONE);
break; break;
case EA_RATE: case EA_RATE:
SetDParam(0, i->produced[line - IL_RATE1].rate * 8); ShowQueryString(GetString(STR_JUST_INT, i->produced[line - IL_RATE1].rate * 8), STR_CONFIG_GAME_PRODUCTION, 10, this, CS_ALPHANUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_CONFIG_GAME_PRODUCTION, 10, this, CS_ALPHANUMERAL, QSF_NONE);
break; break;
default: NOT_REACHED(); default: NOT_REACHED();

View File

@ -951,7 +951,7 @@ struct QueryStringWindow : public Window
QueryString editbox; ///< Editbox. QueryString editbox; ///< Editbox.
QueryStringFlags flags; ///< Flags controlling behaviour of the window. QueryStringFlags flags; ///< Flags controlling behaviour of the window.
QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, WindowDesc &desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) : QueryStringWindow(std::string_view str, StringID caption, uint max_bytes, uint max_chars, WindowDesc &desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) :
Window(desc), editbox(max_bytes, max_chars) Window(desc), editbox(max_bytes, max_chars)
{ {
this->editbox.text.Assign(str); this->editbox.text.Assign(str);
@ -1056,7 +1056,7 @@ static WindowDesc _query_string_desc(
* @param afilter filters out unwanted character input * @param afilter filters out unwanted character input
* @param flags various flags, @see QueryStringFlags * @param flags various flags, @see QueryStringFlags
*/ */
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags) void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
{ {
assert(parent != nullptr); assert(parent != nullptr);

View File

@ -750,9 +750,8 @@ public:
break; break;
case WID_NG_ADD: // Add a server case WID_NG_ADD: // Add a server
SetDParamStr(0, _settings_client.network.connect_to_ip);
ShowQueryString( ShowQueryString(
STR_JUST_RAW_STRING, _settings_client.network.connect_to_ip,
STR_NETWORK_SERVER_LIST_ENTER_SERVER_ADDRESS, STR_NETWORK_SERVER_LIST_ENTER_SERVER_ADDRESS,
NETWORK_HOSTNAME_PORT_LENGTH, // maximum number of characters including '\0' NETWORK_HOSTNAME_PORT_LENGTH, // maximum number of characters including '\0'
this, CS_ALPHANUMERAL, QSF_ACCEPT_UNCHANGED); this, CS_ALPHANUMERAL, QSF_ACCEPT_UNCHANGED);
@ -1045,8 +1044,7 @@ struct NetworkStartServerWindow : public Window {
case WID_NSS_SETPWD: // Set password button case WID_NSS_SETPWD: // Set password button
this->widget_id = WID_NSS_SETPWD; this->widget_id = WID_NSS_SETPWD;
SetDParamStr(0, _settings_client.network.server_password); ShowQueryString(_settings_client.network.server_password, STR_NETWORK_START_SERVER_SET_PASSWORD, NETWORK_PASSWORD_LENGTH, this, CS_ALPHANUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_START_SERVER_SET_PASSWORD, NETWORK_PASSWORD_LENGTH, this, CS_ALPHANUMERAL, QSF_NONE);
break; break;
case WID_NSS_CONNTYPE_BTN: // Connection type case WID_NSS_CONNTYPE_BTN: // Connection type
@ -1074,14 +1072,12 @@ struct NetworkStartServerWindow : public Window {
case WID_NSS_CLIENTS_TXT: // Click on number of clients case WID_NSS_CLIENTS_TXT: // Click on number of clients
this->widget_id = WID_NSS_CLIENTS_TXT; this->widget_id = WID_NSS_CLIENTS_TXT;
SetDParam(0, _settings_client.network.max_clients); ShowQueryString(GetString(STR_JUST_INT, _settings_client.network.max_clients), STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS, 4, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS, 4, this, CS_NUMERAL, QSF_NONE);
break; break;
case WID_NSS_COMPANIES_TXT: // Click on number of companies case WID_NSS_COMPANIES_TXT: // Click on number of companies
this->widget_id = WID_NSS_COMPANIES_TXT; this->widget_id = WID_NSS_COMPANIES_TXT;
SetDParam(0, _settings_client.network.max_companies); ShowQueryString(GetString(STR_JUST_INT, _settings_client.network.max_companies), STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES, 3, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES, 3, this, CS_NUMERAL, QSF_NONE);
break; break;
case WID_NSS_GENERATE_GAME: // Start game case WID_NSS_GENERATE_GAME: // Start game
@ -1744,15 +1740,13 @@ public:
if (!_network_server) break; if (!_network_server) break;
this->query_widget = WID_CL_SERVER_NAME_EDIT; this->query_widget = WID_CL_SERVER_NAME_EDIT;
SetDParamStr(0, _settings_client.network.server_name); ShowQueryString(_settings_client.network.server_name, STR_NETWORK_CLIENT_LIST_SERVER_NAME_QUERY_CAPTION, NETWORK_NAME_LENGTH, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_NAME_QUERY_CAPTION, NETWORK_NAME_LENGTH, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
break; break;
case WID_CL_CLIENT_NAME_EDIT: { case WID_CL_CLIENT_NAME_EDIT: {
const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id); const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
this->query_widget = WID_CL_CLIENT_NAME_EDIT; this->query_widget = WID_CL_CLIENT_NAME_EDIT;
SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name); ShowQueryString(own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_QUERY_CAPTION, NETWORK_CLIENT_NAME_LENGTH, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_QUERY_CAPTION, NETWORK_CLIENT_NAME_LENGTH, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
break; break;
} }
case WID_CL_SERVER_VISIBILITY: case WID_CL_SERVER_VISIBILITY:
@ -2216,7 +2210,7 @@ void ShowNetworkNeedPassword(std::shared_ptr<NetworkAuthenticationPasswordReques
if (w == nullptr) return; if (w == nullptr) return;
w->request = request; w->request = request;
ShowQueryString(STR_EMPTY, STR_NETWORK_NEED_GAME_PASSWORD_CAPTION, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_NONE); ShowQueryString({}, STR_NETWORK_NEED_GAME_PASSWORD_CAPTION, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_NONE);
} }
/** /**

View File

@ -614,7 +614,7 @@ struct NewGRFInspectWindow : Window {
if (!HasVariableParameter(niv.var)) break; if (!HasVariableParameter(niv.var)) break;
this->current_edit_param = niv.var; this->current_edit_param = niv.var;
ShowQueryString(STR_EMPTY, STR_NEWGRF_INSPECT_QUERY_CAPTION, 9, this, CS_HEXADECIMAL, QSF_NONE); ShowQueryString({}, STR_NEWGRF_INSPECT_QUERY_CAPTION, 9, this, CS_HEXADECIMAL, QSF_NONE);
} }
} }
} }
@ -1007,7 +1007,7 @@ struct SpriteAlignerWindow : Window {
break; break;
case WID_SA_GOTO: case WID_SA_GOTO:
ShowQueryString(STR_EMPTY, STR_SPRITE_ALIGNER_GOTO_CAPTION, 7, this, CS_NUMERAL, QSF_NONE); ShowQueryString({}, STR_SPRITE_ALIGNER_GOTO_CAPTION, 7, this, CS_NUMERAL, QSF_NONE);
break; break;
case WID_SA_NEXT: case WID_SA_NEXT:

View File

@ -421,8 +421,7 @@ struct NewGRFParametersWindow : public Window {
} }
} else if (par_info.type == PTYPE_UINT_ENUM && !par_info.complete_labels && click_count >= 2) { } else if (par_info.type == PTYPE_UINT_ENUM && !par_info.complete_labels && click_count >= 2) {
/* Display a query box so users can enter a custom value. */ /* Display a query box so users can enter a custom value. */
SetDParam(0, old_val); ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE);
} }
this->SetDirty(); this->SetDirty();
break; break;

View File

@ -1364,8 +1364,7 @@ public:
assert(order != nullptr); assert(order != nullptr);
uint value = order->GetConditionValue(); uint value = order->GetConditionValue();
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value, this->vehicle->type); if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value, this->vehicle->type);
SetDParam(0, value); ShowQueryString(GetString(STR_JUST_INT, value), STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, this, CS_NUMERAL, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, this, CS_NUMERAL, QSF_NONE);
break; break;
} }

View File

@ -495,8 +495,7 @@ struct ScriptSettingsWindow : public Window {
} }
} else if (!bool_item && !config_item.complete_labels) { } else if (!bool_item && !config_item.complete_labels) {
/* Display a query box so users can enter a custom value. */ /* Display a query box so users can enter a custom value. */
SetDParam(0, old_val); ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QSF_NONE);
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QSF_NONE);
} }
this->SetDirty(); this->SetDirty();
break; break;

View File

@ -2711,9 +2711,8 @@ struct GameSettingsWindow : Window {
if (min_val < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input if (min_val < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input
this->valuewindow_entry = pe; this->valuewindow_entry = pe;
SetDParam(0, value64);
/* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */ /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QSF_ENABLE_DEFAULT); ShowQueryString(GetString(STR_JUST_INT, value64), STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QSF_ENABLE_DEFAULT);
} }
this->SetDisplayedHelpText(pe); this->SetDisplayedHelpText(pe);
} }
@ -3050,7 +3049,7 @@ struct CustomCurrencyWindow : Window {
{ {
int line = 0; int line = 0;
int len = 0; int len = 0;
StringID str = STR_NULL; std::string str;
CharSetFilter afilter = CS_ALPHANUMERAL; CharSetFilter afilter = CS_ALPHANUMERAL;
switch (widget) { switch (widget) {
@ -3067,8 +3066,7 @@ struct CustomCurrencyWindow : Window {
break; break;
case WID_CC_RATE: case WID_CC_RATE:
SetDParam(0, GetCustomCurrency().rate); str = GetString(STR_JUST_INT, GetCustomCurrency().rate);
str = STR_JUST_INT;
len = 5; len = 5;
line = WID_CC_RATE; line = WID_CC_RATE;
afilter = CS_NUMERAL; afilter = CS_NUMERAL;
@ -3076,24 +3074,21 @@ struct CustomCurrencyWindow : Window {
case WID_CC_SEPARATOR_EDIT: case WID_CC_SEPARATOR_EDIT:
case WID_CC_SEPARATOR: case WID_CC_SEPARATOR:
SetDParamStr(0, GetCustomCurrency().separator); str = GetCustomCurrency().separator;
str = STR_JUST_RAW_STRING;
len = 7; len = 7;
line = WID_CC_SEPARATOR; line = WID_CC_SEPARATOR;
break; break;
case WID_CC_PREFIX_EDIT: case WID_CC_PREFIX_EDIT:
case WID_CC_PREFIX: case WID_CC_PREFIX:
SetDParamStr(0, GetCustomCurrency().prefix); str = GetCustomCurrency().prefix;
str = STR_JUST_RAW_STRING;
len = 15; len = 15;
line = WID_CC_PREFIX; line = WID_CC_PREFIX;
break; break;
case WID_CC_SUFFIX_EDIT: case WID_CC_SUFFIX_EDIT:
case WID_CC_SUFFIX: case WID_CC_SUFFIX:
SetDParamStr(0, GetCustomCurrency().suffix); str = GetCustomCurrency().suffix;
str = STR_JUST_RAW_STRING;
len = 15; len = 15;
line = WID_CC_SUFFIX; line = WID_CC_SUFFIX;
break; break;
@ -3111,8 +3106,7 @@ struct CustomCurrencyWindow : Window {
break; break;
case WID_CC_YEAR: case WID_CC_YEAR:
SetDParam(0, GetCustomCurrency().to_euro); str = GetString(STR_JUST_INT, GetCustomCurrency().to_euro);
str = STR_JUST_INT;
len = 7; len = 7;
line = WID_CC_YEAR; line = WID_CC_YEAR;
afilter = CS_NUMERAL; afilter = CS_NUMERAL;

View File

@ -428,8 +428,7 @@ struct SignWindow : Window, SignList {
{ {
/* Display an empty string when the sign hasn't been edited yet */ /* Display an empty string when the sign hasn't been edited yet */
if (!si->name.empty()) { if (!si->name.empty()) {
SetDParam(0, si->index); this->name_editbox.text.Assign(GetString(STR_SIGN_NAME, si->index));
this->name_editbox.text.Assign(STR_SIGN_NAME);
} else { } else {
this->name_editbox.text.DeleteAll(); this->name_editbox.text.DeleteAll();
} }

View File

@ -2002,8 +2002,7 @@ struct StationViewWindow : public Window {
} }
case WID_SV_RENAME: case WID_SV_RENAME:
SetDParam(0, this->window_number); ShowQueryString(GetString(STR_STATION_NAME, this->window_number), STR_STATION_VIEW_RENAME_STATION_CAPTION, MAX_LENGTH_STATION_NAME_CHARS,
ShowQueryString(STR_STATION_NAME, STR_STATION_VIEW_RENAME_STATION_CAPTION, MAX_LENGTH_STATION_NAME_CHARS,
this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS); this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break; break;

View File

@ -424,15 +424,6 @@ Textbuf::~Textbuf()
free(this->buf); free(this->buf);
} }
/**
* Render a string into the textbuffer.
* @param string String
*/
void Textbuf::Assign(StringID string)
{
this->Assign(GetString(string));
}
/** /**
* Copy a string into the textbuffer. * Copy a string into the textbuffer.
* @param text Source. * @param text Source.

View File

@ -27,7 +27,7 @@ DECLARE_ENUM_AS_BIT_SET(QueryStringFlags)
/** Callback procedure for the ShowQuery method. */ /** Callback procedure for the ShowQuery method. */
typedef void QueryCallbackProc(Window*, bool); typedef void QueryCallbackProc(Window*, bool);
void ShowQueryString(StringID str, StringID caption, uint max_len, Window *parent, CharSetFilter afilter, QueryStringFlags flags); void ShowQueryString(std::string_view str, StringID caption, uint max_len, Window *parent, CharSetFilter afilter, QueryStringFlags flags);
void ShowQuery(StringID caption, StringID message, Window *w, QueryCallbackProc *callback, bool focus = false); void ShowQuery(StringID caption, StringID message, Window *w, QueryCallbackProc *callback, bool focus = false);
/** The number of 'characters' on the on-screen keyboard. */ /** The number of 'characters' on the on-screen keyboard. */

View File

@ -45,7 +45,6 @@ struct Textbuf {
explicit Textbuf(uint16_t max_bytes, uint16_t max_chars = UINT16_MAX); explicit Textbuf(uint16_t max_bytes, uint16_t max_chars = UINT16_MAX);
~Textbuf(); ~Textbuf();
void Assign(StringID string);
void Assign(const std::string_view text); void Assign(const std::string_view text);
void DeleteAll(); void DeleteAll();

View File

@ -653,7 +653,7 @@ struct TimetableWindow : Window {
if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) { if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) {
this->query_widget = WID_VT_START_DATE; this->query_widget = WID_VT_START_DATE;
this->change_timetable_all = _ctrl_pressed; this->change_timetable_all = _ctrl_pressed;
ShowQueryString(STR_EMPTY, STR_TIMETABLE_START_SECONDS_QUERY, 6, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED); ShowQueryString({}, STR_TIMETABLE_START_SECONDS_QUERY, 6, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
} else { } else {
ShowSetDateWindow(this, v->index, TimerGameEconomy::date, TimerGameEconomy::year, TimerGameEconomy::year + MAX_TIMETABLE_START_YEARS, ChangeTimetableStartCallback, reinterpret_cast<void*>(static_cast<uintptr_t>(_ctrl_pressed))); ShowSetDateWindow(this, v->index, TimerGameEconomy::date, TimerGameEconomy::year, TimerGameEconomy::year + MAX_TIMETABLE_START_YEARS, ChangeTimetableStartCallback, reinterpret_cast<void*>(static_cast<uintptr_t>(_ctrl_pressed)));
} }
@ -667,15 +667,14 @@ struct TimetableWindow : Window {
if (real >= v->GetNumOrders()) real = 0; if (real >= v->GetNumOrders()) real = 0;
const Order *order = v->GetOrder(real); const Order *order = v->GetOrder(real);
StringID current = STR_EMPTY; std::string current;
if (order != nullptr) { if (order != nullptr) {
uint time = (selected % 2 != 0) ? order->GetTravelTime() : order->GetWaitTime(); uint time = (selected % 2 != 0) ? order->GetTravelTime() : order->GetWaitTime();
time /= TicksPerTimetableUnit(); time /= TicksPerTimetableUnit();
if (time != 0) { if (time != 0) {
SetDParam(0, time); current = GetString(STR_JUST_INT, time);
current = STR_JUST_INT;
} }
} }
@ -691,12 +690,11 @@ struct TimetableWindow : Window {
if (real >= v->GetNumOrders()) real = 0; if (real >= v->GetNumOrders()) real = 0;
StringID current = STR_EMPTY; std::string current;
const Order *order = v->GetOrder(real); const Order *order = v->GetOrder(real);
if (order != nullptr) { if (order != nullptr) {
if (order->GetMaxSpeed() != UINT16_MAX) { if (order->GetMaxSpeed() != UINT16_MAX) {
SetDParam(0, ConvertKmhishSpeedToDisplaySpeed(order->GetMaxSpeed(), v->type)); current = GetString(STR_JUST_INT, ConvertKmhishSpeedToDisplaySpeed(order->GetMaxSpeed(), v->type));
current = STR_JUST_INT;
} }
} }

View File

@ -1203,8 +1203,7 @@ static CallBackFunction ToolbarSwitchClick(Window *w)
*/ */
static CallBackFunction ToolbarScenDatePanel(Window *w) static CallBackFunction ToolbarScenDatePanel(Window *w)
{ {
SetDParam(0, _settings_game.game_creation.starting_year); ShowQueryString(GetString(STR_JUST_INT, _settings_game.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, w, CS_NUMERAL, QSF_ENABLE_DEFAULT);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, w, CS_NUMERAL, QSF_ENABLE_DEFAULT);
return CBF_NONE; return CBF_NONE;
} }

View File

@ -513,8 +513,7 @@ public:
break; break;
case WID_TV_CHANGE_NAME: // rename case WID_TV_CHANGE_NAME: // rename
SetDParam(0, this->window_number); ShowQueryString(GetString(STR_TOWN_NAME, this->window_number), STR_TOWN_VIEW_RENAME_TOWN_BUTTON, MAX_LENGTH_TOWN_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
ShowQueryString(STR_TOWN_NAME, STR_TOWN_VIEW_RENAME_TOWN_BUTTON, MAX_LENGTH_TOWN_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break; break;
case WID_TV_CATCHMENT: case WID_TV_CATCHMENT:

View File

@ -3302,8 +3302,7 @@ public:
switch (widget) { switch (widget) {
case WID_VV_RENAME: { // rename case WID_VV_RENAME: { // rename
SetDParam(0, v->index); ShowQueryString(GetString(STR_VEHICLE_NAME, v->index), STR_QUERY_RENAME_TRAIN_CAPTION + v->type,
ShowQueryString(STR_VEHICLE_NAME, STR_QUERY_RENAME_TRAIN_CAPTION + v->type,
MAX_LENGTH_VEHICLE_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS); MAX_LENGTH_VEHICLE_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break; break;
} }

View File

@ -135,8 +135,7 @@ public:
break; break;
case WID_W_RENAME: // rename case WID_W_RENAME: // rename
SetDParam(0, this->wp->index); ShowQueryString(GetString(STR_WAYPOINT_NAME, this->wp->index), STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_STATION_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
ShowQueryString(STR_WAYPOINT_NAME, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_STATION_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break; break;
case WID_W_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders case WID_W_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders