From c76dc937e3db8c5faed81756e3e5b561ba8c80b2 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 17 Nov 2023 17:26:57 +0000 Subject: [PATCH] Fix tooltip string parameters, change function signatures to match upstream --- src/autoreplace_gui.cpp | 7 +++-- src/company_gui.cpp | 8 +++--- src/departures_gui.cpp | 5 ++-- src/depot_gui.cpp | 17 +++++------- src/industry_gui.cpp | 9 +++---- src/linkgraph/linkgraph_gui.cpp | 15 +++++------ src/misc_gui.cpp | 9 +++---- src/network/network_gui.cpp | 6 ++--- src/order_gui.cpp | 4 +-- src/rail_gui.cpp | 4 +-- src/schdispatch_gui.cpp | 7 +++-- src/station_gui.cpp | 5 ++-- src/tbtr_template_gui_create.cpp | 13 ++++----- src/timetable_gui.cpp | 12 ++++----- src/tracerestrict_gui.cpp | 12 ++++----- src/vehicle_gui.cpp | 16 ++++++------ src/viewport.cpp | 45 +++++++++++++++----------------- src/viewport_gui.cpp | 6 ++--- src/window.cpp | 4 +-- src/window_gui.h | 2 +- 20 files changed, 96 insertions(+), 110 deletions(-) diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 1974b92bcf..dfdf6e35bb 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -719,11 +719,10 @@ public: if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false; if (Group::IsValidID(this->sel_group)) { - uint64 params[1]; - params[0] = STR_REPLACE_REMOVE_WAGON_HELP; - GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, 1, params, close_cond); + SetDParam(0, STR_REPLACE_REMOVE_WAGON_HELP); + GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, close_cond, 1); } else { - GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_HELP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_HELP, close_cond); } return true; } diff --git a/src/company_gui.cpp b/src/company_gui.cpp index a253c84bd8..a9d6595f4f 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -567,14 +567,14 @@ struct CompanyFinancesWindow : Window { { switch (widget) { case WID_CF_INCREASE_LOAN: { - uint64 arg = STR_FINANCES_BORROW_TOOLTIP; - GuiShowTooltips(this, STR_FINANCES_BORROW_TOOLTIP_EXTRA, 1, &arg, close_cond); + SetDParam(0, STR_FINANCES_BORROW_TOOLTIP); + GuiShowTooltips(this, STR_FINANCES_BORROW_TOOLTIP_EXTRA, close_cond, 1); return true; } case WID_CF_REPAY_LOAN: { - uint64 arg = STR_FINANCES_REPAY_TOOLTIP; - GuiShowTooltips(this, STR_FINANCES_REPAY_TOOLTIP_EXTRA, 1, &arg, close_cond); + SetDParam(0, STR_FINANCES_REPAY_TOOLTIP); + GuiShowTooltips(this, STR_FINANCES_REPAY_TOOLTIP_EXTRA, close_cond, 1); return true; } diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 419894059a..a7edef3101 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -328,9 +328,8 @@ public: case WID_DB_SHOW_ROADVEHS: case WID_DB_SHOW_SHIPS: case WID_DB_SHOW_PLANES: { - uint64 params[1]; - params[0] = STR_DEPARTURES_SHOW_TRAINS_TOOLTIP + (widget - WID_DB_SHOW_TRAINS); - GuiShowTooltips(this, STR_DEPARTURES_SHOW_TYPE_TOOLTIP_CTRL_SUFFIX, 1, params, close_cond); + SetDParam(0, STR_DEPARTURES_SHOW_TRAINS_TOOLTIP + (widget - WID_DB_SHOW_TRAINS)); + GuiShowTooltips(this, STR_DEPARTURES_SHOW_TYPE_TOOLTIP_CTRL_SUFFIX, close_cond, 1); return true; } default: diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 762260d03d..24c822fc72 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -876,9 +876,7 @@ struct DepotWindow : Window { } /* Build tooltipstring */ - static char details[1024]; - details[0] = '\0'; - char *pos = details; + std::string details; for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { if (capacity[cargo_type] == 0) continue; @@ -887,14 +885,13 @@ struct DepotWindow : Window { SetDParam(1, loaded[cargo_type]); // {CARGO} #2 SetDParam(2, cargo_type); // {SHORTCARGO} #1 SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2 - pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, lastof(details)); + details = GetString(STR_DEPOT_VEHICLE_TOOLTIP_CARGO); } /* Show tooltip window */ - uint64 args[2]; - args[0] = (whole_chain ? num : v->engine_type); - args[1] = (uint64)(size_t)details; - GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK); + SetDParam(0, whole_chain ? num : v->engine_type); + SetDParamStr(1, std::move(details)); + GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, TCC_RIGHT_CLICK, 2); return true; } @@ -1239,7 +1236,7 @@ void ShowDepotTooltip(Window *w, const TileIndex tile) if (totals.total_vehicle_count == 0) { if (totals.free_wagon_count > 0) { SetDParam(0, totals.free_wagon_count); - GuiShowTooltips(w, STR_DEPOT_VIEW_FREE_WAGONS_TOOLTIP, 0, nullptr, TCC_HOVER_VIEWPORT); + GuiShowTooltips(w, STR_DEPOT_VIEW_FREE_WAGONS_TOOLTIP, TCC_HOVER_VIEWPORT); } return; } @@ -1274,5 +1271,5 @@ void ShowDepotTooltip(Window *w, const TileIndex tile) str = STR_DEPOT_VIEW_MIXED_CONTENTS_TOOLTIP; } - GuiShowTooltips(w, str, 0, nullptr, TCC_HOVER_VIEWPORT); + GuiShowTooltips(w, str, TCC_HOVER_VIEWPORT); } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 7c18eb62f2..b33889235d 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -3171,7 +3171,7 @@ struct IndustryCargoesWindow : public Window { case CFT_INDUSTRY: if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES && (this->ind_cargo >= NUM_INDUSTRYTYPES || fieldxy.x != 2)) { - GuiShowTooltips(this, STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, close_cond); } return true; @@ -3180,9 +3180,8 @@ struct IndustryCargoesWindow : public Window { } if (cid != INVALID_CARGO && (this->ind_cargo < NUM_INDUSTRYTYPES || cid != this->ind_cargo - NUM_INDUSTRYTYPES)) { const CargoSpec *csp = CargoSpec::Get(cid); - uint64 params[5]; - params[0] = csp->name; - GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, close_cond); + SetDParam(0, csp->name); + GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, close_cond, 1); return true; } @@ -3351,6 +3350,6 @@ void ShowIndustryTooltip(Window *w, const TileIndex tile) if (!msg.empty()) { _temp_special_strings[0] = std::move(msg); - GuiShowTooltips(w, SPECSTR_TEMP_START, 0, nullptr, TCC_HOVER_VIEWPORT); + GuiShowTooltips(w, SPECSTR_TEMP_START, TCC_HOVER_VIEWPORT); } } diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index ad668b0cee..ac918a6345 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -586,11 +586,11 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) SetDParam(3, i->to_id); SetDParam(4, link.Usage() * 100 / (link.capacity + 1)); SetDParamStr(5, buf); - GuiShowTooltips(this->window, STR_LINKGRAPH_STATS_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this->window, STR_LINKGRAPH_STATS_TOOLTIP, close_cond); return true; } } - GuiShowTooltips(this->window, STR_NULL, 0, nullptr, close_cond); + GuiShowTooltips(this->window, STR_NULL, close_cond); return false; } @@ -823,19 +823,18 @@ bool LinkGraphLegendWindow::OnTooltip(Point pt, int widget, TooltipCloseConditio { if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { if (this->IsWidgetDisabled(widget)) { - GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES, close_cond); } else { - uint64 params[2]; CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST); - params[0] = STR_LINKGRAPH_LEGEND_SELECT_COMPANIES; - params[1] = cid; - GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_COMPANY_TOOLTIP, 2, params, close_cond); + SetDParam(0, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES); + SetDParam(1, cid); + GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_COMPANY_TOOLTIP, close_cond, 2); } return true; } if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) { const CargoSpec *cargo = _sorted_cargo_specs[widget - WID_LGL_CARGO_FIRST]; - GuiShowTooltips(this, cargo->name, 0, nullptr, close_cond); + GuiShowTooltips(this, cargo->name, close_cond); return true; } return false; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 2116450dcc..e626d5c720 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -718,7 +718,7 @@ struct TooltipsWindow : public Window int viewport_virtual_top; ///< Owner viewport state: top bool delete_next_mouse_loop; ///< Delete window on the next mouse loop - TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc) + TooltipsWindow(Window *parent, StringID str, uint paramcount, TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc) { this->parent = parent; this->string_id = str; @@ -829,17 +829,16 @@ struct TooltipsWindow : public Window * Shows a tooltip * @param parent The window this tooltip is related to. * @param str String to be displayed + * @param close_tooltip the condition under which the tooltip closes * @param paramcount number of params to deal with - * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip - * @param close_tooltip when the left (true) or right (false) mouse button is released */ -void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) +void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount) { CloseWindowById(WC_TOOLTIPS, 0); if (str == STR_NULL || !_cursor.in_window) return; - new TooltipsWindow(parent, str, paramcount, params, close_tooltip); + new TooltipsWindow(parent, str, paramcount, close_tooltip); } void QueryString::HandleEditBox(Window *w, int wid) diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 3c2ac9b114..875b4d02cd 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1872,10 +1872,10 @@ public: if (IsInsideMM(pt.x, player_icon_x, player_icon_x + d2.width)) { if (index == this->player_self_index) { - GuiShowTooltips(this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP, close_cond); return true; } else if (index == this->player_host_index) { - GuiShowTooltips(this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP, close_cond); return true; } } @@ -1883,7 +1883,7 @@ public: ButtonCommon *button = this->GetButtonAtPoint(pt); if (button == nullptr) return false; - GuiShowTooltips(this, button->tooltip, 0, nullptr, close_cond); + GuiShowTooltips(this, button->tooltip, close_cond); return true; }; } diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 7b74abf805..883732299f 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -3569,8 +3569,8 @@ public: switch (widget) { case WID_O_SHARED_ORDER_LIST: { if (this->vehicle->owner == _local_company) { - uint64 args[] = { STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP }; - GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, lengthof(args), args, close_cond); + SetDParam(0, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP); + GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, close_cond, 1); return true; } return false; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 912ba4b8a4..9a74276e20 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -743,8 +743,8 @@ struct BuildRailToolbarWindow : Window { virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override { if (widget == WID_RAT_CONVERT_RAIL) { - uint64 args[] = { STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL }; - GuiShowTooltips(this, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_EXTRA, lengthof(args), args, close_cond); + SetDParam(0, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL); + GuiShowTooltips(this, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_EXTRA, close_cond, 1); return true; } return false; diff --git a/src/schdispatch_gui.cpp b/src/schdispatch_gui.cpp index c4296f5361..da1fb960b0 100644 --- a/src/schdispatch_gui.cpp +++ b/src/schdispatch_gui.cpp @@ -384,9 +384,8 @@ struct SchdispatchWindow : GeneralVehicleWindow { switch (widget) { case WID_SCHDISPATCH_ADD: { if (_settings_time.time_in_minutes) { - uint64 params[1]; - params[0] = STR_SCHDISPATCH_ADD_TOOLTIP; - GuiShowTooltips(this, STR_SCHDISPATCH_ADD_TOOLTIP_EXTRA, 1, params, close_cond); + SetDParam(0, STR_SCHDISPATCH_ADD_TOOLTIP); + GuiShowTooltips(this, STR_SCHDISPATCH_ADD_TOOLTIP_EXTRA, close_cond, 1); return true; } break; @@ -402,7 +401,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { add_suffix(STR_SCHDISPATCH_REMOVE_SCHEDULE_TOOLTIP); add_suffix(STR_SCHDISPATCH_DUPLICATE_SCHEDULE_TOOLTIP); add_suffix(STR_SCHDISPATCH_APPEND_VEHICLE_SCHEDULES_TOOLTIP); - GuiShowTooltips(this, SPECSTR_TEMP_START, 0, nullptr, close_cond); + GuiShowTooltips(this, SPECSTR_TEMP_START, close_cond); return true; } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 7303c699a5..f0e0d5dc73 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1540,8 +1540,9 @@ struct StationViewWindow : public Window { bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override { if (widget == WID_SV_RENAME) { - uint64 args[] = { STR_STATION_VIEW_RENAME_TOOLTIP, STR_BUTTON_DEFAULT }; - GuiShowTooltips(this, STR_STATION_VIEW_RENAME_TOOLTIP_EXTRA, lengthof(args), args, close_cond); + SetDParam(0, STR_STATION_VIEW_RENAME_TOOLTIP); + SetDParam(1, STR_BUTTON_DEFAULT); + GuiShowTooltips(this, STR_STATION_VIEW_RENAME_TOOLTIP_EXTRA, close_cond, 2); return true; } diff --git a/src/tbtr_template_gui_create.cpp b/src/tbtr_template_gui_create.cpp index 6dd6119ba7..c51386e0de 100644 --- a/src/tbtr_template_gui_create.cpp +++ b/src/tbtr_template_gui_create.cpp @@ -423,9 +423,7 @@ public: } /* Build tooltipstring */ - static char details[1024]; - details[0] = '\0'; - char *pos = details; + std::string details; for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { if (capacity[cargo_type] == 0) continue; @@ -434,14 +432,13 @@ public: SetDParam(1, loaded[cargo_type]); // {CARGO} #2 SetDParam(2, cargo_type); // {SHORTCARGO} #1 SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2 - pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, lastof(details)); + details = GetString(STR_DEPOT_VEHICLE_TOOLTIP_CARGO); } /* Show tooltip window */ - uint64 args[2]; - args[0] = (whole_chain ? num : v->engine_type); - args[1] = (uint64)(size_t)details; - GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK); + SetDParam(0, whole_chain ? num : v->engine_type); + SetDParamStr(1, std::move(details)); + GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, TCC_RIGHT_CLICK, 2); return true; } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 3db35ca2ab..10aa4cc7a1 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -624,25 +624,25 @@ struct TimetableWindow : GeneralVehicleWindow { { switch (widget) { case WID_VT_CHANGE_TIME: { - GuiShowTooltips(this, STR_TIMETABLE_WAIT_TIME_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_TIMETABLE_WAIT_TIME_TOOLTIP, close_cond); return true; } case WID_VT_CLEAR_TIME: { - GuiShowTooltips(this, STR_TIMETABLE_CLEAR_TIME_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_TIMETABLE_CLEAR_TIME_TOOLTIP, close_cond); return true; } case WID_VT_CHANGE_SPEED: { - GuiShowTooltips(this, STR_TIMETABLE_CHANGE_SPEED_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_TIMETABLE_CHANGE_SPEED_TOOLTIP, close_cond); return true; } case WID_VT_CLEAR_SPEED: { - GuiShowTooltips(this, STR_TIMETABLE_CLEAR_SPEED_TOOLTIP, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_TIMETABLE_CLEAR_SPEED_TOOLTIP, close_cond); return true; } case WID_VT_SHARED_ORDER_LIST: { if (this->vehicle->owner == _local_company) { - uint64 args[] = { STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP }; - GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, lengthof(args), args, close_cond); + SetDParam(0, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP); + GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, close_cond, 1); return true; } return false; diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 696fa9d8f9..ef3b658c7d 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -2729,20 +2729,20 @@ public: { switch (widget) { case TR_WIDGET_SHARE: { - uint64 arg = STR_TRACE_RESTRICT_SHARE_TOOLTIP; - GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, 1, &arg, close_cond); + SetDParam(0, STR_TRACE_RESTRICT_SHARE_TOOLTIP); + GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, close_cond, 1); return true; } case TR_WIDGET_UNSHARE: { - uint64 arg = STR_TRACE_RESTRICT_UNSHARE_TOOLTIP; - GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, 1, &arg, close_cond); + SetDParam(0, STR_TRACE_RESTRICT_UNSHARE_TOOLTIP); + GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, close_cond, 1); return true; } case TR_WIDGET_SHARE_ONTO: { - uint64 arg = (this->base_share_plane == DPS_UNSHARE) ? STR_TRACE_RESTRICT_UNSHARE_TOOLTIP : STR_TRACE_RESTRICT_SHARE_TOOLTIP; - GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, 1, &arg, close_cond); + SetDParam(0, (this->base_share_plane == DPS_UNSHARE) ? STR_TRACE_RESTRICT_UNSHARE_TOOLTIP : STR_TRACE_RESTRICT_SHARE_TOOLTIP); + GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, close_cond, 1); return true; } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 6babc8e5cc..84c1598645 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -4127,10 +4127,10 @@ public: if (widget == WID_VV_GOTO_DEPOT && _settings_client.gui.hover_delay_ms == 0) { const Vehicle *v = Vehicle::Get(this->window_number); if (_settings_client.gui.show_depot_sell_gui && v->current_order.IsType(OT_GOTO_DEPOT)) { - GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_MENU, 0, nullptr, TCC_RIGHT_CLICK); + GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_MENU, TCC_RIGHT_CLICK); } else { - uint64 arg = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type; - GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_TOOLTIP_SHIFT, 1, &arg, TCC_RIGHT_CLICK); + SetDParam(0, STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type); + GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_TOOLTIP_SHIFT, TCC_RIGHT_CLICK, 1); } } return false; @@ -4141,17 +4141,17 @@ public: if (widget == WID_VV_GOTO_DEPOT) { const Vehicle *v = Vehicle::Get(this->window_number); if (_settings_client.gui.show_depot_sell_gui && v->current_order.IsType(OT_GOTO_DEPOT)) { - GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_MENU, 0, nullptr, close_cond); + GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_MENU, close_cond); } else { - uint64 arg = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type; - GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_TOOLTIP_SHIFT, 1, &arg, close_cond); + SetDParam(0, STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type); + GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_TOOLTIP_SHIFT, close_cond, 1); } return true; } if (widget == WID_VV_LOCATION) { const Vehicle *v = Vehicle::Get(this->window_number); - uint64 args[] = { STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->type }; - GuiShowTooltips(this, STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP_EXTRA, lengthof(args), args, close_cond); + SetDParam(0, STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->type); + GuiShowTooltips(this, STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP_EXTRA, close_cond, 1); return true; } return false; diff --git a/src/viewport.cpp b/src/viewport.cpp index cbd6bdd6e9..37a97bdd96 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -5296,10 +5296,10 @@ void UpdateTileSelection() * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip * @param close_cond Condition for closing this tooltip. */ -static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_EXIT_VIEWPORT) +static inline void ShowMeasurementTooltips(StringID str, uint paramcount, TooltipCloseCondition close_cond = TCC_EXIT_VIEWPORT) { if (!_settings_client.gui.measure_tooltip) return; - GuiShowTooltips(_thd.GetCallbackWnd(), str, paramcount, params, close_cond); + GuiShowTooltips(_thd.GetCallbackWnd(), str, close_cond, paramcount); } static void HideMeasurementTooltips() @@ -5380,7 +5380,8 @@ void VpSetPresizeRange(TileIndex from, TileIndex to) /* show measurement only if there is any length to speak of */ if (distance > 1) { - ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance); + SetDParam(0, distance); + ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1); } else { HideMeasurementTooltips(); } @@ -5552,8 +5553,7 @@ static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, Ti if (_settings_client.gui.measure_tooltip) { uint distance = DistanceManhattan(start_tile, end_tile) + 1; - byte index = 0; - uint64 params[2]; + uint index = 0; if (show_single_tile_length || distance != 1) { int heightdiff = CalcHeightdiff(style, distance, start_tile, end_tile); @@ -5564,11 +5564,11 @@ static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, Ti distance = CeilDiv(distance, 2); } - params[index++] = distance; - if (heightdiff != 0) params[index++] = heightdiff; + SetDParam(index++, distance); + if (heightdiff != 0) SetDParam(index++, heightdiff); } - ShowMeasurementTooltips(measure_strings_length[index], index, params, close_cond); + ShowMeasurementTooltips(measure_strings_length[index], index, close_cond); } } @@ -6122,9 +6122,6 @@ calc_heightdiff_single_direction:; TileIndex t1 = TileVirtXY(x, y); uint dx = Delta(TileX(t0), TileX(t1)) + 1; uint dy = Delta(TileY(t0), TileY(t1)) + 1; - byte index = 0; - uint64 params[5]; - memset( params, 0, sizeof( params ) ); /* If dragging an area (eg dynamite tool) and it is actually a single * row/column, change the type to 'line' to get proper calculation for height */ @@ -6141,17 +6138,18 @@ calc_heightdiff_single_direction:; if (dx != 1 || dy != 1) { heightdiff = CalcHeightdiff(style, 0, t0, t1); - params[index++] = DistanceManhattan(t0, t1); - params[index++] = IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy)); // Avoid overflow in DistanceSquare + SetDParam(0, DistanceManhattan(t0, t1)); + SetDParam(1, IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy))); // Avoid overflow in DistanceSquare } else { - index += 2; + SetDParam(0, 0); + SetDParam(1, 0); } - params[index++] = DistanceFromEdge(t1); - params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP; - params[index++] = heightdiff; + SetDParam(2, DistanceFromEdge(t1)); + SetDParam(3, GetTileMaxZ(t1) * TILE_HEIGHT_STEP); + SetDParam(4, heightdiff); /* Always show the measurement tooltip */ - GuiShowTooltips(_thd.GetCallbackWnd(), STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_EXIT_VIEWPORT); + GuiShowTooltips(_thd.GetCallbackWnd(), STR_MEASURE_DIST_HEIGHTDIFF, TCC_EXIT_VIEWPORT, 5); break; } @@ -6171,8 +6169,7 @@ calc_heightdiff_single_direction:; TileIndex t1 = TileVirtXY(x, y); uint dx = Delta(TileX(t0), TileX(t1)) + 1; uint dy = Delta(TileY(t0), TileY(t1)) + 1; - byte index = 0; - uint64 params[3]; + uint index = 0; /* If dragging an area (eg dynamite tool) and it is actually a single * row/column, change the type to 'line' to get proper calculation for height */ @@ -6217,12 +6214,12 @@ calc_heightdiff_single_direction:; if (dx != 1 || dy != 1) { int heightdiff = CalcHeightdiff(style, 0, t0, t1); - params[index++] = dx - (style & HT_POINT ? 1 : 0); - params[index++] = dy - (style & HT_POINT ? 1 : 0); - if (heightdiff != 0) params[index++] = heightdiff; + SetDParam(index++, dx - (style & HT_POINT ? 1 : 0)); + SetDParam(index++, dy - (style & HT_POINT ? 1 : 0)); + if (heightdiff != 0) SetDParam(index++, heightdiff); } - ShowMeasurementTooltips(measure_strings_area[index], index, params); + ShowMeasurementTooltips(measure_strings_area[index], index); } break; diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 28a6312532..ac5b0012e5 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -269,7 +269,7 @@ void ShowTownNameTooltip(Window *w, const TileIndex tile) } else { tooltip_string = STR_JUST_STRING2; } - GuiShowTooltips(w, tooltip_string, 0, nullptr, TCC_HOVER_VIEWPORT); + GuiShowTooltips(w, tooltip_string, TCC_HOVER_VIEWPORT); } void ShowWaypointViewportTooltip(Window *w, const TileIndex tile) @@ -278,7 +278,7 @@ void ShowWaypointViewportTooltip(Window *w, const TileIndex tile) (_settings_client.gui.waypoint_viewport_tooltip_name == WTNM_ON_IF_HIDDEN && HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES))) return; SetDParam(0, GetStationIndex(tile)); - GuiShowTooltips(w, STR_WAYPOINT_NAME, 0, nullptr, TCC_HOVER_VIEWPORT); + GuiShowTooltips(w, STR_WAYPOINT_NAME, TCC_HOVER_VIEWPORT); } void ShowStationViewportTooltip(Window *w, const TileIndex tile) @@ -314,7 +314,7 @@ void ShowStationViewportTooltip(Window *w, const TileIndex tile) if (!msg.empty()) { _temp_special_strings[0] = std::move(msg); - GuiShowTooltips(w, SPECSTR_TEMP_START, 0, nullptr, TCC_HOVER_VIEWPORT); + GuiShowTooltips(w, SPECSTR_TEMP_START, TCC_HOVER_VIEWPORT); } } diff --git a/src/window.cpp b/src/window.cpp index 39fff1bf13..390269a316 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -840,7 +840,7 @@ static void DispatchRightClickEvent(Window *w, int x, int y) /* Right-click close is enabled, but excluding sticky windows. */ w->Close(); } else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->tool_tip != 0) { - GuiShowTooltips(w, wid->tool_tip, 0, nullptr, TCC_RIGHT_CLICK); + GuiShowTooltips(w, wid->tool_tip, TCC_RIGHT_CLICK); } } @@ -861,7 +861,7 @@ static void DispatchHoverEvent(Window *w, int x, int y) /* Show the tooltip if there is any */ if (!w->OnTooltip(pt, wid->index, TCC_HOVER) && wid->tool_tip != 0) { - GuiShowTooltips(w, wid->tool_tip); + GuiShowTooltips(w, wid->tool_tip, TCC_HOVER); return; } diff --git a/src/window_gui.h b/src/window_gui.h index d75202fde5..4d9f4932a2 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -985,7 +985,7 @@ Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_e void RelocateAllWindows(int neww, int newh); -void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = nullptr, TooltipCloseCondition close_tooltip = TCC_HOVER); +void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount = 0); /* widget.cpp */ int GetWidgetFromPos(const Window *w, int x, int y);