Public Member Functions | Data Fields

# BuildVehicleWindow Struct Reference

Inheritance diagram for BuildVehicleWindow:

## Public Member Functions
| BuildVehicleWindow (const WindowDesc *desc, TileIndex tile, VehicleType type)
void | SetCargoFilterArray ()
| Populate the filter list and set the cargo filter criteria.
void | OnInit ()
| Notification that the nested widget tree gets initialized.
void | FilterEngineList ()
| Filter the engine list against the currently selected cargo filter.
bool | FilterSingleEngine (EngineID eid)
| Filter a single engine.
void | GenerateBuildTrainList ()
void | GenerateBuildRoadVehList ()
void | GenerateBuildShipList ()
void | GenerateBuildAircraftList ()
void | GenerateBuildList ()
void | OnClick (Point pt, int widget, int click_count)
| A click with the left mouse button has been made on the window.
virtual void | OnInvalidateData (int data=0, bool gui_scope=true)
| Some data on this window has become invalid.
virtual void | SetStringParameters (int widget) const
| Initialize string parameters for a widget.
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 | DrawWidget (const Rect &r, int widget) const
| Draw the contents of a nested widget.
virtual void | OnPaint ()
| The window must be repainted.
virtual void | OnQueryTextFinished (char *str)
| The query window opened from this window has closed.
virtual void | OnDropdownSelect (int widget, int index)
| A dropdown option associated to this window has been selected.
virtual void | OnResize ()
| Called after the window got resized.
## Data Fields
VehicleType | vehicle_type
union {
RailTypeByte railtype
RoadTypes roadtypes
} | filter
bool | descending_sort_order
byte | sort_criteria
bool | listview_mode
EngineID | sel_engine
EngineID | rename_engine
GUIEngineList | eng_list
CargoID | cargo_filter [NUM_CARGO+2]
| Available cargo filters; CargoID or CF_ANY or CF_NONE.
StringID | cargo_filter_texts [NUM_CARGO+3]
| Texts for filter_cargo, terminated by INVALID_STRING_ID.
byte | cargo_filter_criteria
| Selected cargo filter.
int | details_height
| Minimal needed height of the details panels (found so far).
Scrollbar * | vscroll

## Detailed Description

Definition at line 924 of file build_vehicle_gui.cpp.

## Member Function Documentation

virtual void BuildVehicleWindow::DrawWidget | ( | const Rect & | r,
|  | int | widget |
| ) |  |  | const`[inline, virtual]`

Draw the contents of a nested widget.

Parameters:

  | r | Rectangle occupied by the widget.
  | widget | Number of the widget to draw.

Note:
  This method may not change any state, it may only use drawing functions.

Reimplemented from Window.

Definition at line 1332 of file build_vehicle_gui.cpp.

References DEFAULT_GROUP, DrawEngineList(), Window::DrawSortButtonState(), Scrollbar::GetCapacity(), Scrollbar::GetPosition(), SmallVector< T, S >::Length(), min(), SBS_DOWN, SBS_UP, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WID_BV_LIST, and WID_BV_SORT_ASSENDING_DESCENDING.

void BuildVehicleWindow::OnClick | ( | Point | pt,
|  | int | widget,
|  | int | click_count |
| ) |  |  | `[inline, virtual]`

A click with the left mouse button has been made on the window.

Parameters:

  | 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 1209 of file build_vehicle_gui.cpp.

References _settings_game, cargo_filter_criteria, cargo_filter_texts, CcBuildPrimaryVehicle(), CcBuildWagon(), CS_ALPHANUMERAL, DoCommandP(), GUIList< T, F >::ForceRebuild(), Scrollbar::GetScrolledRowFromWidget(), INVALID_ENGINE, SmallVector< T, S >::Length(), MAX_LENGTH_ENGINE_NAME_CHARS, QSF_ENABLE_DEFAULT, QSF_LEN_IN_CHARS, VehicleSettings::roadveh_acceleration_model, SetBit(), Window::SetDirty(), SetDParam(), ShowDropDownMenu(), ShowQueryString(), VehicleSettings::train_acceleration_model, VEH_ROAD, VEH_TRAIN, GameSettings::vehicle, WID_BV_BUILD, WID_BV_CARGO_FILTER_DROPDOWN, WID_BV_LIST, WID_BV_RENAME, WID_BV_SORT_ASSENDING_DESCENDING, WID_BV_SORT_DROPDOWN, and Window::window_number.

virtual void BuildVehicleWindow::OnDropdownSelect | ( | int | widget,
|  | int | index |
| ) |  |  | `[inline, virtual]`

A dropdown option associated to this window has been selected.

Parameters:

  | widget | the widget (button) that the dropdown is associated with.
  | index | the element in the dropdown that is selected.

Reimplemented from Window.

Definition at line 1377 of file build_vehicle_gui.cpp.

References cargo_filter, cargo_filter_criteria, CF_ANY, GUIList< T, F >::ForceRebuild(), Window::SetDirty(), GUIList< T, F >::SetFilterState(), WID_BV_CARGO_FILTER_DROPDOWN, and WID_BV_SORT_DROPDOWN.

void BuildVehicleWindow::OnInit | ( |  | ) | `[inline, virtual]`

Notification that the nested widget tree gets initialized.

The event can be used to perform general computations.

Note:
  nested_root and/or nested_array (normally accessed via GetWidget()) may not exist during this call.

Reimplemented from Window.

Definition at line 1041 of file build_vehicle_gui.cpp.

References SetCargoFilterArray().

virtual void BuildVehicleWindow::OnInvalidateData | ( | int | data = `0`,
|  | bool | gui_scope = `true` |
| ) |  |  | `[inline, virtual]`

Some data on this window has become invalid.

Parameters:

  | 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 1276 of file build_vehicle_gui.cpp.

References _settings_game, GUIList< T, F >::ForceRebuild(), VehicleSettings::roadveh_acceleration_model, VEH_ROAD, and GameSettings::vehicle.

virtual void BuildVehicleWindow::OnPaint | ( |  | ) | `[inline, virtual]`

The window must be repainted.

Note:
  This method should not change any state, it should only use drawing functions.

Reimplemented from Window.

Definition at line 1345 of file build_vehicle_gui.cpp.

References NWidgetBase::current_x, details_height, DrawVehiclePurchaseInfo(), Window::DrawWidgets(), INVALID_ENGINE, Window::IsShaded(), SmallVector< T, S >::Length(), max(), NWidgetBase::pos_x, NWidgetBase::pos_y, Window::ReInit(), Window::resize, Scrollbar::SetCount(), WD_FRAMERECT_BOTTOM, WD_FRAMERECT_TOP, WD_FRAMETEXT_LEFT, and WD_FRAMETEXT_RIGHT.

virtual void BuildVehicleWindow::OnQueryTextFinished | ( | char * | str | ) | `[inline, virtual]`

The query window opened from this window has closed.

Parameters:

  | str | the new value of the string, NULL if the window was cancelled or an empty string when the default button was pressed, i.e. StrEmpty(str).

Reimplemented from Window.

Definition at line 1370 of file build_vehicle_gui.cpp.

References CMD_MSG, CMD_RENAME_ENGINE, and DoCommandP().

virtual void BuildVehicleWindow::OnResize | ( |  | ) | `[inline, virtual]`

Called after the window got resized.

For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.

Reimplemented from Window.

Definition at line 1401 of file build_vehicle_gui.cpp.

References Scrollbar::GetCapacity(), MAT_COL_START, Scrollbar::SetCapacityFromWidget(), and WID_BV_LIST.

void BuildVehicleWindow::SetCargoFilterArray | ( |  | ) | `[inline]`

Populate the filter list and set the cargo filter criteria.

Definition at line 998 of file build_vehicle_gui.cpp.

References cargo_filter, cargo_filter_criteria, cargo_filter_texts, CF_ANY, CF_NONE, CargoSpec::Index(), INVALID_STRING_ID, CargoSpec::name, GUIList< T, F >::SetFilterFuncs(), GUIList< T, F >::SetFilterState(), and VEH_TRAIN.

Referenced by OnInit().

virtual void BuildVehicleWindow::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.

Parameters:

  | widget | Widget number.

Reimplemented from Window.

Definition at line 1289 of file build_vehicle_gui.cpp.

References cargo_filter_criteria, cargo_filter_texts, GetRailTypeInfo(), SetDParam(), VEH_TRAIN, WID_BV_CAPTION, WID_BV_CARGO_FILTER_DROPDOWN, and WID_BV_SORT_DROPDOWN.

virtual void BuildVehicleWindow::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.

Parameters:

  | 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 1310 of file build_vehicle_gui.cpp.

References details_height, GetEngineListHeight(), GetStringBoundingBox(), maxdim(), WD_SORTBUTTON_ARROW_WIDTH, WID_BV_LIST, WID_BV_PANEL, and WID_BV_SORT_ASSENDING_DESCENDING.

The documentation for this struct was generated from the following file:

- src/build_vehicle_gui.cpp