Refit cargo window. More...
Public Member Functions | |
void | BuildRefitList () |
Collects all (cargo, subcargo) refit options of a vehicle chain. | |
RefitOption * | GetRefitOption () |
Gets the RefitOption placed in the selected index. | |
RefitWindow (const WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) | |
virtual void | OnInit () |
Notification that the nested widget tree gets initialized. | |
virtual void | OnPaint () |
The window must be repainted. | |
virtual void | UpdateWidgetSize (int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
Update size and resize step of a widget in the window. | |
virtual void | SetStringParameters (int widget) const |
Initialize string parameters for a widget. | |
StringID | GetCapacityString (RefitOption *option) const |
Gets the StringID to use for displaying capacity. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
virtual void | OnInvalidateData (int data=0, bool gui_scope=true) |
Some data on this window has become invalid. | |
int | GetClickPosition (int click_x) |
void | SetSelectedVehicles (int drag_x) |
virtual void | OnClick (Point pt, int widget, int click_count) |
A click with the left mouse button has been made on the window. | |
virtual void | OnMouseDrag (Point pt, int widget) |
An 'object' is being dragged at the provided position, highlight the target if possible. | |
virtual void | OnDragDrop (Point pt, int widget) |
A dragged 'object' has been released. | |
virtual void | OnResize () |
Called after the window got resized. | |
Data Fields | |
int | sel |
Index in refit options, -1 if nothing is selected. | |
RefitOption * | cargo |
Refit option selected by sel. | |
SubtypeList | list [NUM_CARGO] |
List of refit subtypes available for each sorted cargo. | |
VehicleOrderID | order |
If not INVALID_VEH_ORDER_ID, selection is part of a refit order (rather than execute directly). | |
uint | information_width |
Width required for correctly displaying all cargos in the information panel. | |
Scrollbar * | vscroll |
The main scrollbar. | |
Scrollbar * | hscroll |
Only used for long vehicles. | |
int | vehicle_width |
Width of the vehicle being drawn. | |
int | sprite_left |
Left position of the vehicle sprite. | |
int | sprite_right |
Right position of the vehicle sprite. | |
uint | vehicle_margin |
Margin to use while selecting vehicles when the vehicle image is centered. | |
int | click_x |
Position of the first click while dragging. | |
VehicleID | selected_vehicle |
First vehicle in the current selection. | |
uint8 | num_vehicles |
Number of selected vehicles. | |
bool | auto_refit |
Select cargo for auto-refitting. |
Refit cargo window.
Definition at line 373 of file vehicle_gui.cpp.
virtual void RefitWindow::DrawWidget | ( | const Rect & | r, | |
int | widget | |||
) | const [inline, virtual] |
Draw the contents of a nested widget.
r | Rectangle occupied by the widget. | |
widget | Number of the widget to draw. |
Reimplemented from Window.
Definition at line 630 of file vehicle_gui.cpp.
References _current_text_dir, cargo, Clamp(), SmallVector< T, S >::Contains(), DrawFrameRect(), DrawStringMultiLine(), DrawVehicleImage(), DrawVehicleRefitWindow(), EIT_IN_DETAILS, FR_BORDERONLY, SpecializedVehicle< Train, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetCapacity(), GetCapacityString(), Scrollbar::GetPosition(), GetVehicleSet(), hscroll, INVALID_STRING_ID, INVALID_VEH_ORDER_ID, INVALID_VEHICLE, Window::left, max(), SpecializedVehicle< T, Type >::Next(), num_vehicles, Window::resize, sel, selected_vehicle, sprite_left, sprite_right, ResizeInfo::step_height, TD_RTL, BaseVehicle::type, VEH_TRAIN, vehicle_margin, vscroll, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, Window::width, and Window::window_number.
StringID RefitWindow::GetCapacityString | ( | RefitOption * | option | ) | const [inline] |
Gets the StringID to use for displaying capacity.
Cargo | and cargo subtype to check for capacity. |
Definition at line 607 of file vehicle_gui.cpp.
References _current_company, _local_company, _returned_mail_refit_capacity, _returned_refit_capacity, RefitOption::cargo, DC_QUERY_COST, DoCommand(), CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), CommandCost::GetCost(), INVALID_STRING_ID, SetDParam(), RefitOption::subtype, Vehicle::tile, BaseVehicle::type, and Window::window_number.
Referenced by DrawWidget(), and OnInvalidateData().
RefitOption* RefitWindow::GetRefitOption | ( | ) | [inline] |
Gets the RefitOption placed in the selected index.
Definition at line 486 of file vehicle_gui.cpp.
References SmallVector< T, S >::Length(), and sel.
Referenced by OnInvalidateData().
virtual void RefitWindow::OnClick | ( | Point | pt, | |
int | widget, | |||
int | click_count | |||
) | [inline, virtual] |
A click with the left mouse button has been made on the window.
pt | the point inside the window that has been clicked. | |
widget | the clicked widget. | |
click_count | Number of fast consecutive clicks at same position |
Reimplemented from Window.
Definition at line 819 of file vehicle_gui.cpp.
References _ctrl_pressed, cargo, CMD_ORDER_REFIT, DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetScrolledRowFromWidget(), HT_DRAG, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEH_ORDER_ID, Window::InvalidateData(), num_vehicles, NWidgetBase::pos_x, sel, selected_vehicle, Window::SetWidgetDirty(), Window::SetWidgetDisabledState(), SPR_CURSOR_MOUSE, Vehicle::tile, vscroll, and Window::window_number.
virtual void RefitWindow::OnDragDrop | ( | Point | pt, | |
int | widget | |||
) | [inline, virtual] |
A dragged 'object' has been released.
pt | the point inside the window where the release took place. | |
widget | the widget where the release took place. |
Reimplemented from Window.
Definition at line 875 of file vehicle_gui.cpp.
References INVALID_VEH_ORDER_ID, Window::InvalidateData(), and NWidgetBase::pos_x.
virtual void RefitWindow::OnInit | ( | ) | [inline, virtual] |
Notification that the nested widget tree gets initialized.
The event can be used to perform general computations.
Reimplemented from Window.
Definition at line 525 of file vehicle_gui.cpp.
References BuildRefitList(), cargo, SmallVector< T, S >::Length(), OnInvalidateData(), Scrollbar::ScrollTowards(), sel, Window::SetWidgetDisabledState(), and vscroll.
virtual void RefitWindow::OnInvalidateData | ( | int | data = 0 , |
|
bool | gui_scope = true | |||
) | [inline, virtual] |
Some data on this window has become invalid.
data | Information about the changed data. | |
gui_scope | Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details. |
Reimplemented from Window.
Definition at line 712 of file vehicle_gui.cpp.
References BuildRefitList(), cargo, EIT_IN_DETAILS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetCapacityString(), GetRefitOption(), GetStringBoundingBox(), GetVehicleWidth(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, information_width, INVALID_STRING_ID, SmallVector< T, S >::Length(), max(), num_vehicles, Window::ReInit(), selected_vehicle, vehicle_width, and Window::window_number.
Referenced by OnInit().
virtual void RefitWindow::OnMouseDrag | ( | Point | pt, | |
int | widget | |||
) | [inline, virtual] |
An 'object' is being dragged at the provided position, highlight the target if possible.
pt | The point inside the window that the mouse hovers over. | |
widget | The widget the mouse hovers over. |
Reimplemented from Window.
Definition at line 862 of file vehicle_gui.cpp.
References INVALID_VEH_ORDER_ID, NWidgetBase::pos_x, and Window::SetWidgetDirty().
virtual void RefitWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 557 of file vehicle_gui.cpp.
References _current_text_dir, NWidgetBase::current_x, Window::DrawWidgets(), hscroll, max(), NWidgetBase::pos_x, Scrollbar::SetCount(), sprite_left, sprite_right, TD_RTL, vehicle_margin, and vehicle_width.
virtual void RefitWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 888 of file vehicle_gui.cpp.
References EIT_IN_DETAILS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Scrollbar::GetCapacity(), GetVehicleWidth(), hscroll, MAT_COL_START, Scrollbar::SetCapacityFromWidget(), vehicle_width, vscroll, and Window::window_number.
virtual void RefitWindow::SetStringParameters | ( | int | widget | ) | const [inline, virtual] |
Initialize string parameters for a widget.
Calls to this function are made during initialization to measure the size (that is as part of InitNested()), during drawing, and while re-initializing the window. Only for widgets that render text initializing is requested.
widget | Widget number. |
Reimplemented from Window.
Definition at line 596 of file vehicle_gui.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), SetDParam(), and Window::window_number.
virtual void RefitWindow::UpdateWidgetSize | ( | int | widget, | |
Dimension * | size, | |||
const Dimension & | padding, | |||
Dimension * | fill, | |||
Dimension * | resize | |||
) | [inline, virtual] |
Update size and resize step of a widget in the window.
After retrieval of the minimal size and the resize-steps of a widget, this function is called to allow further refinement, typically by computing the real maximal size of the content. Afterwards, size is taken to be the minimal size of the widget and resize is taken to contain the resize steps. For the convenience of the callee, padding contains the amount of padding between the content and the edge of the widget. This should be added to the returned size.
widget | Widget number. | |
size | Size of the widget. | |
padding | Recommended amount of space between the widget content and the widget edge. | |
fill | Fill step of the widget. | |
resize | Resize step of the widget. |
Reimplemented from Window.
Definition at line 578 of file vehicle_gui.cpp.
References FONT_HEIGHT_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetVehicleHeight(), information_width, WD_FRAMERECT_LEFT, WD_MATRIX_TOP, and Window::window_number.