Window class for handling the bridge-build GUI. More...
Public Member Functions | |
BuildBridgeWindow (const WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) | |
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 Point | OnInitialPosition (const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) |
Compute the initial position of the window. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
virtual EventState | OnKeyPress (uint16 key, uint16 keycode) |
A key has been pressed. | |
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 | OnDropdownSelect (int widget, int index) |
A dropdown option associated to this window has been selected. | |
virtual void | OnResize () |
Called after the window got resized. | |
Private Member Functions | |
void | BuildBridge (uint8 i) |
void | SortBridgeList () |
Sort the builable bridges. | |
Static Private Member Functions | |
static int CDECL | BridgeIndexSorter (const BuildBridgeData *a, const BuildBridgeData *b) |
Sort the bridges by their index. | |
static int CDECL | BridgePriceSorter (const BuildBridgeData *a, const BuildBridgeData *b) |
Sort the bridges by their price. | |
static int CDECL | BridgeSpeedSorter (const BuildBridgeData *a, const BuildBridgeData *b) |
Sort the bridges by their maximum speed. | |
Private Attributes | |
TileIndex | start_tile |
TileIndex | end_tile |
uint32 | type |
GUIBridgeList * | bridges |
int | bridgetext_offset |
Horizontal offset of the text describing the bridge properties in BBSW_BRIDGE_LIST relative to the left edge. | |
Scrollbar * | vscroll |
Static Private Attributes | |
static uint16 | last_size = 4 |
Last size of the bridge GUI window. | |
static Listing | last_sorting = {true, 2} |
Last setting of the sort. | |
static const StringID | sorter_names [] |
Names of the sorting functions. | |
static GUIBridgeList::SortFunction *const | sorter_funcs [] |
Available bridge sorting functions. |
Window class for handling the bridge-build GUI.
Definition at line 68 of file bridge_gui.cpp.
virtual void BuildBridgeWindow::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 218 of file bridge_gui.cpp.
References Window::DrawSortButtonState(), DrawSprite(), DrawStringMultiLine(), SmallVector< T, S >::Get(), Scrollbar::GetPosition(), GetSpriteSize(), GUIList< T, F >::IsDescSortOrder(), Scrollbar::IsVisible(), SmallVector< T, S >::Length(), BridgeSpec::material, BridgeSpec::pal, Window::resize, SBS_DOWN, SBS_UP, SetDParam(), BridgeSpec::speed, BridgeSpec::sprite, ResizeInfo::step_height, and WD_MATRIX_LEFT.
virtual void BuildBridgeWindow::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 256 of file bridge_gui.cpp.
References Scrollbar::GetScrolledRowFromWidget(), SmallVector< T, S >::Length(), Window::SetDirty(), ShowDropDownMenu(), sorter_names, GUIList< T, F >::SortType(), and GUIList< T, F >::ToggleSortOrder().
virtual void BuildBridgeWindow::OnDropdownSelect | ( | int | widget, | |
int | index | |||
) | [inline, virtual] |
A dropdown option associated to this window has been selected.
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 280 of file bridge_gui.cpp.
References GUIList< T, F >::SetSortType(), SortBridgeList(), and GUIList< T, F >::SortType().
virtual Point BuildBridgeWindow::OnInitialPosition | ( | const WindowDesc * | desc, | |
int16 | sm_width, | |||
int16 | sm_height, | |||
int | window_number | |||
) | [inline, virtual] |
Compute the initial position of the window.
*desc | The pointer to the WindowDesc of the window to create. | |
sm_width | Smallest width of the window. | |
sm_height | Smallest height of the window. | |
window_number | The window number of the new window. |
Reimplemented from Window.
Definition at line 208 of file bridge_gui.cpp.
References Clamp(), GetMainViewBottom(), GetMainViewTop(), NWidgetBase::pos_x, and NWidgetBase::pos_y.
virtual EventState BuildBridgeWindow::OnKeyPress | ( | uint16 | key, | |
uint16 | keycode | |||
) | [inline, virtual] |
A key has been pressed.
key | the Unicode value of the key. | |
keycode | the untranslated key code including shift state. |
Reimplemented from Window.
Definition at line 244 of file bridge_gui.cpp.
References ES_HANDLED, ES_NOT_HANDLED, and SmallVector< T, S >::Length().
virtual void BuildBridgeWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 289 of file bridge_gui.cpp.
References Scrollbar::GetCapacity(), last_size, MAT_COL_START, MAT_ROW_START, max(), and Scrollbar::SetCapacityFromWidget().
virtual void BuildBridgeWindow::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 164 of file bridge_gui.cpp.
References bridgetext_offset, SmallVector< T, S >::Get(), GetSpriteSize(), GetStringBoundingBox(), INVALID_STRING_ID, SmallVector< T, S >::Length(), BridgeSpec::material, max(), maxdim(), SetDParam(), sorter_names, BridgeSpec::speed, BridgeSpec::sprite, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, and WD_SORTBUTTON_ARROW_WIDTH.
uint16 BuildBridgeWindow::last_size = 4 [static, private] |
Last size of the bridge GUI window.
Set the default size of the Build Bridge Window.
Definition at line 71 of file bridge_gui.cpp.
Referenced by OnResize().
Listing BuildBridgeWindow::last_sorting = {true, 2} [static, private] |
Last setting of the sort.
Set the default sorting for the bridges.
Definition at line 72 of file bridge_gui.cpp.
GUIBridgeList::SortFunction *const BuildBridgeWindow::sorter_funcs [static, private] |
Available bridge sorting functions.
Definition at line 76 of file bridge_gui.cpp.
const StringID BuildBridgeWindow::sorter_names [static, private] |
{ STR_SORT_BY_NUMBER, STR_SORT_BY_COST, STR_SORT_BY_MAX_SPEED, INVALID_STRING_ID }
Names of the sorting functions.
Definition at line 75 of file bridge_gui.cpp.
Referenced by OnClick(), SortBridgeList(), and UpdateWidgetSize().