Window for showing NewGRF files. More...
Public Types | |
typedef GUIList< const GRFConfig * > | GUIGRFConfigList |
Public Member Functions | |
NewGRFWindow (const WindowDesc *desc, bool editable, bool show_params, bool execute, GRFConfig **orig_list) | |
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 | OnResize () |
Called after the window got resized. | |
virtual void | SetStringParameters (int widget) const |
Initialize string parameters for a widget. | |
virtual void | OnPaint () |
The window must be repainted. | |
FORCEINLINE PaletteID | GetPalette (const GRFConfig *c) const |
Pick the palette for the sprite of the grf to display. | |
virtual void | DrawWidget (const Rect &r, int widget) const |
Draw the contents of a nested widget. | |
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 | OnQueryTextFinished (char *str) |
The query window opened from this window has closed. | |
virtual void | OnInvalidateData (int data=0, bool gui_scope=true) |
Some data on this window has become invalid. | |
virtual void | OnMouseLoop () |
Called for every mouse loop run, which is at least once per (game) tick. | |
virtual EventState | OnKeyPress (uint16 key, uint16 keycode) |
A key has been pressed. | |
virtual void | OnOSKInput (int wid) |
Callback for when on input has been entered with the OSK. | |
Data Fields | |
GUIGRFConfigList | avails |
Available (non-active) grfs. | |
const GRFConfig * | avail_sel |
Currently selected available grf. NULL is none is selected. | |
int | avail_pos |
Index of avail_sel if existing, else -1 . | |
GRFConfig * | actives |
Temporary active grf list to which changes are made. | |
GRFConfig * | active_sel |
Selected active grf item. | |
GRFConfig ** | orig_list |
List active grfs in the game. Used as initial value, may be updated by the window. | |
bool | editable |
Is the window editable? | |
bool | show_params |
Are the grf-parameters shown in the info-panel? | |
bool | execute |
On pressing 'apply changes' are grf changes applied immediately, or only list is updated. | |
int | preset |
Selected preset. | |
Scrollbar * | vscroll |
Scrollbar * | vscroll2 |
Static Public Attributes | |
static const uint | EDITBOX_MAX_SIZE = 50 |
static Listing | last_sorting = {false, 0} |
Default sorting of GUIGRFConfigList. | |
static Filtering | last_filtering = {false, 0} |
Default filtering of GUIGRFConfigList. | |
static GUIGRFConfigList::SortFunction *const | sorter_funcs [] |
Sort functions of the GUIGRFConfigList. | |
static GUIGRFConfigList::FilterFunction *const | filter_funcs [] |
Filter functions of the GUIGRFConfigList. | |
Private Member Functions | |
void | BuildAvailables () |
Static Private Member Functions | |
static int CDECL | NameSorter (const GRFConfig *const *a, const GRFConfig *const *b) |
Sort grfs by name. | |
static bool CDECL | TagNameFilter (const GRFConfig *const *a, const char *filter_string) |
Filter grfs by tags/name. |
Window for showing NewGRF files.
Definition at line 509 of file newgrf_gui.cpp.
virtual void NewGRFWindow::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 694 of file newgrf_gui.cpp.
References _current_text_dir, active_sel, actives, avail_sel, avails, DrawSprite(), DrawString(), GRFConfig::error, FONT_HEIGHT_NORMAL, Scrollbar::GetCapacity(), GRFConfig::GetName(), GetPalette(), Scrollbar::GetPosition(), GfxFillRect(), Scrollbar::IsVisible(), SmallVector< T, S >::Length(), min(), GRFConfig::next, PC_BLACK, PC_DARK_BLUE, SA_HOR_CENTER, TD_RTL, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, and WD_FRAMERECT_TOP.
Pick the palette for the sprite of the grf to display.
c | grf to display. |
Definition at line 664 of file newgrf_gui.cpp.
References GRFConfig::flags, GCF_COMPATIBLE, GCF_STATIC, GCS_ACTIVATED, GCS_DISABLED, GCS_NOT_FOUND, HasBit(), and GRFConfig::status.
Referenced by DrawWidget().
static int CDECL NewGRFWindow::NameSorter | ( | const GRFConfig *const * | a, | |
const GRFConfig *const * | b | |||
) | [inline, static, private] |
Sort grfs by name.
Definition at line 1211 of file newgrf_gui.cpp.
References lengthof, and strnatcmp().
virtual void NewGRFWindow::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 767 of file newgrf_gui.cpp.
References _network_available, active_sel, actives, SmallVector< T, S >::Append(), avail_pos, avail_sel, avails, BSWAP32(), CONTENT_TYPE_NEWGRF, CopyGRFConfigList(), CS_ALPHANUMERAL, Window::DeleteChildWindows(), DeleteGRFPresetFromConfig(), DeleteWindowByClass(), ContentInfo::DOES_NOT_EXIST, TarScanner::DoScan(), editable, execute, GRFConfig::flags, GUIList< T, F >::ForceRebuild(), GCF_COMPATIBLE, GCF_INVALID, GCS_NOT_FOUND, GetGRFPresetList(), GRFConfig::GetName(), Scrollbar::GetScrolledRowFromWidget(), GRFIdentifier::grfid, GRFP_USE_MASK, HasBit(), GRFConfig::ident, INVALID_STRING_ID, Window::InvalidateData(), InvalidateWindowClassesData(), SmallVector< T, S >::Length(), lengthof, GRFIdentifier::md5sum, ContentInfo::md5sum, ContentInfo::name, NewGRFConfirmationCallback(), GRFConfig::next, orig_list, GRFConfig::original_md5sum, GRFConfig::palette, preset, ReloadNewGRFData(), ResetGRFConfig(), ScanNewGRFFiles(), Scrollbar::ScrollTowards(), Window::SetDirty(), GRFConfig::SetParameterDefaults(), ShowDropDownList(), ShowErrorMessage(), ShowNetworkContentListWindow(), ShowQuery(), ShowQueryString(), ContentInfo::state, GRFConfig::status, ttd_strlcpy(), ContentInfo::type, ContentInfo::unique_id, WL_ERROR, and WL_INFO.
virtual void NewGRFWindow::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 994 of file newgrf_gui.cpp.
References active_sel, actives, avails, ClearGRFConfigList(), DeleteWindowByClass(), editable, GUIList< T, F >::ForceRebuild(), Window::InvalidateData(), LoadGRFPresetFromConfig(), and preset.
virtual void NewGRFWindow::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 1042 of file newgrf_gui.cpp.
References active_sel, actives, avail_pos, avail_sel, avails, Window::DisableWidget(), editable, FGCM_EXACT, FindGRFConfig(), GRFConfig::flags, GUIList< T, F >::ForceRebuild(), GCF_COMPATIBLE, GCF_INVALID, GCS_NOT_FOUND, GRFIdentifier::grfid, HasBit(), GRFConfig::ident, GRFConfig::IsOpenTTDBaseGRF(), GRFIdentifier::md5sum, GRFConfig::next, GRFConfig::original_md5sum, preset, Scrollbar::ScrollTowards(), Scrollbar::SetCapacityFromWidget(), Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetsDisabledState(), GRFConfig::status, and WIDGET_LIST_END.
virtual EventState NewGRFWindow::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 1145 of file newgrf_gui.cpp.
References avail_pos, avail_sel, avails, editable, ES_HANDLED, ES_NOT_HANDLED, Scrollbar::GetCapacity(), Window::InvalidateData(), SmallVector< T, S >::Length(), min(), OnOSKInput(), and Scrollbar::ScrollTowards().
virtual void NewGRFWindow::OnOSKInput | ( | int | wid | ) | [inline, virtual] |
Callback for when on input has been entered with the OSK.
wid | The widget the OSK was attached to. |
Reimplemented from QueryStringBaseWindow.
Definition at line 1200 of file newgrf_gui.cpp.
References avails, QueryStringBaseWindow::edit_str_buf, editable, GUIList< T, F >::ForceRebuild(), Window::InvalidateData(), GUIList< T, F >::SetFilterState(), and StrEmpty().
Referenced by OnKeyPress().
virtual void NewGRFWindow::OnPaint | ( | ) | [inline, virtual] |
The window must be repainted.
Reimplemented from Window.
Definition at line 653 of file newgrf_gui.cpp.
References Window::DrawWidgets(), and editable.
virtual void NewGRFWindow::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 1014 of file newgrf_gui.cpp.
References actives, GetGRFPresetList(), Window::InvalidateData(), SmallVector< T, S >::Length(), preset, and SaveGRFPresetToConfig().
virtual void NewGRFWindow::OnResize | ( | ) | [inline, virtual] |
Called after the window got resized.
For nested windows with a viewport, call NWidgetViewport::UpdateViewportCoordinates.
Reimplemented from Window.
Definition at line 633 of file newgrf_gui.cpp.
References Scrollbar::SetCapacityFromWidget().
virtual void NewGRFWindow::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 639 of file newgrf_gui.cpp.
References preset, SetDParam(), and SetDParamStr().
virtual void NewGRFWindow::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 585 of file newgrf_gui.cpp.
References FONT_HEIGHT_NORMAL, GetStringBoundingBox(), SmallVector< T, S >::Length(), max(), maxdim(), SetDParamStr(), WD_FRAMERECT_BOTTOM, WD_FRAMERECT_TOP, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, and WD_FRAMETEXT_TOP.
{ &TagNameFilter, }
Filter functions of the GUIGRFConfigList.
Definition at line 517 of file newgrf_gui.cpp.
{ &NameSorter, }
Sort functions of the GUIGRFConfigList.
Definition at line 516 of file newgrf_gui.cpp.