# newgrf_gui.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "variables.h"`
`#include "gui.h"`
`#include "window_gui.h"`
`#include "textbuf_gui.h"`
`#include "newgrf.h"`
`#include "newgrf_config.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "core/alloc_func.hpp"`
`#include "string_func.h"`
`#include "gfx_func.h"`
`#include "table/strings.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Data Structures

struct | newgrf_add_d
struct | newgrf_d

## Enumerations

enum | AddNewGRFWindowWidgets { ANGRFW_CLOSEBOX = 0, ANGRFW_CAPTION, ANGRFW_BACKGROUND, ANGRFW_GRF_LIST, ANGRFW_SCROLLBAR, ANGRFW_GRF_INFO, ANGRFW_ADD, ANGRFW_RESCAN, ANGRFW_RESIZE }
enum | ShowNewGRFStateWidgets { SNGRFS_CLOSEBOX = 0, SNGRFS_CAPTION, SNGRFS_BACKGROUND, SNGRFS_ADD, SNGRFS_REMOVE, SNGRFS_MOVE_UP, SNGRFS_MOVE_DOWN, SNGRFS_FILE_LIST, SNGRFS_SCROLLBAR, SNGRFS_NEWGRF_INFO, SNGRFS_SET_PARAMETERS, SNGRFS_APPLY_CHANGES, SNGRFS_RESIZE }

## 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 | NewGRFAddDlgWndProc (Window *w, WindowEvent *e)
| assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(newgrf_d))
static void | SetupNewGRFState (Window *w)
static void | SetupNewGRFWindow (Window *w)
static void | NewGRFConfirmationCallback (Window *w, bool confirmed)
| Callback function for the newgrf 'apply changes' confirmation window.
static void | NewGRFWndProc (Window *w, WindowEvent *e)
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
static const Widget | _newgrf_widgets []
static const WindowDesc | _newgrf_desc

## Detailed Description

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 319 of file newgrf_gui.cpp.

References CopyGRFConfigList(), ReloadNewGRFData(), and SetWindowDirty().

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 28 of file newgrf_gui.cpp.

Referenced by load_intlist().

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 578 of file newgrf_gui.cpp.

References AllocateWindowDesc(), and CopyGRFConfigList().

## Variable Documentation

const WindowDesc _newgrf_add_dlg_desc`[static]`

Initial value:

     {
      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,
      NewGRFAddDlgWndProc,
    }

Definition at line 242 of file newgrf_gui.cpp.

const Widget _newgrf_add_dlg_widgets[]`[static]`

Initial value:

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

Definition at line 228 of file newgrf_gui.cpp.

const WindowDesc _newgrf_desc`[static]`

Initial value:

     {
      WDP_CENTER, WDP_CENTER, 300, 225, 300, 225,
      WC_GAME_OPTIONS, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
      _newgrf_widgets,
      NewGRFWndProc,
    }

Definition at line 563 of file newgrf_gui.cpp.

const Widget _newgrf_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,  RESIZE_NONE, 10,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW },
    {    WWT_CAPTION, RESIZE_RIGHT, 10,  11, 299,   0,  13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },
    {      WWT_PANEL, RESIZE_RIGHT, 10,   0, 299,  14,  29, STR_NULL,                    STR_NULL },
    { WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  10,  79,  16,  27, STR_NEWGRF_ADD,              STR_NEWGRF_ADD_TIP },
    { WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  80, 149,  16,  27, STR_NEWGRF_REMOVE,           STR_NEWGRF_REMOVE_TIP },
    { WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 150, 219,  16,  27, STR_NEWGRF_MOVEUP,           STR_NEWGRF_MOVEUP_TIP },
    { WWT_PUSHTXTBTN, RESIZE_RIGHT,  3, 220, 289,  16,  27, STR_NEWGRF_MOVEDOWN,         STR_NEWGRF_MOVEDOWN_TIP },
    {     WWT_MATRIX,    RESIZE_RB, 10,   0, 287,  30,  99, 0x501,                       STR_NEWGRF_FILE_TIP },
    {  WWT_SCROLLBAR,   RESIZE_LRB, 10, 288, 299,  30,  99, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST },
    {      WWT_PANEL,   RESIZE_RTB, 10,   0, 299, 100, 212, STR_NULL,                    STR_NULL },
    { WWT_PUSHTXTBTN,    RESIZE_TB, 10,   0, 143, 213, 224, STR_NEWGRF_SET_PARAMETERS,   STR_NULL },
    { WWT_PUSHTXTBTN,   RESIZE_RTB, 10, 144, 287, 213, 224, STR_NEWGRF_APPLY_CHANGES,    STR_NULL },
    {  WWT_RESIZEBOX,  RESIZE_LRTB, 10, 288, 299, 213, 224, 0x0,                         STR_RESIZE_BUTTON },
    { WIDGETS_END },
    }

Definition at line 545 of file newgrf_gui.cpp.