# industry_gui.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "debug.h"`
`#include "gui.h"`
`#include "window_gui.h"`
`#include "textbuf_gui.h"`
`#include "command_func.h"`
`#include "viewport_func.h"`
`#include "gfx_func.h"`
`#include "industry.h"`
`#include "town.h"`
`#include "variables.h"`
`#include "cargotype.h"`
`#include "newgrf.h"`
`#include "newgrf_callbacks.h"`
`#include "newgrf_industries.h"`
`#include "newgrf_text.h"`
`#include "strings_func.h"`
`#include "map_func.h"`
`#include "player_func.h"`
`#include "settings_type.h"`
`#include "table/strings.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Data Structures
struct | fnd_d
| Attached struct to the window extended data. More...
struct | IndustryData
| Helper struct holding the available industries for current situation. More...
struct | indview_d
| Information to store about the industry window. More...
## Enumerations
enum | DynamicPlaceIndustriesWidgets { DPIW_CLOSEBOX = 0, DPIW_CAPTION, DPIW_MATRIX_WIDGET, DPIW_SCROLLBAR, DPIW_INFOPANEL, DPIW_FUND_WIDGET, DPIW_RESIZE_WIDGET }
| Names of the widgets of the dynamic place industries gui.
enum | IndustryViewWidgets { IVW_CLOSEBOX = 0, IVW_CAPTION, IVW_STICKY, IVW_BACKGROUND, IVW_VIEWPORT, IVW_INFO, IVW_GOTO, IVW_SPACER, IVW_RESIZE_WIDGET }
| Names of the widgets of the view industry gui.
enum | IndustryDirectoryWidgets { IDW_CLOSEBOX = 0, IDW_CAPTION, IDW_STICKY, IDW_SORTBYNAME, IDW_SORTBYTYPE, IDW_SORTBYPROD, IDW_SORTBYTRANSPORT, IDW_SPACER, IDW_INDUSRTY_LIST, IDW_SCROLLBAR, IDW_RESIZE }
| Names of the widgets of the industry directory gui.
## Functions
| assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(fnd_d))
| assert_compile (lengthof(_fund_gui.index)==lengthof(_fund_gui.text))
static void | SetupFundArrays (Window *w)
static void | BuildDynamicIndustryWndProc (Window *w, WindowEvent *e)
void | ShowBuildIndustryWindow ()
static void | UpdateIndustryProduction (Industry *i)
static bool | isProductionMinimum (const Industry *i, int pt)
static bool | isProductionMaximum (const Industry *i, int pt)
static bool | IsProductionAlterable (const Industry *i)
| assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(indview_d))
static void | IndustryViewWndProc (Window *w, WindowEvent *e)
void | ShowIndustryViewWindow (int industry)
static int CDECL | GeneralIndustrySorter (const void *a, const void *b)
static void | MakeSortedIndustryList ()
| Makes a sorted industry list.
static void | IndustryDirectoryWndProc (Window *w, WindowEvent *e)
void | ShowIndustryDirectory ()
## Variables
bool | _ignore_restrictions
static struct IndustryData | _fund_gui
| Helper struct holding the available industries for current situation.
static const Widget | _build_dynamic_industry_widgets []
| Widget definition of the dynamic place industries gui.
static const WindowDesc | _build_industry_dynamic_desc
| Window definition of the dynamic place industries gui.
static const Widget | _industry_view_widgets []
| Widget definition of the view industy gui.
static const WindowDesc | _industry_view_desc
| Window definition of the view industy gui.
static const Widget | _industry_directory_widgets []
| Widget definition of the industy directory gui.
static uint | _num_industry_sort
static char | _bufcache [96]
static const Industry * | _last_industry
static byte | _industry_sort_order
static const WindowDesc | _industry_directory_desc
| Window definition of the industy directory gui.

## Detailed Description

Definition in file industry_gui.cpp.

## Function Documentation

static void MakeSortedIndustryList | ( |  | ) | `[static]`

Makes a sorted industry list.

When there are no industries, the list has to be made. This so when one starts a new game without industries after playing a game with industries the list is not populated with invalid industries from the previous game.

Definition at line 804 of file industry_gui.cpp.

References ReallocT().

## Variable Documentation

const Widget _build_dynamic_industry_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,    RESIZE_NONE,    7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_RIGHT,    7,    11,   169,     0,    13, STR_0314_FUND_NEW_INDUSTRY,     STR_018C_WINDOW_TITLE_DRAG_THIS},
    {     WWT_MATRIX,      RESIZE_RB,    7,     0,   157,    14,   118, 0x801,                          STR_INDUSTRY_SELECTION_HINT},
    {  WWT_SCROLLBAR,     RESIZE_LRB,    7,   158,   169,    14,   118, 0x0,                            STR_0190_SCROLL_BAR_SCROLLS_LIST},
    {      WWT_PANEL,     RESIZE_RTB,    7,     0,   169,   119,   199, 0x0,                            STR_NULL},
    {    WWT_TEXTBTN,     RESIZE_RTB,    7,     0,   157,   200,   211, STR_FUND_NEW_INDUSTRY,          STR_NULL},
    {  WWT_RESIZEBOX,    RESIZE_LRTB,    7,   158,   169,   200,   211, 0x0,                            STR_RESIZE_BUTTON},
    {   WIDGETS_END},
    }

Widget definition of the dynamic place industries gui.

Definition at line 360 of file industry_gui.cpp.

const WindowDesc _build_industry_dynamic_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 170, 212, 170, 212,
      WC_BUILD_INDUSTRY, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
      _build_dynamic_industry_widgets,
      BuildDynamicIndustryWndProc,
    }

Window definition of the dynamic place industries gui.

Definition at line 372 of file industry_gui.cpp.

const WindowDesc _industry_directory_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 508, 190, 508, 190,
      WC_INDUSTRY_DIRECTORY, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
      _industry_directory_widgets,
      IndustryDirectoryWndProc
    }

Window definition of the industy directory gui.

Definition at line 918 of file industry_gui.cpp.

const Widget _industry_directory_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,    13,    11,   495,     0,    13, STR_INDUSTRYDIR_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
    {  WWT_STICKYBOX,   RESIZE_NONE,    13,   496,   507,     0,    13, 0x0,                     STR_STICKY_BUTTON},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    13,     0,   100,    14,    25, STR_SORT_BY_NAME,        STR_SORT_ORDER_TIP},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   101,   200,    14,    25, STR_SORT_BY_TYPE,        STR_SORT_ORDER_TIP},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   201,   300,    14,    25, STR_SORT_BY_PRODUCTION,  STR_SORT_ORDER_TIP},
    { WWT_PUSHTXTBTN,   RESIZE_NONE,    13,   301,   400,    14,    25, STR_SORT_BY_TRANSPORTED, STR_SORT_ORDER_TIP},
    {      WWT_PANEL,   RESIZE_NONE,    13,   401,   495,    14,    25, 0x0,                     STR_NULL},
    {      WWT_PANEL, RESIZE_BOTTOM,    13,     0,   495,    26,   189, 0x0,                     STR_INDUSTRYDIR_LIST_CAPTION},
    {  WWT_SCROLLBAR, RESIZE_BOTTOM,    13,   496,   507,    14,   177, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST},
    {  WWT_RESIZEBOX,     RESIZE_TB,    13,   496,   507,   178,   189, 0x0,                     STR_RESIZE_BUTTON},
    {   WIDGETS_END},
    }

Widget definition of the industy directory gui.

Definition at line 699 of file industry_gui.cpp.

const WindowDesc _industry_view_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 260, 160, 260, 160,
      WC_INDUSTRY_VIEW, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
      _industry_view_widgets,
      IndustryViewWndProc
    }

Window definition of the view industy gui.

Definition at line 662 of file industry_gui.cpp.

const Widget _industry_view_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX,   RESIZE_NONE,     9,     0,    10,     0,    13, STR_00C5,          STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION,   RESIZE_NONE,     9,    11,   247,     0,    13, STR_4801,          STR_018C_WINDOW_TITLE_DRAG_THIS},
    {  WWT_STICKYBOX,   RESIZE_NONE,     9,   248,   259,     0,    13, 0x0,               STR_STICKY_BUTTON},
    {      WWT_PANEL,   RESIZE_NONE,     9,     0,   259,    14,   105, 0x0,               STR_NULL},
    {      WWT_INSET,   RESIZE_NONE,     9,     2,   257,    16,   103, 0x0,               STR_NULL},
    {      WWT_PANEL, RESIZE_BOTTOM,     9,     0,   259,   106,   147, 0x0,               STR_NULL},
    { WWT_PUSHTXTBTN,     RESIZE_TB,     9,     0,   129,   148,   159, STR_00E4_LOCATION, STR_482C_CENTER_THE_MAIN_VIEW_ON},
    {      WWT_PANEL,     RESIZE_TB,     9,   130,   247,   148,   159, 0x0,               STR_NULL},
    {  WWT_RESIZEBOX,     RESIZE_TB,     9,   248,   259,   148,   159, 0x0,               STR_RESIZE_BUTTON},
    {   WIDGETS_END},
    }

Widget definition of the view industy gui.

Definition at line 648 of file industry_gui.cpp.