mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r20121) -Add: OnHover method for windows.
This commit is contained in:
parent
10fbb87823
commit
9cf9bb9b92
@ -558,6 +558,7 @@ struct DepotWindow : Window {
|
|||||||
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
|
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
|
||||||
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
|
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
|
||||||
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
|
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
|
||||||
|
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
@ -843,13 +844,9 @@ struct DepotWindow : Window {
|
|||||||
args[0] = (whole_chain ? num : v->engine_type);
|
args[0] = (whole_chain ? num : v->engine_type);
|
||||||
args[1] = (uint64)(size_t)details;
|
args[1] = (uint64)(size_t)details;
|
||||||
GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
|
GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
|
||||||
} else {
|
|
||||||
/* Show tooltip help */
|
|
||||||
GuiShowTooltips(STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type, TCC_RIGHT_CLICK);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||||
{
|
{
|
||||||
const Vehicle *v = CheckMouseOverVehicle();
|
const Vehicle *v = CheckMouseOverVehicle();
|
||||||
|
@ -409,6 +409,12 @@ static void DispatchHoverEvent(Window *w, int x, int y)
|
|||||||
GuiShowTooltips(wid->tool_tip);
|
GuiShowTooltips(wid->tool_tip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Widget has no index, so the window is not interested in it. */
|
||||||
|
if (wid->index < 0) return;
|
||||||
|
|
||||||
|
Point pt = { x, y };
|
||||||
|
w->OnHover(pt, wid->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -657,6 +657,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void OnRightClick(Point pt, int widget) {}
|
virtual void OnRightClick(Point pt, int widget) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mouse is hovering over a widget in the window, perform an action for it, like opening a custom tooltip.
|
||||||
|
* @param pt The point where the mouse is hovering.
|
||||||
|
* @param widget The widget where the mouse is hovering.
|
||||||
|
*/
|
||||||
|
virtual void OnHover(Point pt, int widget) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An 'object' is being dragged at the provided position, highlight the target if possible.
|
* An 'object' is being dragged at the provided position, highlight the target if possible.
|
||||||
* @param pt The point inside the window that the mouse hovers over.
|
* @param pt The point inside the window that the mouse hovers over.
|
||||||
|
Loading…
Reference in New Issue
Block a user