|
|
/* $Id$ */
|
|
|
|
|
|
/** @file industry_gui.cpp GUIs related to industries. */
|
|
|
|
|
|
#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 "cheat_func.h"
|
|
|
#include "cargotype.h"
|
|
|
#include "cheat_type.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 "company_func.h"
|
|
|
#include "settings_type.h"
|
|
|
#include "tilehighlight_func.h"
|
|
|
#include "string_func.h"
|
|
|
#include "sortlist_type.h"
|
|
|
#include "widgets/dropdown_func.h"
|
|
|
#include "company_base.h"
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
#include "table/sprites.h"
|
|
|
|
|
|
bool _ignore_restrictions;
|
|
|
|
|
|
enum CargoSuffixType {
|
|
|
CST_FUND,
|
|
|
CST_VIEW,
|
|
|
CST_DIR,
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Gets the string to display after the cargo name (using callback 37)
|
|
|
* @param 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
|
|
|
* @param cst the cargo suffix type (for which window is it requested)
|
|
|
* @param ind the industry (NULL if in fund window)
|
|
|
* @param ind_type the industry type
|
|
|
* @param indspec the industry spec
|
|
|
* @return the string to display
|
|
|
*/
|
|
|
static StringID GetCargoSuffix(uint cargo, CargoSuffixType cst, Industry *ind, IndustryType ind_type, const IndustrySpec *indspec)
|
|
|
{
|
|
|
if (HasBit(indspec->callback_flags, CBM_IND_CARGO_SUFFIX)) {
|
|
|
uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, ind, ind_type, (cst != CST_FUND) ? ind->xy : INVALID_TILE);
|
|
|
if (GB(callback, 0, 8) != 0xFF) return GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback);
|
|
|
}
|
|
|
return STR_EMPTY;
|
|
|
}
|
|
|
|
|
|
/** Names of the widgets of the dynamic place industries gui */
|
|
|
enum DynamicPlaceIndustriesWidgets {
|
|
|
DPIW_CLOSEBOX = 0,
|
|
|
DPIW_CAPTION,
|
|
|
DPIW_MATRIX_WIDGET,
|
|
|
DPIW_SCROLLBAR,
|
|
|
DPIW_INFOPANEL,
|
|
|
DPIW_FUND_WIDGET,
|