diff options
author | Darkvater <Darkvater@openttd.org> | 2006-12-30 01:17:53 +0000 |
---|---|---|
committer | Darkvater <Darkvater@openttd.org> | 2006-12-30 01:17:53 +0000 |
commit | 990270fda928f7ce9e0638189b8fc65683583e71 (patch) | |
tree | 4ef6719359384448b5674c8f954ba1a88987d16d | |
parent | faea6549ce13b05ab565162a9d9e0fcf0818f6dc (diff) | |
download | openttd-990270fda928f7ce9e0638189b8fc65683583e71.tar.xz |
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
query has no parent (eg give money, rename waypoint), the global function
HandleOnEditText is used.
-rw-r--r-- | aircraft_gui.c | 2 | ||||
-rw-r--r-- | build_vehicle_gui.c | 2 | ||||
-rw-r--r-- | genworld_gui.c | 8 | ||||
-rw-r--r-- | gui.h | 3 | ||||
-rw-r--r-- | industry_gui.c | 5 | ||||
-rw-r--r-- | intro_gui.c | 4 | ||||
-rw-r--r-- | main_gui.c | 24 | ||||
-rw-r--r-- | misc_gui.c | 140 | ||||
-rw-r--r-- | network_gui.c | 17 | ||||
-rw-r--r-- | newgrf_gui.c | 2 | ||||
-rw-r--r-- | player_gui.c | 6 | ||||
-rw-r--r-- | roadveh_gui.c | 5 | ||||
-rw-r--r-- | settings_gui.c | 12 | ||||
-rw-r--r-- | ship_gui.c | 7 | ||||
-rw-r--r-- | station_gui.c | 2 | ||||
-rw-r--r-- | town_gui.c | 2 | ||||
-rw-r--r-- | train_gui.c | 4 | ||||
-rw-r--r-- | window.h | 3 |
18 files changed, 112 insertions, 136 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c index c488c1671..ded25b463 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -125,7 +125,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e) case 2: /* rename */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); - ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w, CS_ALPHANUMERAL); break; case 5: /* increase int */ mod = _ctrl_pressed? 5 : 10; diff --git a/build_vehicle_gui.c b/build_vehicle_gui.c index 3f23bef4b..b293b516c 100644 --- a/build_vehicle_gui.c +++ b/build_vehicle_gui.c @@ -396,7 +396,7 @@ static void BuildAircraftClickEvent(Window *w, WindowEvent *e) EngineID sel_eng = bv->sel_engine; if (sel_eng != INVALID_ENGINE) { bv->rename_engine = sel_eng; - ShowQueryString(GetCustomEngineName(sel_eng), STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(GetCustomEngineName(sel_eng), STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w, CS_ALPHANUMERAL); } break; } diff --git a/genworld_gui.c b/genworld_gui.c index 1dfd758e0..2519a67fd 100644 --- a/genworld_gui.c +++ b/genworld_gui.c @@ -345,7 +345,7 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e) case 19: // Year text WP(w, def_d).data_3 = START_DATE_QUERY; SetDParam(0, _patches_newgame.starting_year); - ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, WC_GENERATE_LANDSCAPE, mode, CS_NUMERAL); + ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL); break; case 21: case 23: // Snow line buttons /* Don't allow too fast scrolling */ @@ -360,7 +360,7 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e) case 22: // Snow line text WP(w, def_d).data_3 = SNOW_LINE_QUERY; SetDParam(0, _patches_newgame.snow_line_height); - ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, WC_GENERATE_LANDSCAPE, mode, CS_NUMERAL); + ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, w, CS_NUMERAL); break; case 24: case 25: // Tree placer ShowDropDownMenu(w, tree_placer, _patches_newgame.tree_placer, 25, 0, 0); @@ -604,7 +604,7 @@ void CreateScenarioWndProc(Window *w, WindowEvent *e) case 15: // Year text WP(w, def_d).data_3 = START_DATE_QUERY; SetDParam(0, _patches_newgame.starting_year); - ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, WC_GENERATE_LANDSCAPE, GLWP_SCENARIO, CS_NUMERAL); + ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL); break; case 17: case 19: // Height level buttons /* Don't allow too fast scrolling */ @@ -619,7 +619,7 @@ void CreateScenarioWndProc(Window *w, WindowEvent *e) case 18: // Height level text WP(w, def_d).data_3 = FLAT_WORLD_HEIGHT_QUERY; SetDParam(0, _patches_newgame.se_flat_world_height); - ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, WC_GENERATE_LANDSCAPE, GLWP_SCENARIO, CS_NUMERAL); + ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, w, CS_NUMERAL); break; } break; @@ -126,11 +126,12 @@ extern const byte _fios_colors[]; void ShowBuildBridgeWindow(uint start, uint end, byte type); void ShowBuildIndustryWindow(void); -void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, WindowClass window_class, WindowNumber window_number, CharSetFilter afilter); +void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter); void ShowQuery(StringID caption, StringID message, Window *w, void (*callback)(Window*, bool)); void ShowMusicWindow(void); /* main_gui.c */ +void HandleOnEditText(const char *str); VARDEF byte _station_show_coverage; VARDEF PlaceProc *_place_proc; diff --git a/industry_gui.c b/industry_gui.c index fa6d13198..3e481ef88 100644 --- a/industry_gui.c +++ b/industry_gui.c @@ -380,10 +380,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e) // clicked the text WP(w,vp2_d).data_1 = line; SetDParam(0, i->production_rate[line] * 8); - ShowQueryString(STR_CONFIG_PATCHES_INT32, - STR_CONFIG_GAME_PRODUCTION, - 10, 100, w->window_class, - w->window_number, CS_ALPHANUMERAL); + ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, w, CS_ALPHANUMERAL); } } } break; diff --git a/intro_gui.c b/intro_gui.c index 32e345aa4..364b81f5f 100644 --- a/intro_gui.c +++ b/intro_gui.c @@ -41,8 +41,6 @@ static const Widget _select_game_widgets[] = { { WIDGETS_END}, }; -extern void HandleOnEditText(WindowEvent *e); - static inline void SetNewLandscapeType(byte landscape) { _opt_newgame.landscape = landscape; @@ -88,8 +86,6 @@ static void SelectGameWndProc(Window *w, WindowEvent *e) case 16: HandleExitGameRequest(); break; } break; - - case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; } } diff --git a/main_gui.c b/main_gui.c index ad28e506b..bf991e88f 100644 --- a/main_gui.c +++ b/main_gui.c @@ -54,27 +54,23 @@ extern void GenerateIndustries(void); extern bool GenerateTowns(void); -void HandleOnEditText(WindowEvent *e) +void HandleOnEditText(const char *str) { - const char *b = e->we.edittext.str; - int id; - - _cmd_text = b; - - id = _rename_id; + int id = _rename_id; + _cmd_text = str; switch (_rename_what) { case 0: /* Rename a s sign, if string is empty, delete sign */ DoCommandP(0, id, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)); break; case 1: /* Rename a waypoint */ - if (*b == '\0') return; + if (*str == '\0') return; DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME)); break; #ifdef ENABLE_NETWORK case 3: { /* Give money, you can only give money in excess of loan */ const Player *p = GetPlayer(_current_player); - int32 money = min(p->money64 - p->current_loan, atoi(e->we.edittext.str) / _currency->rate); + int32 money = min(p->money64 - p->current_loan, atoi(str) / _currency->rate); char msg[20]; money = clamp(money, 0, 20000000); // Clamp between 20 million and 0 @@ -311,7 +307,7 @@ void ShowNetworkGiveMoneyWindow(PlayerID player) { _rename_id = player; _rename_what = 3; - ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, 1, 0, CS_NUMERAL); + ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, NULL, CS_NUMERAL); } #endif /* ENABLE_NETWORK */ @@ -319,7 +315,7 @@ void ShowRenameSignWindow(const Sign *si) { _rename_id = si->index; _rename_what = 0; - ShowQueryString(si->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, 1, 0, CS_ALPHANUMERAL); + ShowQueryString(si->str, STR_280B_EDIT_SIGN_TEXT, 30, 180, NULL, CS_ALPHANUMERAL); } void ShowRenameWaypointWindow(const Waypoint *wp) @@ -336,7 +332,7 @@ void ShowRenameWaypointWindow(const Waypoint *wp) _rename_id = id; _rename_what = 1; SetDParam(0, id); - ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, 1, 0, CS_ALPHANUMERAL); + ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL); } static void SelectSignTool(void) @@ -1837,8 +1833,6 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e) SetWindowDirty(w); } break; - case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; - case WE_MOUSELOOP: if (IsWindowWidgetLowered(w, 0) != !!_pause) { ToggleWidgetLoweredState(w, 0); @@ -2038,8 +2032,6 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e) SetWindowDirty(w); } break; - case WE_ON_EDIT_TEXT: HandleOnEditText(e); break; - case WE_MOUSELOOP: if (IsWindowWidgetLowered(w, 0) != !!_pause) { ToggleWidgetLoweredState(w, 0); diff --git a/misc_gui.c b/misc_gui.c index 92ba1b4fa..1bca0f997 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -1038,93 +1038,87 @@ void DrawEditBox(Window *w, querystr_d *string, int wid) _cur_dpi = old_dpi; } +enum QueryStringWidgets { + QUERY_STR_WIDGET_TEXT = 3, + QUERY_STR_WIDGET_CANCEL, + QUERY_STR_WIDGET_OK +}; + + static void QueryStringWndProc(Window *w, WindowEvent *e) { - static bool closed = false; + querystr_d *qs = &WP(w, querystr_d); + switch (e->event) { - case WE_CREATE: - SETBIT(_no_scroll, SCROLL_EDIT); - closed = false; - break; + case WE_CREATE: + SETBIT(_no_scroll, SCROLL_EDIT); + break; - case WE_PAINT: - SetDParam(0, WP(w,querystr_d).caption); - DrawWindowWidgets(w); + case WE_PAINT: + SetDParam(0, qs->caption); + DrawWindowWidgets(w); - DrawEditBox(w, &WP(w,querystr_d), 5); - break; + DrawEditBox(w, qs, QUERY_STR_WIDGET_TEXT); + break; - case WE_CLICK: - switch (e->we.click.widget) { - case 3: DeleteWindow(w); break; - case 4: -press_ok:; - if (WP(w, querystr_d).orig != NULL && - strcmp(WP(w, querystr_d).text.buf, WP(w, querystr_d).orig) == 0) { - DeleteWindow(w); - } else { - char *buf = WP(w,querystr_d).text.buf; - WindowClass wnd_class = WP(w,querystr_d).wnd_class; - WindowNumber wnd_num = WP(w,querystr_d).wnd_num; - Window *parent; - - // Mask the edit-box as closed, so we don't send out a CANCEL - closed = true; - - DeleteWindow(w); - - parent = FindWindowById(wnd_class, wnd_num); - if (parent != NULL) { - WindowEvent e; - e.event = WE_ON_EDIT_TEXT; - e.we.edittext.str = buf; - parent->wndproc(parent, &e); - } + case WE_CLICK: + switch (e->we.click.widget) { + case QUERY_STR_WIDGET_OK: + press_ok:; + if (qs->orig == NULL || strcmp(qs->text.buf, qs->orig) != 0) { + Window *parent = w->parent; + qs->handled = true; + + /* If the parent is NULL, the editbox is handled by general function + * HandleOnEditText */ + if (parent != NULL) { + WindowEvent e; + e.event = WE_ON_EDIT_TEXT; + e.we.edittext.str = qs->text.buf; + parent->wndproc(parent, &e); + } else { + HandleOnEditText(qs->text.buf); + } + } + /* Fallthrough */ + case QUERY_STR_WIDGET_CANCEL: + DeleteWindow(w); + break; } break; - } - break; - case WE_MOUSELOOP: { - if (!FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num)) { - DeleteWindow(w); - return; - } - HandleEditBox(w, &WP(w, querystr_d), 5); - } break; + case WE_MOUSELOOP: + HandleEditBox(w, qs, QUERY_STR_WIDGET_TEXT); + break; - case WE_KEYPRESS: { - switch (HandleEditBoxKey(w, &WP(w, querystr_d), 5, e)) { - case 1: // Return - goto press_ok; - case 2: // Escape - DeleteWindow(w); + case WE_KEYPRESS: + switch (HandleEditBoxKey(w, qs, QUERY_STR_WIDGET_TEXT, e)) { + case 1: goto press_ok; /* Enter pressed, confirms change */ + case 2: DeleteWindow(w); break; /* ESC pressed, closes window, abandons changes */ + } break; - } - } break; - case WE_DESTROY: - // If the window is not closed yet, it means it still needs to send a CANCEL - if (!closed) { - Window *parent = FindWindowById(WP(w,querystr_d).wnd_class, WP(w,querystr_d).wnd_num); - if (parent != NULL) { + case WE_DESTROY: /* Call cancellation of query, if we have not handled it before */ + if (!qs->handled && w->parent != NULL) { WindowEvent e; + Window *parent = w->parent; + + qs->handled = true; e.event = WE_ON_EDIT_TEXT_CANCEL; parent->wndproc(parent, &e); } + CLRBIT(_no_scroll, SCROLL_EDIT); + break; } - CLRBIT(_no_scroll, SCROLL_EDIT); - break; - } } static const Widget _query_string_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_012D, STR_NULL}, { WWT_PANEL, RESIZE_NONE, 14, 0, 259, 14, 29, 0x0, STR_NULL}, +{ WWT_PANEL, RESIZE_NONE, 14, 2, 257, 16, 27, 0x0, STR_NULL}, { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 129, 30, 41, STR_012E_CANCEL, STR_NULL}, { WWT_TEXTBTN, RESIZE_NONE, 14, 130, 259, 30, 41, STR_012F_OK, STR_NULL}, -{ WWT_PANEL, RESIZE_NONE, 14, 2, 257, 16, 27, 0x0, STR_NULL}, { WIDGETS_END}, }; @@ -1137,10 +1131,19 @@ static const WindowDesc _query_string_desc = { }; static char _edit_str_buf[64]; -static char _orig_str_buf[lengthof(_edit_str_buf)]; -void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, WindowClass window_class, WindowNumber window_number, CharSetFilter afilter) +/** 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 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) { + static char orig_str_buf[lengthof(_edit_str_buf)]; Window *w; uint realmaxlen = maxlen & ~0x1000; @@ -1150,6 +1153,7 @@ void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, DeleteWindowById(WC_SAVELOAD, 0); w = AllocateWindowDesc(&_query_string_desc); + w->parent = parent; GetString(_edit_str_buf, str, lastof(_edit_str_buf)); _edit_str_buf[realmaxlen - 1] = '\0'; @@ -1157,14 +1161,12 @@ void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, if (maxlen & 0x1000) { WP(w, querystr_d).orig = NULL; } else { - strecpy(_orig_str_buf, _edit_str_buf, lastof(_orig_str_buf)); - WP(w, querystr_d).orig = _orig_str_buf; + strecpy(orig_str_buf, _edit_str_buf, lastof(orig_str_buf)); + WP(w, querystr_d).orig = orig_str_buf; } - LowerWindowWidget(w, 5); + LowerWindowWidget(w, QUERY_STR_WIDGET_TEXT); WP(w, querystr_d).caption = caption; - WP(w, querystr_d).wnd_class = window_class; - WP(w, querystr_d).wnd_num = window_number; WP(w, querystr_d).afilter = afilter; InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, realmaxlen, maxwidth); } diff --git a/network_gui.c b/network_gui.c index 207d93fbe..4c994872c 100644 --- a/network_gui.c +++ b/network_gui.c @@ -424,8 +424,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) STR_NETWORK_ENTER_IP, 31 | 0x1000, // maximum number of characters OR 250, // characters up to this width pixels, whichever is satisfied first - w->window_class, - w->window_number, CS_ALPHANUMERAL); + w, CS_ALPHANUMERAL); } break; case 13: /* Start server */ ShowNetworkStartServerWindow(); @@ -648,8 +647,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) break; case 4: /* Set password button */ - ShowQueryString(BindCString(_network_server_password), - STR_NETWORK_SET_PASSWORD, 20, 250, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(BindCString(_network_server_password), STR_NETWORK_SET_PASSWORD, 20, 250, w, CS_ALPHANUMERAL); break; case 5: { /* Select map */ @@ -1381,7 +1379,7 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt) 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, WC_NETWORK_STATUS_WINDOW, 0, CS_ALPHANUMERAL); + ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL); } @@ -1421,13 +1419,14 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) case 0: /* Close 'X' */ case 3: /* Disconnect button */ NetworkDisconnect(); - DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); + DeleteWindow(w); SwitchMode(SM_MENU); ShowNetworkGameWindow(); break; } break; + /* If the server asks for a password, we need to fill it in */ case WE_ON_EDIT_TEXT_CANCEL: NetworkDisconnect(); ShowNetworkGameWindow(); @@ -1709,10 +1708,8 @@ void ShowNetworkChatQueryWindow(DestType type, byte dest) w = AllocateWindowDesc(&_chat_window_desc); LowerWindowWidget(w, 2); - WP(w,querystr_d).caption = GB(type, 0, 8) | (dest << 8); // Misuse of caption - WP(w,querystr_d).wnd_class = WC_MAIN_TOOLBAR; - WP(w,querystr_d).wnd_num = 0; - WP(w,querystr_d).afilter = CS_ALPHANUMERAL; + WP(w, querystr_d).caption = GB(type, 0, 8) | (dest << 8); // Misuse of caption + WP(w, querystr_d).afilter = CS_ALPHANUMERAL; InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0); } diff --git a/newgrf_gui.c b/newgrf_gui.c index ad9aa5916..4ae734207 100644 --- a/newgrf_gui.c +++ b/newgrf_gui.c @@ -436,7 +436,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e) if (WP(w, newgrf_d).sel == NULL) break; GRFBuildParamList(buff, WP(w, newgrf_d).sel, lastof(buff)); - ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, w, CS_ALPHANUMERAL); break; } } diff --git a/player_gui.c b/player_gui.c index e7bb30609..80eb77d3b 100644 --- a/player_gui.c +++ b/player_gui.c @@ -765,7 +765,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) const Player *p = GetPlayer(w->window_number); WP(w, def_d).byte_1 = 0; SetDParam(0, p->president_name_2); - ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w, CS_ALPHANUMERAL); break; } @@ -773,7 +773,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) Player *p = GetPlayer(w->window_number); WP(w,def_d).byte_1 = 1; SetDParam(0, p->name_2); - ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL); break; } @@ -812,7 +812,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) if (w->window_number == _local_player) { WP(w,def_d).byte_1 = 2; ShowQueryString(BindCString(_network_player_info[_local_player].password), - STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w->window_class, w->window_number, CS_ALPHANUMERAL); + STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w, CS_ALPHANUMERAL); } break; #endif /* ENABLE_NETWORK */ diff --git a/roadveh_gui.c b/roadveh_gui.c index 1dfb48789..ba382b04a 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -162,7 +162,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) case 2: /* rename */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); - ShowQueryString(v->string_id, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(v->string_id, STR_902C_NAME_ROAD_VEHICLE, 31, 150, w, CS_ALPHANUMERAL); break; case 5: /* increase int */ @@ -479,8 +479,7 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e) EngineID sel_eng = WP(w,buildvehicle_d).sel_engine; if (sel_eng != INVALID_ENGINE) { WP(w,buildvehicle_d).rename_engine = sel_eng; - ShowQueryString(GetCustomEngineName(sel_eng), - STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(GetCustomEngineName(sel_eng), STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w, CS_ALPHANUMERAL); } } break; } diff --git a/settings_gui.c b/settings_gui.c index f9efc264d..1c1bdcb7d 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -845,7 +845,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) WP(w,def_d).data_3 = btn; SetDParam(0, value); - ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, WC_GAME_OPTIONS, 0, CS_NUMERAL); + ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL); } } @@ -1061,14 +1061,8 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) } if (len != 0) { - WP(w,def_d).data_2 = line; - ShowQueryString( - str, - STR_CURRENCY_CHANGE_PARAMETER, - len + 1, // maximum number of characters OR - 250, // characters up to this width pixels, whichever is satisfied first - w->window_class, - w->window_number, afilter); + WP(w, def_d).data_2 = line; + ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, w, afilter); } w->flags4 |= 5 << WF_TIMEOUT_SHL; diff --git a/ship_gui.c b/ship_gui.c index c0719d803..010ea71e5 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -161,7 +161,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e) case 2: /* rename */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); - ShowQueryString(v->string_id, STR_9831_NAME_SHIP, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(v->string_id, STR_9831_NAME_SHIP, 31, 150, w, CS_ALPHANUMERAL); break; case 5: /* increase int */ mod = _ctrl_pressed? 5 : 10; @@ -302,9 +302,8 @@ static void NewShipWndProc(Window *w, WindowEvent *e) case 6: { /* rename */ EngineID sel_eng = WP(w,buildvehicle_d).sel_engine; if (sel_eng != INVALID_ENGINE) { - WP(w,buildvehicle_d).rename_engine = sel_eng; - ShowQueryString(GetCustomEngineName(sel_eng), - STR_9838_RENAME_SHIP_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL); + WP(w, buildvehicle_d).rename_engine = sel_eng; + ShowQueryString(GetCustomEngineName(sel_eng), STR_9838_RENAME_SHIP_TYPE, 31, 160, w, CS_ALPHANUMERAL); } } break; } diff --git a/station_gui.c b/station_gui.c index 84845ab86..55428a793 100644 --- a/station_gui.c +++ b/station_gui.c @@ -749,7 +749,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e) case 9: { SetDParam(0, w->window_number); - ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w, CS_ALPHANUMERAL); } break; case 10: { /* Show a list of scheduled trains to this station */ diff --git a/town_gui.c b/town_gui.c index 896e7cffd..10fef991b 100644 --- a/town_gui.c +++ b/town_gui.c @@ -266,7 +266,7 @@ static void TownViewWndProc(Window *w, WindowEvent *e) case 8: /* rename */ SetDParam(0, w->window_number); - ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w, CS_ALPHANUMERAL); break; case 9: /* expand town */ diff --git a/train_gui.c b/train_gui.c index 479d0a0c4..a99170b68 100644 --- a/train_gui.c +++ b/train_gui.c @@ -515,7 +515,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e) EngineID sel_eng = bv->sel_engine; if (sel_eng != INVALID_ENGINE) { bv->rename_engine = sel_eng; - ShowQueryString(GetCustomEngineName(sel_eng), STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(GetCustomEngineName(sel_eng), STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w, CS_ALPHANUMERAL); } break; } @@ -1037,7 +1037,7 @@ static void TrainDetailsWndProc(Window *w, WindowEvent *e) case 2: /* name train */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); - ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); + ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL); break; case 6: /* inc serv interval */ mod = _ctrl_pressed? 5 : 10; @@ -342,11 +342,10 @@ struct Window { typedef struct querystr_d { StringID caption; - WindowClass wnd_class; - WindowNumber wnd_num; Textbuf text; const char *orig; CharSetFilter afilter; + bool handled; } querystr_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); |