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:
Window NewGRFScanCallback ZeroedMemoryAllocator

Public Types

typedef GUIList< const
GRFConfig *, StringFilter & > 
GUIGRFConfigList

Public Member Functions

 NewGRFWindow (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 GRFConfigavail_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;.
GRFConfigactives
 Temporary active grf list to which changes are made.
GRFConfigactive_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.
Scrollbarvscroll
Scrollbarvscroll2

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 594 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 1437 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 752 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 1370 of file newgrf_gui.cpp.

References lengthof, and strnatcmp().

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

Called whenever the NewGRF scan completed.

Implements NewGRFScanCallback.

Definition at line 1083 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

Initial value:
 {
  &TagNameFilter,
}

Filter functions of the GUIGRFConfigList.

Definition at line 602 of file newgrf_gui.cpp.

Initial value:
 {
  &NameSorter,
}

Sort functions of the GUIGRFConfigList.

Definition at line 601 of file newgrf_gui.cpp.


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