industry_gui.cpp File Reference

GUIs related to industries. More...

#include "stdafx.h"
#include "gui.h"
#include "sound_func.h"
#include "window_func.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "industry.h"
#include "town.h"
#include "cheat_type.h"
#include "newgrf_industries.h"
#include "newgrf_text.h"
#include "newgrf_debug.h"
#include "strings_func.h"
#include "company_func.h"
#include "tilehighlight_func.h"
#include "string_func.h"
#include "sortlist_type.h"
#include "widgets/dropdown_func.h"
#include "company_base.h"
#include "core/geometry_func.hpp"
#include "core/random_func.hpp"
#include "core/backup_type.hpp"
#include "genworld.h"
#include "smallmap_gui.h"
#include "table/strings.h"
#include "table/sprites.h"

Go to the source code of this file.

Data Structures

class  BuildIndustryWindow
 Build (fund or prospect) a new industry,. More...
class  IndustryViewWindow
class  IndustryDirectoryWindow
 The list of industries. More...
struct  CargoesField
 Data about a single field in the IndustryCargoesWindow panel. More...
struct  CargoesRow
 A single row of CargoesField. More...
struct  IndustryCargoesWindow
 Window displaying the cargo connections around an industry (or cargo). More...

Typedefs

typedef GUIList< const Industry * > GUIIndustryList

Enumerations

enum  CargoSuffixType { CST_FUND, CST_VIEW, CST_DIR }
 

Cargo suffix type (for which window is it requested).

More...
enum  DynamicPlaceIndustriesWidgets {
  DPIW_MATRIX_WIDGET, DPIW_SCROLLBAR, DPIW_INFOPANEL, DPIW_DISPLAY_WIDGET,
  DPIW_FUND_WIDGET
}
 

Names of the widgets of the dynamic place industries gui.


enum  IndustryViewWidgets {
  IVW_CAPTION, IVW_VIEWPORT, IVW_INFO, IVW_GOTO,
  IVW_DISPLAY
}
 

Names of the widgets of the view industry gui.


enum  IndustryDirectoryWidgets { IDW_DROPDOWN_ORDER, IDW_DROPDOWN_CRITERIA, IDW_INDUSTRY_LIST, IDW_SCROLLBAR }
 

Names of the widgets of the industry directory gui.


enum  IndustryCargoesWidgets { ICW_CAPTION, ICW_NOTIFY, ICW_PANEL, ICW_SCROLLBAR }
 

Widget numbers of the industry cargoes window,.


enum  CargoesFieldType {
  CFT_EMPTY, CFT_SMALL_EMPTY, CFT_INDUSTRY, CFT_CARGO,
  CFT_CARGO_LABEL, CFT_HEADER
}
 

Available types of field.

More...

Functions

 assert_compile (NUM_INDUSTRYTYPES<=64)
static void ShowIndustryCargoesWindow (IndustryType id)
 Open the industry and cargoes window.
static void GetCargoSuffix (uint cargo, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, char *suffix, const char *suffix_last)
 Gets the string to display after the cargo name (using callback 37).
template<typename TC , typename TS >
static void GetAllCargoSuffixes (uint cb_offset, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, const TC &cargos, TS &suffixes)
 Gets all strings to display after the cargos of industries (using callback 37).
static int CDECL IndustryTypeNameSorter (const IndustryType *a, const IndustryType *b)
 Sort industry types by their name.
void SortIndustryTypes ()
 Initialize the list of sorted industry types.
void CcBuildIndustry (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 Command callback.
void ShowBuildIndustryWindow ()
static void UpdateIndustryProduction (Industry *i)
static bool IsProductionAlterable (const Industry *i)
void ShowIndustryViewWindow (int industry)
void ShowIndustryDirectory ()
 assert_compile (MAX_CARGOES >=cpp_lengthof(IndustrySpec, produced_cargo))
 assert_compile (MAX_CARGOES >=cpp_lengthof(IndustrySpec, accepts_cargo))

Variables

bool _ignore_restrictions
uint64 _displayed_industries
 Communication from the industry chain window to the smallmap window about what industries to display.
IndustryType _sorted_industry_types [NUM_INDUSTRYTYPES]
static const NWidgetPart _nested_build_industry_widgets []
static const WindowDesc _build_industry_desc (WDP_AUTO, 170, 212, WC_BUILD_INDUSTRY, WC_NONE, WDF_CONSTRUCTION, _nested_build_industry_widgets, lengthof(_nested_build_industry_widgets))
 Window definition of the dynamic place industries gui.
static const NWidgetPart _nested_industry_view_widgets []
 Widget definition of the view industry gui.
static const WindowDesc _industry_view_desc (WDP_AUTO, 260, 120, WC_INDUSTRY_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_industry_view_widgets, lengthof(_nested_industry_view_widgets))
 Window definition of the view industry gui.
static const NWidgetPart _nested_industry_directory_widgets []
 Widget definition of the industry directory gui.
static const WindowDesc _industry_directory_desc (WDP_AUTO, 428, 190, WC_INDUSTRY_DIRECTORY, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_industry_directory_widgets, lengthof(_nested_industry_directory_widgets))
 Window definition of the industry directory gui.
static const NWidgetPart _nested_industry_cargoes_widgets []
 Widgets of the industry cargoes window.
static const WindowDesc _industry_cargoes_desc (WDP_AUTO, 300, 210, WC_INDUSTRY_CARGOES, WC_NONE, 0, _nested_industry_cargoes_widgets, lengthof(_nested_industry_cargoes_widgets))
 Window description for the industry cargoes window.
static const uint MAX_CARGOES = 3
 Maximum number of cargoes carried in a CFT_CARGO field in CargoesField.

Detailed Description

GUIs related to industries.

Definition in file industry_gui.cpp.


Enumeration Type Documentation

Available types of field.

Enumerator:
CFT_EMPTY 

Empty field.

CFT_SMALL_EMPTY 

Empty small field (for the header).

CFT_INDUSTRY 

Display industry.

CFT_CARGO 

Display cargo connections.

CFT_CARGO_LABEL 

Display cargo labels.

CFT_HEADER 

Header text.

Definition at line 1452 of file industry_gui.cpp.

Cargo suffix type (for which window is it requested).

Enumerator:
CST_FUND 

Fund-industry window.

CST_VIEW 

View-industry window.

CST_DIR 

Industry-directory window.

Definition at line 48 of file industry_gui.cpp.


Function Documentation

void CcBuildIndustry ( const CommandCost result,
TileIndex  tile,
uint32  p1,
uint32  p2 
)

Command callback.

In case of failure to build an industry, show an error message.

Parameters:
result Result of the command.
tile Tile where the industry is placed.
p1 Additional data of the CMD_BUILD_INDUSTRY command.
p2 Additional data of the CMD_BUILD_INDUSTRY command.

Definition at line 149 of file industry_gui.cpp.

References IndustrySpec::enabled, GB(), CommandCost::GetErrorMessage(), GetIndustrySpec(), IndustrySpec::name, NUM_INDUSTRYTYPES, SetDParam(), ShowErrorMessage(), CommandCost::Succeeded(), TILE_SIZE, TileX(), TileY(), and WL_INFO.

Referenced by BuildIndustryWindow::OnPlaceObject().

template<typename TC , typename TS >
static void GetAllCargoSuffixes ( uint  cb_offset,
CargoSuffixType  cst,
const Industry ind,
IndustryType  ind_type,
const IndustrySpec indspec,
const TC &  cargos,
TS &  suffixes 
) [inline, static]

Gets all strings to display after the cargos of industries (using callback 37).

Parameters:
cb_offset The offset for the cargo used in cb37, 0 for accepted cargos, 3 for produced cargos
cst the cargo suffix type (for which window is it requested).
See also:
CargoSuffixType
Parameters:
ind the industry (NULL if in fund window)
ind_type the industry type
indspec the industry spec
cargos array with cargotypes. for CT_INVALID no suffix will be determined
suffixes is filled with the suffixes

Definition at line 95 of file industry_gui.cpp.

References CT_INVALID, GetCargoSuffix(), lastof, and lengthof.

Referenced by IndustryViewWindow::DrawInfo(), BuildIndustryWindow::DrawWidget(), IndustryDirectoryWindow::GetIndustryString(), and BuildIndustryWindow::UpdateWidgetSize().

static void GetCargoSuffix ( uint  cargo,
CargoSuffixType  cst,
const Industry ind,
IndustryType  ind_type,
const IndustrySpec indspec,
char *  suffix,
const char *  suffix_last 
) [static]

Gets the string to display after the cargo name (using callback 37).

Parameters:
cargo the cargo for which the suffix is requested

  • 00 - first accepted cargo type
  • 01 - second accepted cargo type
  • 02 - third accepted cargo type
  • 03 - first produced cargo type
  • 04 - second produced cargo type
cst the cargo suffix type (for which window is it requested).
See also:
CargoSuffixType
Parameters:
ind the industry (NULL if in fund window)
ind_type the industry type
indspec the industry spec
suffix is filled with the string to display
suffix_last lastof(suffix)

Definition at line 71 of file industry_gui.cpp.

References IndustrySpec::callback_mask, CBID_INDUSTRY_CARGO_SUFFIX, CBM_IND_CARGO_SUFFIX, CST_FUND, GB(), GetGRFStringID(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), INVALID_TILE, Industry::location, PrepareTextRefStackUsage(), StopTextRefStackUsage(), and TileArea::tile.

Referenced by GetAllCargoSuffixes().

static int CDECL IndustryTypeNameSorter ( const IndustryType a,
const IndustryType b 
) [static]

Sort industry types by their name.

Definition at line 110 of file industry_gui.cpp.

References GetIndustrySpec(), lastof, IndustrySpec::name, SetDParam(), and strnatcmp().

Referenced by SortIndustryTypes().

static void ShowIndustryCargoesWindow ( IndustryType  id  )  [static]

Open the industry and cargoes window.

Parameters:
id Industry type to display.

Definition at line 2619 of file industry_gui.cpp.

References BringWindowToFrontById(), Window::InvalidateData(), and NUM_INDUSTRYTYPES.

Referenced by IndustryViewWindow::OnClick(), and BuildIndustryWindow::OnClick().


Variable Documentation

const WindowDesc _industry_cargoes_desc(WDP_AUTO, 300, 210, WC_INDUSTRY_CARGOES, WC_NONE, 0, _nested_industry_cargoes_widgets, lengthof(_nested_industry_cargoes_widgets)) [static]

Window description for the industry cargoes window.

const NWidgetPart _nested_build_industry_widgets[] [static]
Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
    NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_FUND_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
    NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, DPIW_MATRIX_WIDGET), SetDataTip(0x801, STR_FUND_INDUSTRY_SELECTION_TOOLTIP), SetFill(1, 0), SetResize(1, 1), SetScrollbar(DPIW_SCROLLBAR),
    NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, DPIW_SCROLLBAR),
  EndContainer(),
  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, DPIW_INFOPANEL), SetResize(1, 0),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, DPIW_DISPLAY_WIDGET), SetFill(1, 0), SetResize(1, 0),
        SetDataTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
    NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, DPIW_FUND_WIDGET), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_JUST_STRING, STR_NULL),
    NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
  EndContainer(),
}

Definition at line 172 of file industry_gui.cpp.

Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
    NWidget(WWT_CAPTION, COLOUR_BROWN, ICW_CAPTION), SetDataTip(STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    NWidget(WWT_SHADEBOX, COLOUR_BROWN),
    NWidget(WWT_STICKYBOX, COLOUR_BROWN),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(NWID_VERTICAL),
      NWidget(WWT_PANEL, COLOUR_BROWN, ICW_PANEL), SetResize(1, 10), SetMinimalSize(200, 90), SetScrollbar(ICW_SCROLLBAR), EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_TEXTBTN, COLOUR_BROWN, ICW_NOTIFY),
          SetDataTip(STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP, STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_TOOLTIP),
        NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 0), SetResize(1, 0), EndContainer(),
      EndContainer(),
    EndContainer(),
    NWidget(NWID_VERTICAL),
      NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, ICW_SCROLLBAR),
      NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
    EndContainer(),
  EndContainer(),
}

Widgets of the industry cargoes window.

Definition at line 1420 of file industry_gui.cpp.

Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
    NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_INDUSTRY_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    NWidget(WWT_SHADEBOX, COLOUR_BROWN),
    NWidget(WWT_STICKYBOX, COLOUR_BROWN),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(NWID_VERTICAL),
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_TEXTBTN, COLOUR_BROWN, IDW_DROPDOWN_ORDER), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
        NWidget(WWT_DROPDOWN, COLOUR_BROWN, IDW_DROPDOWN_CRITERIA), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
        NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0), EndContainer(),
      EndContainer(),
      NWidget(WWT_PANEL, COLOUR_BROWN, IDW_INDUSTRY_LIST), SetDataTip(0x0, STR_INDUSTRY_DIRECTORY_LIST_CAPTION), SetResize(1, 1), SetScrollbar(IDW_SCROLLBAR), EndContainer(),
    EndContainer(),
    NWidget(NWID_VERTICAL),
      NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, IDW_SCROLLBAR),
      NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
    EndContainer(),
  EndContainer(),
}

Widget definition of the industry directory gui.

Definition at line 1041 of file industry_gui.cpp.

Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_CREAM),
    NWidget(WWT_CAPTION, COLOUR_CREAM, IVW_CAPTION), SetDataTip(STR_INDUSTRY_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    NWidget(WWT_DEBUGBOX, COLOUR_CREAM),
    NWidget(WWT_SHADEBOX, COLOUR_CREAM),
    NWidget(WWT_STICKYBOX, COLOUR_CREAM),
  EndContainer(),
  NWidget(WWT_PANEL, COLOUR_CREAM),
    NWidget(WWT_INSET, COLOUR_CREAM), SetPadding(2, 2, 2, 2),
      NWidget(NWID_VIEWPORT, INVALID_COLOUR, IVW_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 0), SetPadding(1, 1, 1, 1), SetResize(1, 1),
    EndContainer(),
  EndContainer(),
  NWidget(WWT_PANEL, COLOUR_CREAM, IVW_INFO), SetMinimalSize(260, 2), SetResize(1, 0),
  EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, IVW_GOTO), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_INDUSTRY_VIEW_LOCATION_TOOLTIP),
    NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, IVW_DISPLAY), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
    NWidget(WWT_RESIZEBOX, COLOUR_CREAM),
  EndContainer(),
}

Widget definition of the view industry gui.

Definition at line 997 of file industry_gui.cpp.


Generated on Sun May 15 19:20:21 2011 for OpenTTD by  doxygen 1.6.1