# newgrf_gui.cpp File Reference

GUI to change NewGRF settings. More...

`#include "stdafx.h"`
`#include "gui.h"`
`#include "window_gui.h"`
`#include "textbuf_gui.h"`
`#include "newgrf.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "string_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 "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...
## Functions
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 w, 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 Widget | _newgrf_add_dlg_widgets []
static const WindowDesc | _newgrf_add_dlg_desc (WDP_CENTER, WDP_CENTER, 307, 237, 307, 337, WC_SAVELOAD, WC_NONE, WDF_STD_TOOLTIPS|WDF_DEF_WIDGET|WDF_STD_BTN|WDF_UNCLICK_BUTTONS|WDF_RESIZABLE, _newgrf_add_dlg_widgets)
static GRFPresetList | _grf_preset_list
static const Widget | _newgrf_widgets []
static const WindowDesc | _newgrf_desc (WDP_CENTER, WDP_CENTER, 300, 263, 300, 263, WC_GAME_OPTIONS, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET|WDF_UNCLICK_BUTTONS|WDF_RESIZABLE, _newgrf_widgets)

## Detailed Description

GUI to change NewGRF settings.

Definition in 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 763 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 29 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 794 of file newgrf_gui.cpp.

References DeleteWindowByClass().

## Variable Documentation

const Widget _newgrf_add_dlg_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,    RESIZE_NONE,  COLOUR_GREY,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW },
    {    WWT_CAPTION,   RESIZE_RIGHT,  COLOUR_GREY,  11, 306,   0,  13, STR_NEWGRF_ADD_CAPTION,  STR_018C_WINDOW_TITLE_DRAG_THIS },
    {      WWT_PANEL,      RESIZE_RB,  COLOUR_GREY,   0, 294,  14, 121, 0x0,                     STR_NULL },
    {      WWT_INSET,      RESIZE_RB,  COLOUR_GREY,   2, 292,  16, 119, 0x0,                     STR_NULL },
    {  WWT_SCROLLBAR,     RESIZE_LRB,  COLOUR_GREY, 295, 306,  14, 121, 0x0,                     STR_NULL },
    {      WWT_PANEL,     RESIZE_RTB,  COLOUR_GREY,   0, 306, 122, 224, 0x0,                     STR_NULL },
    { WWT_PUSHTXTBTN,     RESIZE_RTB,  COLOUR_GREY,   0, 146, 225, 236, STR_NEWGRF_ADD_FILE,     STR_NEWGRF_ADD_FILE_TIP },
    { WWT_PUSHTXTBTN,    RESIZE_LRTB,  COLOUR_GREY, 147, 294, 225, 236, STR_NEWGRF_RESCAN_FILES, STR_NEWGRF_RESCAN_FILES_TIP },
    {  WWT_RESIZEBOX,    RESIZE_LRTB,  COLOUR_GREY, 295, 306, 225, 236, 0x0,                     STR_RESIZE_BUTTON },
    {   WIDGETS_END },
    }

Definition at line 239 of file newgrf_gui.cpp.

const Widget _newgrf_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,  RESIZE_NONE,  COLOUR_MAUVE,    0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW },
    {    WWT_CAPTION, RESIZE_RIGHT,  COLOUR_MAUVE,   11, 299,   0,  13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },
    {      WWT_PANEL, RESIZE_RIGHT,  COLOUR_MAUVE,    0, 299,  14,  41, STR_NULL,                    STR_NULL },
    {   WWT_DROPDOWN, RESIZE_RIGHT,  COLOUR_YELLOW,  10, 103,  16,  27, STR_EMPTY,                   STR_NEWGRF_PRESET_LIST_TIP },
    { WWT_PUSHTXTBTN,    RESIZE_LR,  COLOUR_YELLOW, 104, 196,  16,  27, STR_NEWGRF_PRESET_SAVE,      STR_NEWGRF_PRESET_SAVE_TIP },
    { WWT_PUSHTXTBTN,    RESIZE_LR,  COLOUR_YELLOW, 197, 289,  16,  27, STR_NEWGRF_PRESET_DELETE,    STR_NEWGRF_PRESET_DELETE_TIP },
    {      WWT_PANEL, RESIZE_RIGHT,  COLOUR_MAUVE,    0, 299,  30,  45, STR_NULL,                    STR_NULL },
    { WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_YELLOW,  10,  79,  32,  43, STR_NEWGRF_ADD,              STR_NEWGRF_ADD_TIP },
    { WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_YELLOW,  80, 149,  32,  43, STR_NEWGRF_REMOVE,           STR_NEWGRF_REMOVE_TIP },
    { WWT_PUSHTXTBTN,  RESIZE_NONE,  COLOUR_YELLOW, 150, 219,  32,  43, STR_NEWGRF_MOVEUP,           STR_NEWGRF_MOVEUP_TIP },
    { WWT_PUSHTXTBTN, RESIZE_RIGHT,  COLOUR_YELLOW, 220, 289,  32,  43, STR_NEWGRF_MOVEDOWN,         STR_NEWGRF_MOVEDOWN_TIP },
    {     WWT_MATRIX,    RESIZE_RB,  COLOUR_MAUVE,    0, 287,  46, 115, 0x501,                       STR_NEWGRF_FILE_TIP },
    {  WWT_SCROLLBAR,   RESIZE_LRB,  COLOUR_MAUVE,  288, 299,  46, 115, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST },
    {      WWT_PANEL,   RESIZE_RTB,  COLOUR_MAUVE,    0, 299, 116, 238, STR_NULL,                    STR_NULL },
    { WWT_PUSHTXTBTN,    RESIZE_TB,  COLOUR_MAUVE,    0,  99, 239, 250, STR_NEWGRF_SET_PARAMETERS,   STR_NULL },
    { WWT_PUSHTXTBTN,   RESIZE_RTB,  COLOUR_MAUVE,  100, 199, 239, 250, STR_NEWGRF_TOGGLE_PALETTE,   STR_NEWGRF_TOGGLE_PALETTE_TIP },
    { WWT_PUSHTXTBTN,   RESIZE_RTB,  COLOUR_MAUVE,  200, 299, 239, 250, STR_NEWGRF_APPLY_CHANGES,    STR_NULL },
    { WWT_PUSHTXTBTN,   RESIZE_RTB,  COLOUR_MAUVE,    0, 287, 251, 262, STR_CONTENT_INTRO_BUTTON,    STR_CONTENT_INTRO_BUTTON_TIP },
    {  WWT_RESIZEBOX,  RESIZE_LRTB,  COLOUR_MAUVE,  288, 299, 251, 262, 0x0,                         STR_RESIZE_BUTTON },
    { WIDGETS_END },
    }

Definition at line 728 of file newgrf_gui.cpp.