# newgrf_gui.cpp File Reference

GUI to change NewGRF settings. More...

`#include "stdafx.h"`
`#include "gui.h"`
`#include "newgrf.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "gfx_func.h"`
`#include "gamelog.h"`
`#include "settings_func.h"`
`#include "widgets/dropdown_type.h"`
`#include "network/network.h"`
`#include "network/network_content.h"`
`#include "sortlist_type.h"`
`#include "querystring_gui.h"`
`#include "table/strings.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Data Structures

struct | NewGRFAddWindow
| Window for adding NewGRF files. More...
class | DropDownListPresetItem
struct | NewGRFWindow
| Window for showing NewGRF files. More...

## Enumerations

enum | AddNewGRFWindowWidgets { ANGRFW_FILTER, ANGRFW_GRF_LIST, ANGRFW_SCROLLBAR, ANGRFW_GRF_INFO, ANGRFW_ADD, ANGRFW_RESCAN }
| Names of the add a newgrf window widgets. More...
enum | ShowNewGRFStateWidgets { SNGRFS_PRESET_LIST, SNGRFS_PRESET_SAVE, SNGRFS_PRESET_DELETE, SNGRFS_ADD, SNGRFS_REMOVE, SNGRFS_MOVE_UP, SNGRFS_MOVE_DOWN, SNGRFS_FILE_LIST, SNGRFS_SCROLLBAR, SNGRFS_NEWGRF_INFO, SNGRFS_SET_PARAMETERS, SNGRFS_TOGGLE_PALETTE, SNGRFS_APPLY_CHANGES, SNGRFS_CONTENT_DOWNLOAD }
| Names of the manage newgrfs window widgets. More...

## Functions

void | ShowNewGRFError ()
| Show the first NewGRF error we can find.
static int | parse_intlist (const char *p, int *items, int maxitems)
| Parse an integerlist string and set each found value.
static void | ShowNewGRFInfo (const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params)
static void | NewGRFConfirmationCallback (Window *w, bool confirmed)
| Callback function for the newgrf 'apply changes' confirmation window.
void | ShowNewGRFSettings (bool editable, bool show_params, bool exec_changes, GRFConfig **config)
| Setup the NewGRF gui.

## Variables

static const NWidgetPart | _nested_newgrf_add_dlg_widgets []
static const WindowDesc | _newgrf_add_dlg_desc (WDP_CENTER, 306, 347, WC_SAVELOAD, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_newgrf_add_dlg_widgets, lengthof(_nested_newgrf_add_dlg_widgets))
static GRFPresetList | _grf_preset_list
static const NWidgetPart | _nested_newgrf_widgets []
static const WindowDesc | _newgrf_desc (WDP_CENTER, 300, 263, WC_GAME_OPTIONS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_newgrf_widgets, lengthof(_nested_newgrf_widgets))

## Detailed Description

GUI to change NewGRF settings.

Definition in file newgrf_gui.cpp.

## Enumeration Type Documentation

enum AddNewGRFWindowWidgets

Names of the add a newgrf window widgets.

Definition at line 145 of file newgrf_gui.cpp.

enum ShowNewGRFStateWidgets

Names of the manage newgrfs window widgets.

Definition at line 535 of file newgrf_gui.cpp.

## Function Documentation

static void NewGRFConfirmationCallback | ( | Window * | w,
|  | bool | confirmed |
| ) |  |  | `[static]`

Callback function for the newgrf 'apply changes' confirmation window.

Parameters:

  | w | Window which is calling this callback
  | confirmed | boolean value, true when yes was clicked, false otherwise

Definition at line 1073 of file newgrf_gui.cpp.

References _grfconfig, CopyGRFConfigList(), GamelogGRFUpdate(), GamelogStartAction(), GamelogStopAction(), GLAT_GRF, NewGRFWindow::list, GRFConfig::next, NewGRFWindow::orig_list, ReloadNewGRFData(), NewGRFWindow::sel, and Window::SetDirty().

Referenced by NewGRFWindow::OnClick().

static int parse_intlist | ( | const char * | p,
|  | int * | items,
|  | int | maxitems |
| ) |  |  | `[static]`

Parse an integerlist string and set each found value.

Parameters:

  | p | the string to be parsed. Each element in the list is seperated by a comma or a space character
  | items | pointer to the integerlist-array that will be filled with values
  | maxitems | the maximum number of elements the integerlist-array has

Returns:
  returns the number of items found, or -1 on an error

Definition at line 58 of file newgrf_gui.cpp.

Referenced by load_intlist(), and NewGRFWindow::OnQueryTextFinished().

void ShowNewGRFSettings | ( | bool | editable,
|  | bool | show_params,
|  | bool | exec_changes,
|  | GRFConfig ** | config |
| ) |  |  |

Setup the NewGRF gui.

Parameters:

  | editable | allow the user to make changes to the grfconfig in the window
  | show_params | show information about what parameters are set for the grf files
  | exec_changes | if changes are made to the list (editable is true), apply these changes immediately or only update the list
  | config | pointer to a linked-list of grfconfig's that will be shown

Definition at line 1104 of file newgrf_gui.cpp.

References DeleteWindowByClass().

## Variable Documentation

const NWidgetPart _nested_newgrf_add_dlg_widgets[]`[static]`

Initial value:

     {
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_CLOSEBOX, COLOUR_GREY),
        NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NEWGRF_ADD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
      EndContainer(),
      NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0),
        NWidget(NWID_HORIZONTAL), SetPadding(WD_TEXTPANEL_TOP, 0, WD_TEXTPANEL_BOTTOM, 0), SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT),
          NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
          NWidget(WWT_EDITBOX, COLOUR_GREY, ANGRFW_FILTER), SetFill(1, 0), SetMinimalSize(100, 12), SetResize(1, 0), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
        EndContainer(),
      EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_PANEL, COLOUR_GREY),
          NWidget(WWT_INSET, COLOUR_GREY, ANGRFW_GRF_LIST), SetMinimalSize(290, 1), SetResize(1, 1), SetPadding(2, 2, 2, 2), EndContainer(),
        EndContainer(),
        NWidget(WWT_SCROLLBAR, COLOUR_GREY, ANGRFW_SCROLLBAR),
      EndContainer(),
      NWidget(WWT_PANEL, COLOUR_GREY, ANGRFW_GRF_INFO), SetMinimalSize(306, 1), SetResize(1, 0), EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
          NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ANGRFW_ADD), SetMinimalSize(147, 12), SetResize(1, 0), SetDataTip(STR_NEWGRF_ADD_FILE, STR_NEWGRF_ADD_FILE_TOOLTIP),
          NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, ANGRFW_RESCAN), SetMinimalSize(147, 12), SetResize(1, 0), SetDataTip(STR_NEWGRF_ADD_RESCAN_FILES, STR_NEWGRF_ADD_RESCAN_FILES_TOOLTIP),
        EndContainer(),
        NWidget(WWT_RESIZEBOX, COLOUR_GREY),
      EndContainer(),
    }

Definition at line 478 of file newgrf_gui.cpp.