Fix tooltip string parameters, change function signatures to match upstream

This commit is contained in:
Jonathan G Rennison
2023-11-17 17:26:57 +00:00
parent 9ceef09e9c
commit c76dc937e3
20 changed files with 96 additions and 110 deletions

View File

@@ -719,11 +719,10 @@ public:
if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false; if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false;
if (Group::IsValidID(this->sel_group)) { if (Group::IsValidID(this->sel_group)) {
uint64 params[1]; SetDParam(0, STR_REPLACE_REMOVE_WAGON_HELP);
params[0] = STR_REPLACE_REMOVE_WAGON_HELP; GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, close_cond, 1);
GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, 1, params, close_cond);
} else { } else {
GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_HELP, 0, nullptr, close_cond); GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_HELP, close_cond);
} }
return true; return true;
} }

View File

@@ -567,14 +567,14 @@ struct CompanyFinancesWindow : Window {
{ {
switch (widget) { switch (widget) {
case WID_CF_INCREASE_LOAN: { case WID_CF_INCREASE_LOAN: {
uint64 arg = STR_FINANCES_BORROW_TOOLTIP; SetDParam(0, STR_FINANCES_BORROW_TOOLTIP);
GuiShowTooltips(this, STR_FINANCES_BORROW_TOOLTIP_EXTRA, 1, &arg, close_cond); GuiShowTooltips(this, STR_FINANCES_BORROW_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }
case WID_CF_REPAY_LOAN: { case WID_CF_REPAY_LOAN: {
uint64 arg = STR_FINANCES_REPAY_TOOLTIP; SetDParam(0, STR_FINANCES_REPAY_TOOLTIP);
GuiShowTooltips(this, STR_FINANCES_REPAY_TOOLTIP_EXTRA, 1, &arg, close_cond); GuiShowTooltips(this, STR_FINANCES_REPAY_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }

View File

@@ -328,9 +328,8 @@ public:
case WID_DB_SHOW_ROADVEHS: case WID_DB_SHOW_ROADVEHS:
case WID_DB_SHOW_SHIPS: case WID_DB_SHOW_SHIPS:
case WID_DB_SHOW_PLANES: { case WID_DB_SHOW_PLANES: {
uint64 params[1]; SetDParam(0, STR_DEPARTURES_SHOW_TRAINS_TOOLTIP + (widget - WID_DB_SHOW_TRAINS));
params[0] = STR_DEPARTURES_SHOW_TRAINS_TOOLTIP + (widget - WID_DB_SHOW_TRAINS); GuiShowTooltips(this, STR_DEPARTURES_SHOW_TYPE_TOOLTIP_CTRL_SUFFIX, close_cond, 1);
GuiShowTooltips(this, STR_DEPARTURES_SHOW_TYPE_TOOLTIP_CTRL_SUFFIX, 1, params, close_cond);
return true; return true;
} }
default: default:

View File

@@ -876,9 +876,7 @@ struct DepotWindow : Window {
} }
/* Build tooltipstring */ /* Build tooltipstring */
static char details[1024]; std::string details;
details[0] = '\0';
char *pos = details;
for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
if (capacity[cargo_type] == 0) continue; if (capacity[cargo_type] == 0) continue;
@@ -887,14 +885,13 @@ struct DepotWindow : Window {
SetDParam(1, loaded[cargo_type]); // {CARGO} #2 SetDParam(1, loaded[cargo_type]); // {CARGO} #2
SetDParam(2, cargo_type); // {SHORTCARGO} #1 SetDParam(2, cargo_type); // {SHORTCARGO} #1
SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2 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 */ /* Show tooltip window */
uint64 args[2]; SetDParam(0, whole_chain ? num : v->engine_type);
args[0] = (whole_chain ? num : v->engine_type); SetDParamStr(1, std::move(details));
args[1] = (uint64)(size_t)details; GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, TCC_RIGHT_CLICK, 2);
GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
return true; return true;
} }
@@ -1239,7 +1236,7 @@ void ShowDepotTooltip(Window *w, const TileIndex tile)
if (totals.total_vehicle_count == 0) { if (totals.total_vehicle_count == 0) {
if (totals.free_wagon_count > 0) { if (totals.free_wagon_count > 0) {
SetDParam(0, totals.free_wagon_count); 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; return;
} }
@@ -1274,5 +1271,5 @@ void ShowDepotTooltip(Window *w, const TileIndex tile)
str = STR_DEPOT_VIEW_MIXED_CONTENTS_TOOLTIP; str = STR_DEPOT_VIEW_MIXED_CONTENTS_TOOLTIP;
} }
GuiShowTooltips(w, str, 0, nullptr, TCC_HOVER_VIEWPORT); GuiShowTooltips(w, str, TCC_HOVER_VIEWPORT);
} }

View File

@@ -3171,7 +3171,7 @@ struct IndustryCargoesWindow : public Window {
case CFT_INDUSTRY: case CFT_INDUSTRY:
if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES && (this->ind_cargo >= NUM_INDUSTRYTYPES || fieldxy.x != 2)) { 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; 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)) { if (cid != INVALID_CARGO && (this->ind_cargo < NUM_INDUSTRYTYPES || cid != this->ind_cargo - NUM_INDUSTRYTYPES)) {
const CargoSpec *csp = CargoSpec::Get(cid); const CargoSpec *csp = CargoSpec::Get(cid);
uint64 params[5]; SetDParam(0, csp->name);
params[0] = csp->name; GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, close_cond, 1);
GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, close_cond);
return true; return true;
} }
@@ -3351,6 +3350,6 @@ void ShowIndustryTooltip(Window *w, const TileIndex tile)
if (!msg.empty()) { if (!msg.empty()) {
_temp_special_strings[0] = std::move(msg); _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);
} }
} }

View File

@@ -586,11 +586,11 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
SetDParam(3, i->to_id); SetDParam(3, i->to_id);
SetDParam(4, link.Usage() * 100 / (link.capacity + 1)); SetDParam(4, link.Usage() * 100 / (link.capacity + 1));
SetDParamStr(5, buf); 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; return true;
} }
} }
GuiShowTooltips(this->window, STR_NULL, 0, nullptr, close_cond); GuiShowTooltips(this->window, STR_NULL, close_cond);
return false; 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 (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
if (this->IsWidgetDisabled(widget)) { 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 { } else {
uint64 params[2];
CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST); CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST);
params[0] = STR_LINKGRAPH_LEGEND_SELECT_COMPANIES; SetDParam(0, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES);
params[1] = cid; SetDParam(1, cid);
GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_COMPANY_TOOLTIP, 2, params, close_cond); GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_COMPANY_TOOLTIP, close_cond, 2);
} }
return true; return true;
} }
if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) { if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
const CargoSpec *cargo = _sorted_cargo_specs[widget - WID_LGL_CARGO_FIRST]; 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 true;
} }
return false; return false;

View File

@@ -718,7 +718,7 @@ struct TooltipsWindow : public Window
int viewport_virtual_top; ///< Owner viewport state: top int viewport_virtual_top; ///< Owner viewport state: top
bool delete_next_mouse_loop; ///< Delete window on the next mouse loop 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->parent = parent;
this->string_id = str; this->string_id = str;
@@ -829,17 +829,16 @@ struct TooltipsWindow : public Window
* Shows a tooltip * Shows a tooltip
* @param parent The window this tooltip is related to. * @param parent The window this tooltip is related to.
* @param str String to be displayed * @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 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); CloseWindowById(WC_TOOLTIPS, 0);
if (str == STR_NULL || !_cursor.in_window) return; 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) void QueryString::HandleEditBox(Window *w, int wid)

View File

@@ -1872,10 +1872,10 @@ public:
if (IsInsideMM(pt.x, player_icon_x, player_icon_x + d2.width)) { if (IsInsideMM(pt.x, player_icon_x, player_icon_x + d2.width)) {
if (index == this->player_self_index) { 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; return true;
} else if (index == this->player_host_index) { } 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; return true;
} }
} }
@@ -1883,7 +1883,7 @@ public:
ButtonCommon *button = this->GetButtonAtPoint(pt); ButtonCommon *button = this->GetButtonAtPoint(pt);
if (button == nullptr) return false; if (button == nullptr) return false;
GuiShowTooltips(this, button->tooltip, 0, nullptr, close_cond); GuiShowTooltips(this, button->tooltip, close_cond);
return true; return true;
}; };
} }

View File

@@ -3569,8 +3569,8 @@ public:
switch (widget) { switch (widget) {
case WID_O_SHARED_ORDER_LIST: { case WID_O_SHARED_ORDER_LIST: {
if (this->vehicle->owner == _local_company) { if (this->vehicle->owner == _local_company) {
uint64 args[] = { STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP }; SetDParam(0, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP);
GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, lengthof(args), args, close_cond); GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }
return false; return false;

View File

@@ -743,8 +743,8 @@ struct BuildRailToolbarWindow : Window {
virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
{ {
if (widget == WID_RAT_CONVERT_RAIL) { if (widget == WID_RAT_CONVERT_RAIL) {
uint64 args[] = { STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL }; SetDParam(0, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL);
GuiShowTooltips(this, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_EXTRA, lengthof(args), args, close_cond); GuiShowTooltips(this, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_EXTRA, close_cond, 1);
return true; return true;
} }
return false; return false;

View File

@@ -384,9 +384,8 @@ struct SchdispatchWindow : GeneralVehicleWindow {
switch (widget) { switch (widget) {
case WID_SCHDISPATCH_ADD: { case WID_SCHDISPATCH_ADD: {
if (_settings_time.time_in_minutes) { if (_settings_time.time_in_minutes) {
uint64 params[1]; SetDParam(0, STR_SCHDISPATCH_ADD_TOOLTIP);
params[0] = STR_SCHDISPATCH_ADD_TOOLTIP; GuiShowTooltips(this, STR_SCHDISPATCH_ADD_TOOLTIP_EXTRA, close_cond, 1);
GuiShowTooltips(this, STR_SCHDISPATCH_ADD_TOOLTIP_EXTRA, 1, params, close_cond);
return true; return true;
} }
break; break;
@@ -402,7 +401,7 @@ struct SchdispatchWindow : GeneralVehicleWindow {
add_suffix(STR_SCHDISPATCH_REMOVE_SCHEDULE_TOOLTIP); add_suffix(STR_SCHDISPATCH_REMOVE_SCHEDULE_TOOLTIP);
add_suffix(STR_SCHDISPATCH_DUPLICATE_SCHEDULE_TOOLTIP); add_suffix(STR_SCHDISPATCH_DUPLICATE_SCHEDULE_TOOLTIP);
add_suffix(STR_SCHDISPATCH_APPEND_VEHICLE_SCHEDULES_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; return true;
} }

View File

@@ -1540,8 +1540,9 @@ struct StationViewWindow : public Window {
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
{ {
if (widget == WID_SV_RENAME) { if (widget == WID_SV_RENAME) {
uint64 args[] = { STR_STATION_VIEW_RENAME_TOOLTIP, STR_BUTTON_DEFAULT }; SetDParam(0, STR_STATION_VIEW_RENAME_TOOLTIP);
GuiShowTooltips(this, STR_STATION_VIEW_RENAME_TOOLTIP_EXTRA, lengthof(args), args, close_cond); SetDParam(1, STR_BUTTON_DEFAULT);
GuiShowTooltips(this, STR_STATION_VIEW_RENAME_TOOLTIP_EXTRA, close_cond, 2);
return true; return true;
} }

View File

@@ -423,9 +423,7 @@ public:
} }
/* Build tooltipstring */ /* Build tooltipstring */
static char details[1024]; std::string details;
details[0] = '\0';
char *pos = details;
for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
if (capacity[cargo_type] == 0) continue; if (capacity[cargo_type] == 0) continue;
@@ -434,14 +432,13 @@ public:
SetDParam(1, loaded[cargo_type]); // {CARGO} #2 SetDParam(1, loaded[cargo_type]); // {CARGO} #2
SetDParam(2, cargo_type); // {SHORTCARGO} #1 SetDParam(2, cargo_type); // {SHORTCARGO} #1
SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2 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 */ /* Show tooltip window */
uint64 args[2]; SetDParam(0, whole_chain ? num : v->engine_type);
args[0] = (whole_chain ? num : v->engine_type); SetDParamStr(1, std::move(details));
args[1] = (uint64)(size_t)details; GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, TCC_RIGHT_CLICK, 2);
GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
return true; return true;
} }

View File

@@ -624,25 +624,25 @@ struct TimetableWindow : GeneralVehicleWindow {
{ {
switch (widget) { switch (widget) {
case WID_VT_CHANGE_TIME: { 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; return true;
} }
case WID_VT_CLEAR_TIME: { 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; return true;
} }
case WID_VT_CHANGE_SPEED: { 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; return true;
} }
case WID_VT_CLEAR_SPEED: { 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; return true;
} }
case WID_VT_SHARED_ORDER_LIST: { case WID_VT_SHARED_ORDER_LIST: {
if (this->vehicle->owner == _local_company) { if (this->vehicle->owner == _local_company) {
uint64 args[] = { STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP }; SetDParam(0, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP);
GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, lengthof(args), args, close_cond); GuiShowTooltips(this, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }
return false; return false;

View File

@@ -2729,20 +2729,20 @@ public:
{ {
switch (widget) { switch (widget) {
case TR_WIDGET_SHARE: { case TR_WIDGET_SHARE: {
uint64 arg = STR_TRACE_RESTRICT_SHARE_TOOLTIP; SetDParam(0, STR_TRACE_RESTRICT_SHARE_TOOLTIP);
GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, 1, &arg, close_cond); GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }
case TR_WIDGET_UNSHARE: { case TR_WIDGET_UNSHARE: {
uint64 arg = STR_TRACE_RESTRICT_UNSHARE_TOOLTIP; SetDParam(0, STR_TRACE_RESTRICT_UNSHARE_TOOLTIP);
GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, 1, &arg, close_cond); GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }
case TR_WIDGET_SHARE_ONTO: { case TR_WIDGET_SHARE_ONTO: {
uint64 arg = (this->base_share_plane == DPS_UNSHARE) ? STR_TRACE_RESTRICT_UNSHARE_TOOLTIP : STR_TRACE_RESTRICT_SHARE_TOOLTIP; 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, 1, &arg, close_cond); GuiShowTooltips(this, STR_TRACE_RESTRICT_SHARE_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }

View File

@@ -4127,10 +4127,10 @@ public:
if (widget == WID_VV_GOTO_DEPOT && _settings_client.gui.hover_delay_ms == 0) { if (widget == WID_VV_GOTO_DEPOT && _settings_client.gui.hover_delay_ms == 0) {
const Vehicle *v = Vehicle::Get(this->window_number); const Vehicle *v = Vehicle::Get(this->window_number);
if (_settings_client.gui.show_depot_sell_gui && v->current_order.IsType(OT_GOTO_DEPOT)) { 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 { } else {
uint64 arg = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type; SetDParam(0, 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); GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_TOOLTIP_SHIFT, TCC_RIGHT_CLICK, 1);
} }
} }
return false; return false;
@@ -4141,17 +4141,17 @@ public:
if (widget == WID_VV_GOTO_DEPOT) { if (widget == WID_VV_GOTO_DEPOT) {
const Vehicle *v = Vehicle::Get(this->window_number); const Vehicle *v = Vehicle::Get(this->window_number);
if (_settings_client.gui.show_depot_sell_gui && v->current_order.IsType(OT_GOTO_DEPOT)) { 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 { } else {
uint64 arg = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type; SetDParam(0, STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->type);
GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_TOOLTIP_SHIFT, 1, &arg, close_cond); GuiShowTooltips(this, STR_VEHICLE_VIEW_SEND_TO_DEPOT_TOOLTIP_SHIFT, close_cond, 1);
} }
return true; return true;
} }
if (widget == WID_VV_LOCATION) { if (widget == WID_VV_LOCATION) {
const Vehicle *v = Vehicle::Get(this->window_number); const Vehicle *v = Vehicle::Get(this->window_number);
uint64 args[] = { STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->type }; SetDParam(0, STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->type);
GuiShowTooltips(this, STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP_EXTRA, lengthof(args), args, close_cond); GuiShowTooltips(this, STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP_EXTRA, close_cond, 1);
return true; return true;
} }
return false; return false;

View File

@@ -5296,10 +5296,10 @@ void UpdateTileSelection()
* @param params (optional) up to 5 pieces of additional information that may be added to a tooltip * @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. * @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; 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() static void HideMeasurementTooltips()
@@ -5380,7 +5380,8 @@ void VpSetPresizeRange(TileIndex from, TileIndex to)
/* show measurement only if there is any length to speak of */ /* show measurement only if there is any length to speak of */
if (distance > 1) { if (distance > 1) {
ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance); SetDParam(0, distance);
ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1);
} else { } else {
HideMeasurementTooltips(); HideMeasurementTooltips();
} }
@@ -5552,8 +5553,7 @@ static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, Ti
if (_settings_client.gui.measure_tooltip) { if (_settings_client.gui.measure_tooltip) {
uint distance = DistanceManhattan(start_tile, end_tile) + 1; uint distance = DistanceManhattan(start_tile, end_tile) + 1;
byte index = 0; uint index = 0;
uint64 params[2];
if (show_single_tile_length || distance != 1) { if (show_single_tile_length || distance != 1) {
int heightdiff = CalcHeightdiff(style, distance, start_tile, end_tile); 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); distance = CeilDiv(distance, 2);
} }
params[index++] = distance; SetDParam(index++, distance);
if (heightdiff != 0) params[index++] = heightdiff; 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); TileIndex t1 = TileVirtXY(x, y);
uint dx = Delta(TileX(t0), TileX(t1)) + 1; uint dx = Delta(TileX(t0), TileX(t1)) + 1;
uint dy = Delta(TileY(t0), TileY(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 /* 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 */ * 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) { if (dx != 1 || dy != 1) {
heightdiff = CalcHeightdiff(style, 0, t0, t1); heightdiff = CalcHeightdiff(style, 0, t0, t1);
params[index++] = DistanceManhattan(t0, t1); SetDParam(0, DistanceManhattan(t0, t1));
params[index++] = IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy)); // Avoid overflow in DistanceSquare SetDParam(1, IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy))); // Avoid overflow in DistanceSquare
} else { } else {
index += 2; SetDParam(0, 0);
SetDParam(1, 0);
} }
params[index++] = DistanceFromEdge(t1); SetDParam(2, DistanceFromEdge(t1));
params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP; SetDParam(3, GetTileMaxZ(t1) * TILE_HEIGHT_STEP);
params[index++] = heightdiff; SetDParam(4, heightdiff);
/* Always show the measurement tooltip */ /* 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; break;
} }
@@ -6171,8 +6169,7 @@ calc_heightdiff_single_direction:;
TileIndex t1 = TileVirtXY(x, y); TileIndex t1 = TileVirtXY(x, y);
uint dx = Delta(TileX(t0), TileX(t1)) + 1; uint dx = Delta(TileX(t0), TileX(t1)) + 1;
uint dy = Delta(TileY(t0), TileY(t1)) + 1; uint dy = Delta(TileY(t0), TileY(t1)) + 1;
byte index = 0; uint index = 0;
uint64 params[3];
/* If dragging an area (eg dynamite tool) and it is actually a single /* 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 */ * 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) { if (dx != 1 || dy != 1) {
int heightdiff = CalcHeightdiff(style, 0, t0, t1); int heightdiff = CalcHeightdiff(style, 0, t0, t1);
params[index++] = dx - (style & HT_POINT ? 1 : 0); SetDParam(index++, dx - (style & HT_POINT ? 1 : 0));
params[index++] = dy - (style & HT_POINT ? 1 : 0); SetDParam(index++, dy - (style & HT_POINT ? 1 : 0));
if (heightdiff != 0) params[index++] = heightdiff; if (heightdiff != 0) SetDParam(index++, heightdiff);
} }
ShowMeasurementTooltips(measure_strings_area[index], index, params); ShowMeasurementTooltips(measure_strings_area[index], index);
} }
break; break;

View File

@@ -269,7 +269,7 @@ void ShowTownNameTooltip(Window *w, const TileIndex tile)
} else { } else {
tooltip_string = STR_JUST_STRING2; 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) 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; (_settings_client.gui.waypoint_viewport_tooltip_name == WTNM_ON_IF_HIDDEN && HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES))) return;
SetDParam(0, GetStationIndex(tile)); 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) void ShowStationViewportTooltip(Window *w, const TileIndex tile)
@@ -314,7 +314,7 @@ void ShowStationViewportTooltip(Window *w, const TileIndex tile)
if (!msg.empty()) { if (!msg.empty()) {
_temp_special_strings[0] = std::move(msg); _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);
} }
} }

View File

@@ -840,7 +840,7 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
/* Right-click close is enabled, but excluding sticky windows. */ /* Right-click close is enabled, but excluding sticky windows. */
w->Close(); w->Close();
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->tool_tip != 0) { } 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 */ /* Show the tooltip if there is any */
if (!w->OnTooltip(pt, wid->index, TCC_HOVER) && wid->tool_tip != 0) { 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; return;
} }

View File

@@ -985,7 +985,7 @@ Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_e
void RelocateAllWindows(int neww, int newh); 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 */ /* widget.cpp */
int GetWidgetFromPos(const Window *w, int x, int y); int GetWidgetFromPos(const Window *w, int x, int y);