Window for setting the parameters of a NewGRF. More...
Public Member Functions | |
NewGRFParametersWindow (const WindowDesc *desc, GRFConfig *c, bool editable) | |
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. | |
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 | OnClick (Point pt, int widget, int click_count) |
A click with the left mouse button has been made on the window. | |
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 | OnDropdownClose (Point pt, int widget, int index, bool instant_close) |
A dropdown window associated to this window has been closed. | |
virtual void | OnResize () |
Called after the window got resized. | |
virtual void | OnInvalidateData (int data=0, bool gui_scope=true) |
Some data on this window has become invalid. | |
virtual void | OnTick () |
Called once per (game) tick. | |
Static Public Member Functions | |
static GRFParameterInfo * | GetDummyParameterInfo (uint nr) |
Get a dummy parameter-info object with default information. | |
Data Fields | |
GRFConfig * | grf_config |
Set the parameters of this GRFConfig. | |
uint | clicked_button |
The row in which a button was clicked or UINT_MAX. | |
bool | clicked_increase |
True if the increase button was clicked, false for the decrease button. | |
bool | clicked_dropdown |
Whether the dropdown is open. | |
bool | closing_dropdown |
True, if the dropdown list is currently closing. | |
int | timeout |
How long before we unpress the last-pressed button? | |
uint | clicked_row |
The selected parameter. | |
int | line_height |
Height of a row in the matrix widget. | |
Scrollbar * | vscroll |
bool | action14present |
True if action14 information is present. | |
bool | editable |
Allow editing parameters. | |
Static Public Attributes | |
static GRFParameterInfo | dummy_parameter_info |
Dummy info in case a newgrf didn't provide info about some parameter. |
Window for setting the parameters of a NewGRF.
Definition at line 143 of file newgrf_gui.cpp.
virtual void NewGRFParametersWindow::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 242 of file newgrf_gui.cpp.
References _current_text_dir, clicked_button, clicked_dropdown, clicked_increase, clicked_row, GRFParameterInfo::complete_labels, SmallMap< T, U, S >::Contains(), GRFParameterInfo::desc, DrawArrowButtons(), DrawBoolButton(), DrawDropDownButton(), DrawString(), DrawStringMultiLine(), editable, SmallMap< T, U, S >::Find(), Scrollbar::GetCount(), GetDummyParameterInfo(), GetGRFStringFromGRFText(), Scrollbar::GetPosition(), GRFParameterInfo::GetValue(), grf_config, Scrollbar::IsVisible(), SmallVector< T, S >::Length(), line_height, GRFParameterInfo::min_value, GRFParameterInfo::name, GRFConfig::param_info, PTYPE_BOOL, PTYPE_UINT_ENUM, SetDParam(), SetDParamStr(), SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, GRFParameterInfo::type, GRFParameterInfo::value_names, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_MATRIX_TOP, WD_TEXTPANEL_BOTTOM, WD_TEXTPANEL_TOP, WID_NP_BACKGROUND, and WID_NP_DESCRIPTION.
static GRFParameterInfo* NewGRFParametersWindow::GetDummyParameterInfo | ( | uint | nr | ) | [inline, static] |
Get a dummy parameter-info object with default information.
nr | The param number that should be changed. |
Definition at line 184 of file newgrf_gui.cpp.
References dummy_parameter_info, and GRFParameterInfo::param_nr.
Referenced by DrawWidget(), OnClick(), OnDropdownSelect(), and OnQueryTextFinished().
virtual void NewGRFParametersWindow::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 311 of file newgrf_gui.cpp.
References _current_text_dir, action14present, clicked_button, clicked_dropdown, clicked_increase, clicked_row, closing_dropdown, GRFParameterInfo::complete_labels, CS_NUMERAL, NWidgetBase::current_x, Window::DeleteChildWindows(), editable, SmallMap< T, U, S >::Find(), Scrollbar::GetCount(), GetDummyParameterInfo(), GetGRFStringFromGRFText(), Scrollbar::GetScrolledRowFromWidget(), GRFParameterInfo::GetValue(), grf_config, HideDropDownMenu(), Window::InvalidateData(), IsInsideMM(), SmallVector< T, S >::Length(), line_height, GRFParameterInfo::min_value, GRFConfig::num_params, GRFConfig::num_valid_params, GRFConfig::param, GRFConfig::param_info, NWidgetBase::pos_x, NWidgetBase::pos_y, PTYPE_BOOL, PTYPE_UINT_ENUM, Window::SetDirty(), SetDParam(), GRFConfig::SetParameterDefaults(), SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, GRFParameterInfo::SetValue(), SetWindowDirty(), ShowDropDownListAt(), ShowQueryString(), TD_RTL, timeout, GRFParameterInfo::type, GRFParameterInfo::value_names, WC_GAME_OPTIONS, WC_QUERY_STRING, WID_NP_ACCEPT, WID_NP_BACKGROUND, WID_NP_NUMPAR_DEC, WID_NP_NUMPAR_INC, WID_NP_RESET, and WN_GAME_OPTIONS_NEWGRF_STATE.
virtual void NewGRFParametersWindow::OnDropdownClose | ( | Point | pt, | |
int | widget, | |||
int | index, | |||
bool | instant_close | |||
) | [inline, virtual] |
A dropdown window associated to this window has been closed.
pt | the point inside the window the mouse resides on after closure. | |
widget | the widget (button) that the dropdown is associated with. | |
index | the element in the dropdown that is selected. | |
instant_close | whether the dropdown was configured to close on mouse up. |
Reimplemented from Window.
Definition at line 445 of file newgrf_gui.cpp.
References clicked_dropdown, closing_dropdown, and Window::SetDirty().
virtual void NewGRFParametersWindow::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 436 of file newgrf_gui.cpp.
References clicked_dropdown, clicked_row, GetDummyParameterInfo(), grf_config, SmallVector< T, S >::Length(), GRFConfig::param_info, Window::SetDirty(), and GRFParameterInfo::SetValue().
virtual void NewGRFParametersWindow::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 468 of file newgrf_gui.cpp.
References action14present, clicked_row, Window::DeleteChildWindows(), editable, Scrollbar::GetCount(), grf_config, GRFConfig::num_params, GRFConfig::num_valid_params, Scrollbar::SetCount(), Window::SetWidgetDisabledState(), WC_QUERY_STRING, WID_NP_NUMPAR_DEC, and WID_NP_NUMPAR_INC.
virtual void NewGRFParametersWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 302 of file newgrf_gui.cpp.
References clicked_dropdown, closing_dropdown, and Window::DrawWidgets().
virtual void NewGRFParametersWindow::OnQueryTextFinished | ( | char * | str | ) | [inline, virtual] |
The query window opened from this window has closed.
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 425 of file newgrf_gui.cpp.
References clicked_row, GetDummyParameterInfo(), grf_config, SmallVector< T, S >::Length(), GRFParameterInfo::max_value, GRFParameterInfo::min_value, GRFConfig::param_info, Window::SetDirty(), GRFParameterInfo::SetValue(), and StrEmpty().
virtual void NewGRFParametersWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 456 of file newgrf_gui.cpp.
References NWidgetBase::current_y, Scrollbar::GetCapacity(), MAT_COL_START, Scrollbar::SetCapacity(), and NWidgetCore::widget_data.
virtual void NewGRFParametersWindow::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 233 of file newgrf_gui.cpp.
References Scrollbar::GetCount(), SetDParam(), and WID_NP_NUMPAR.
virtual void NewGRFParametersWindow::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 190 of file newgrf_gui.cpp.
References GRFParameterInfo::desc, FONT_HEIGHT_NORMAL, GB(), GetGRFStringFromGRFText(), GetStringBoundingBox(), GetStringMultiLineBoundingBox(), grf_config, SmallVector< T, S >::Length(), line_height, MAT_ROW_BITS, MAT_ROW_START, maxdim(), GRFConfig::param_info, SetDParam(), WD_FRAMERECT_LEFT, WD_MATRIX_TOP, WD_TEXTPANEL_BOTTOM, WD_TEXTPANEL_TOP, WID_NP_BACKGROUND, WID_NP_DESCRIPTION, WID_NP_NUMPAR, WID_NP_NUMPAR_DEC, and WID_NP_NUMPAR_INC.