Public Types | Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions | Static Private Member Functions

# NewGRFWindow Struct Reference

Window for showing NewGRF files. More...

Inheritance diagram for NewGRFWindow:

## Public Types
typedef GUIList< const GRFConfig *, StringFilter & > | 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)
virtual void | OnResize ()
virtual void | SetStringParameters (int widget) const
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
virtual void | OnClick (Point pt, int widget, int click_count)
virtual void | OnNewGRFsScanned ()
| Called whenever the NewGRF scan completed.
virtual void | OnDropdownSelect (int widget, int index)
virtual void | OnQueryTextFinished (char *str)
virtual void | OnInvalidateData (int data=0, bool gui_scope=true)
| Some data on this window has become invalid.
virtual EventState | OnKeyPress (uint16 key, uint16 keycode)
virtual void | OnEditboxChanged (int wid)
virtual void | OnDragDrop (Point pt, int widget)
virtual void | OnMouseDrag (Point pt, int widget)
## 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`.
StringFilter | string_filter
| Filter for available grf.
QueryString | filter_editbox
| Filter editbox;.
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.
int | active_over
| Active GRF item over which another one is dragged, `-1` if none.
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 ()
bool | AddGRFToActive (int ins_pos=-1)
| Insert a GRF into the active list.
## 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, StringFilter &filter)
| Filter grfs by tags/name.

## Detailed Description

Window for showing NewGRF files.

Definition at line 593 of file newgrf_gui.cpp.

## Member Function Documentation

bool NewGRFWindow::AddGRFToActive | ( | int | ins_pos = `-1` | ) | `[inline, private]`

Insert a GRF into the active list.

Parameters:

  | ins_pos | Insert GRF at this position.

Returns:
  True if the GRF was successfully added.

Definition at line 1436 of file newgrf_gui.cpp.

References actives, avail_pos, avail_sel, avails, editable, GRFConfig::flags, GUIList< T, F >::ForceRebuild(), GCF_INVALID, GOID_NEWGRF_LIST_EDITED, HasBit(), INVALID_STRING_ID, Window::InvalidateData(), SmallVector< T, S >::Length(), GRFConfig::next, GRFConfig::SetParameterDefaults(), ShowErrorMessage(), and WL_INFO.

PaletteID NewGRFWindow::GetPalette | ( | const GRFConfig * | c | ) | const`[inline]`

Pick the palette for the sprite of the grf to display.

Parameters:

  | c | grf to display.

Returns:
  Palette for the sprite.

Definition at line 751 of file newgrf_gui.cpp.

References GRFConfig::flags, GCF_COMPATIBLE, GCF_STATIC, GCS_ACTIVATED, GCS_DISABLED, GCS_NOT_FOUND, HasBit(), and GRFConfig::status.

static int CDECL NewGRFWindow::NameSorter | ( | const GRFConfig *const * | a,
|  | const GRFConfig *const * | b |
| ) |  |  | `[inline, static, private]`

Sort grfs by name.

Definition at line 1369 of file newgrf_gui.cpp.

References lengthof, and strnatcmp().

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

See also:
  GameOptionsInvalidationData

Parameters:

  | gui_scope | Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See InvalidateWindowData() for details.

Definition at line 1132 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, GRFConfig::GetTextfile(), GRFConfig::GetURL(), GOID_NEWGRF_LIST_EDITED, GOID_NEWGRF_PRESET_LOADED, GOID_NEWGRF_RESCANNED, GRFIdentifier::grfid, HasBit(), GRFConfig::ident, GRFConfig::IsOpenTTDBaseGRF(), GRFIdentifier::md5sum, GRFConfig::next, GRFConfig::num_valid_params, GRFConfig::original_md5sum, preset, Scrollbar::ScrollTowards(), Scrollbar::SetCapacityFromWidget(), Scrollbar::SetCount(), Window::SetWidgetDisabledState(), Window::SetWidgetsDisabledState(), GRFConfig::status, StrEmpty(), WID_NS_ADD, WID_NS_APPLY_CHANGES, WID_NS_AVAIL_LIST, WID_NS_FILE_LIST, WID_NS_MOVE_DOWN, WID_NS_MOVE_UP, WID_NS_NEWGRF_TEXTFILE, WID_NS_OPEN_URL, WID_NS_PRESET_DELETE, WID_NS_PRESET_LIST, WID_NS_PRESET_SAVE, WID_NS_REMOVE, WID_NS_SET_PARAMETERS, WID_NS_TOGGLE_PALETTE, WID_NS_VIEW_PARAMETERS, and WIDGET_LIST_END.

virtual void NewGRFWindow::OnNewGRFsScanned | ( |  | ) | `[inline, virtual]`

Called whenever the NewGRF scan completed.

Implements NewGRFScanCallback.

Definition at line 1082 of file newgrf_gui.cpp.

References avail_pos, avail_sel, avails, Window::DeleteChildWindows(), GUIList< T, F >::ForceRebuild(), WC_QUERY_STRING, and WC_TEXTFILE.

## Field Documentation

NewGRFWindow::GUIGRFConfigList::FilterFunction *const NewGRFWindow::filter_funcs`[static]`

Initial value:

     {
      &TagNameFilter,
    }

Filter functions of the GUIGRFConfigList.

Definition at line 601 of file newgrf_gui.cpp.

NewGRFWindow::GUIGRFConfigList::SortFunction *const NewGRFWindow::sorter_funcs`[static]`

Initial value:

     {
      &NameSorter,
    }

Sort functions of the GUIGRFConfigList.

Definition at line 600 of file newgrf_gui.cpp.

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

- src/newgrf_gui.cpp