Data Structures | Enumerations | Functions | Variables

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 "gamelog.h"
#include "settings_type.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 "core/geometry_func.hpp"
#include "newgrf_text.h"
#include "fileio_func.h"
#include "table/strings.h"
#include "table/sprites.h"

Go to the source code of this file.

Data Structures

struct  NewGRFParametersWindow
 Window for setting the parameters of a NewGRF. More...
class  DropDownListPresetItem
struct  NewGRFWindow
 Window for showing NewGRF files. More...
class  NWidgetNewGRFDisplay
 Custom nested widget container for the NewGRF gui. More...

Enumerations

enum  ShowNewGRFParametersWidgets {
  GRFPAR_WIDGET_SHOW_NUMPAR, GRFPAR_WIDGET_NUMPAR_DEC, GRFPAR_WIDGET_NUMPAR_INC, GRFPAR_WIDGET_NUMPAR,
  GRFPAR_WIDGET_NUMPAR_TEXT, GRFPAR_WIDGET_BACKGROUND, GRFPAR_WIDGET_SCROLLBAR, GRFPAR_WIDGET_ACCEPT,
  GRFPAR_WIDGET_RESET, GRFPAR_WIDGET_SHOW_DESCRIPTION, GRFPAR_WIDGET_DESCRIPTION
}
 

Enum referring to the widgets of the NewGRF parameters window.

More...
enum  ShowNewGRFStateWidgets {
  SNGRFS_PRESET_LIST, SNGRFS_PRESET_SAVE, SNGRFS_PRESET_DELETE, SNGRFS_ADD,
  SNGRFS_REMOVE, SNGRFS_MOVE_UP, SNGRFS_MOVE_DOWN, SNGRFS_FILTER,
  SNGRFS_FILE_LIST, SNGRFS_SCROLLBAR, SNGRFS_AVAIL_LIST, SNGRFS_SCROLL2BAR,
  SNGRFS_NEWGRF_INFO_TITLE, SNGRFS_NEWGRF_INFO, SNGRFS_SET_PARAMETERS, SNGRFS_TOGGLE_PALETTE,
  SNGRFS_APPLY_CHANGES, SNGRFS_RESCAN_FILES, SNGRFS_RESCAN_FILES2, SNGRFS_CONTENT_DOWNLOAD,
  SNGRFS_CONTENT_DOWNLOAD2, SNGRFS_SHOW_REMOVE, SNGRFS_SHOW_APPLY
}
 

Names of the manage newgrfs window widgets.

More...

Functions

void ShowNewGRFError ()
 Show the first NewGRF error we can find.
static void ShowNewGRFInfo (const GRFConfig *c, uint x, uint y, uint right, uint bottom, bool show_params)
void OpenGRFParameterWindow (GRFConfig *c)
static void NewGRFConfirmationCallback (Window *w, bool confirmed)
 Callback function for the newgrf 'apply changes' confirmation window.
NWidgetBaseNewGRFDisplay (int *biggest_index)
 Construct nested container widget for managing the lists and the info panel of the NewGRF GUI.
void ShowNewGRFSettings (bool editable, bool show_params, bool exec_changes, GRFConfig **config)
 Setup the NewGRF gui.

Variables

static const NWidgetPart _nested_newgrf_parameter_widgets []
static const WindowDesc _newgrf_parameters_desc (WDP_CENTER, 500, 208, WC_GRF_PARAMETERS, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_newgrf_parameter_widgets, lengthof(_nested_newgrf_parameter_widgets))
static GRFPresetList _grf_preset_list
static const NWidgetPart _nested_newgrf_actives_widgets []
static const NWidgetPart _nested_newgrf_availables_widgets []
static const NWidgetPart _nested_newgrf_infopanel_widgets []
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 referring to the widgets of the NewGRF parameters window.

Enumerator:
GRFPAR_WIDGET_SHOW_NUMPAR 

NWID_SELECTION to optionally display GRFPAR_WIDGET_NUMPAR

GRFPAR_WIDGET_NUMPAR_DEC 

Button to decrease number of parameters.

GRFPAR_WIDGET_NUMPAR_INC 

Button to increase number of parameters.

GRFPAR_WIDGET_NUMPAR 

Optional number of parameters.

GRFPAR_WIDGET_NUMPAR_TEXT 

Text description.

GRFPAR_WIDGET_BACKGROUND 

Panel to draw the settings on.

GRFPAR_WIDGET_SCROLLBAR 

Scrollbar to scroll through all settings.

GRFPAR_WIDGET_ACCEPT 

Accept button.

GRFPAR_WIDGET_RESET 

Reset button.

GRFPAR_WIDGET_SHOW_DESCRIPTION 

NWID_SELECTION to optionally display parameter descriptions

GRFPAR_WIDGET_DESCRIPTION 

Multi-line description of a parameter.

Definition at line 136 of file newgrf_gui.cpp.

Names of the manage newgrfs window widgets.

Enumerator:
SNGRFS_SHOW_REMOVE 

Select active list buttons (0 = normal, 1 = simple layout).

SNGRFS_SHOW_APPLY 

Select display of the buttons below the 'details'.

Definition at line 485 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 1647 of file newgrf_gui.cpp.

References _grfconfig, NewGRFWindow::active_sel, NewGRFWindow::actives, NewGRFWindow::avails, CopyGRFConfigList(), DeleteWindowByClass(), GamelogGRFUpdate(), GamelogStartAction(), GamelogStopAction(), GLAT_GRF, Window::InvalidateData(), GRFConfig::next, NewGRFWindow::orig_list, ReInitAllWindows(), and ReloadNewGRFData().

NWidgetBase* NewGRFDisplay ( int *  biggest_index  ) 

Construct nested container widget for managing the lists and the info panel of the NewGRF GUI.

Definition at line 1604 of file newgrf_gui.cpp.

References lengthof, MakeNWidgets(), and max().

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

References DeleteWindowByClass().

Referenced by SelectGameWindow::OnClick().


Variable Documentation

const NWidgetPart _nested_newgrf_infopanel_widgets[] [static]
Initial value:
 {
  
  NWidget(WWT_PANEL, COLOUR_MAUVE), SetPadding(0, 0, 2, 0),
    NWidget(WWT_EMPTY, COLOUR_MAUVE, SNGRFS_NEWGRF_INFO_TITLE), SetFill(1, 0), SetResize(1, 0),
    NWidget(WWT_EMPTY, COLOUR_MAUVE, SNGRFS_NEWGRF_INFO), SetFill(1, 1), SetResize(1, 1), SetMinimalSize(150, 100),
  EndContainer(),
  NWidget(NWID_SELECTION, INVALID_COLOUR, SNGRFS_SHOW_APPLY),
    
    NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(0, WD_RESIZEBOX_WIDTH, 0),
      NWidget(NWID_VERTICAL),
        NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_SET_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
            SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
        NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_TOGGLE_PALETTE), SetFill(1, 0), SetResize(1, 0),
            SetDataTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
      EndContainer(),
      NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, SNGRFS_APPLY_CHANGES), SetFill(1, 0), SetResize(1, 0),
          SetDataTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES, STR_NULL),
    EndContainer(),
  EndContainer(),
}

Definition at line 1582 of file newgrf_gui.cpp.

const NWidgetPart _nested_newgrf_parameter_widgets[] [static]
Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
    NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_PARAMETERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
  EndContainer(),
  NWidget(NWID_SELECTION, INVALID_COLOUR, GRFPAR_WIDGET_SHOW_NUMPAR),
    NWidget(WWT_PANEL, COLOUR_MAUVE), SetResize(1, 0), SetFill(1, 0), SetPIP(4, 0, 4),
      NWidget(NWID_HORIZONTAL), SetPIP(4, 0, 4),
        NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, GRFPAR_WIDGET_NUMPAR_DEC), SetMinimalSize(12, 12), SetDataTip(AWV_DECREASE, STR_NULL),
        NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, GRFPAR_WIDGET_NUMPAR_INC), SetMinimalSize(12, 12), SetDataTip(AWV_INCREASE, STR_NULL),
        NWidget(WWT_TEXT, COLOUR_MAUVE, GRFPAR_WIDGET_NUMPAR), SetResize(1, 0), SetFill(1, 0), SetPadding(0, 0, 0, 4), SetDataTip(STR_NEWGRF_PARAMETERS_NUM_PARAM, STR_NULL),
      EndContainer(),
    EndContainer(),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_MATRIX, COLOUR_MAUVE, GRFPAR_WIDGET_BACKGROUND), SetMinimalSize(188, 182), SetResize(1, 1), SetFill(1, 0), SetDataTip(0x501, STR_NULL), SetScrollbar(GRFPAR_WIDGET_SCROLLBAR),
    NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, GRFPAR_WIDGET_SCROLLBAR),
  EndContainer(),
  NWidget(NWID_SELECTION, INVALID_COLOUR, GRFPAR_WIDGET_SHOW_DESCRIPTION),
    NWidget(WWT_PANEL, COLOUR_MAUVE, GRFPAR_WIDGET_DESCRIPTION), SetResize(1, 0), SetFill(1, 0),
    EndContainer(),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
      NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, GRFPAR_WIDGET_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NEWGRF_PARAMETERS_CLOSE, STR_NULL),
      NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, GRFPAR_WIDGET_RESET), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NEWGRF_PARAMETERS_RESET, STR_NEWGRF_PARAMETERS_RESET_TOOLTIP),
    EndContainer(),
    NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
  EndContainer(),
}

Definition at line 418 of file newgrf_gui.cpp.

const NWidgetPart _nested_newgrf_widgets[] [static]
Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
    NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
  EndContainer(),
  NWidget(WWT_PANEL, COLOUR_MAUVE),
    NWidgetFunction(NewGRFDisplay), SetPadding(WD_RESIZEBOX_WIDTH, WD_RESIZEBOX_WIDTH, 2, WD_RESIZEBOX_WIDTH),
    
    NWidget(NWID_HORIZONTAL),
      NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
      NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
    EndContainer(),
  EndContainer(),
}

Definition at line 1619 of file newgrf_gui.cpp.