|
OpenTTD Source 20251104-master-g3befbdd52f
|
GUIs related to industries. More...
#include "stdafx.h"#include <ranges>#include "error.h"#include "gui.h"#include "settings_gui.h"#include "sound_func.h"#include "window_func.h"#include "textbuf_gui.h"#include "command_func.h"#include "viewport_func.h"#include "industry.h"#include "town.h"#include "cheat_type.h"#include "newgrf_badge.h"#include "newgrf_badge_gui.h"#include "newgrf_industries.h"#include "newgrf_text.h"#include "newgrf_debug.h"#include "network/network.h"#include "strings_func.h"#include "company_func.h"#include "tilehighlight_func.h"#include "string_func.h"#include "sortlist_type.h"#include "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 "dropdown_type.h"#include "clear_map.h"#include "zoom_func.h"#include "industry_cmd.h"#include "graph_gui.h"#include "querystring_gui.h"#include "stringfilter_type.h"#include "timer/timer.h"#include "timer/timer_window.h"#include "hotkeys.h"#include "core/string_consumer.hpp"#include "widgets/industry_widget.h"#include "table/strings.h"#include <bitset>#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | CargoSuffix |
| Transfer storage of cargo suffix information. More... | |
| 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 *, const CargoType &, const std::pair< CargoType, CargoType > & > | GUIIndustryList |
Enumerations | |
| enum | CargoSuffixType : uint8_t { CST_FUND , CST_VIEW , CST_DIR } |
| Cargo suffix type (for which window is it requested) More... | |
| enum | CargoSuffixDisplay : uint8_t { CSD_CARGO , CSD_CARGO_AMOUNT , CSD_CARGO_TEXT , CSD_CARGO_AMOUNT_TEXT } |
| Ways of displaying the cargo. More... | |
| enum | CargoSuffixInOut : uint8_t { CARGOSUFFIX_OUT = 0 , CARGOSUFFIX_IN = 1 } |
| enum | CargoesFieldType : uint8_t { CFT_EMPTY , CFT_SMALL_EMPTY , CFT_INDUSTRY , CFT_CARGO , CFT_CARGO_LABEL , CFT_HEADER } |
| Available types of field. More... | |
Functions | |
| void | GenerateIndustries () |
| This function will create random industries during game creation. | |
| 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, CargoSuffix &suffix) |
| Gets the string to display after the cargo name (using callback 37) | |
| template<typename TC , typename TS > | |
| static void | GetAllCargoSuffixes (CargoSuffixInOut use_input, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, const TC &cargoes, TS &suffixes) |
| Gets all strings to display after the cargoes of industries (using callback 37) | |
| void | GetCargoSuffix (CargoSuffixInOut use_input, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, CargoType cargo, uint8_t slot, CargoSuffix &suffix) |
| Gets the strings to display after the cargo of industries (using callback 37) | |
| static bool | IndustryTypeNameSorter (const IndustryType &a, const IndustryType &b) |
| Sort industry types by their name. | |
| void | SortIndustryTypes () |
| Initialize the list of sorted industry types. | |
| void | ShowBuildIndustryWindow () |
| static void | UpdateIndustryProduction (Industry *i) |
| static bool | IsProductionAlterable (const Industry *i) |
| void | ShowIndustryViewWindow (IndustryID industry) |
| static bool | CargoFilter (const Industry *const *industry, const std::pair< CargoType, CargoType > &cargoes) |
| Cargo filter functions. | |
| void | ShowIndustryDirectory () |
| void | ShowIndustryCargoesWindow () |
| Open the industry and cargoes window with an industry. | |
Variables | |
| bool | _ignore_industry_restrictions |
| std::bitset< NUM_INDUSTRYTYPES > | _displayed_industries |
| Communication from the industry chain window to the smallmap window about what industries to display. | |
| std::array< IndustryType, NUM_INDUSTRYTYPES > | _sorted_industry_types |
| Industry types sorted by name. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_build_industry_widgets |
| static WindowDesc | _build_industry_desc (WDP_AUTO, "build_industry", 170, 212, WC_BUILD_INDUSTRY, WC_NONE, WindowDefaultFlag::Construction, _nested_build_industry_widgets) |
| Window definition of the dynamic place industries gui. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_industry_view_widgets |
| Widget definition of the view industry gui. | |
| static WindowDesc | _industry_view_desc (WDP_AUTO, "view_industry", 260, 120, WC_INDUSTRY_VIEW, WC_NONE, {}, _nested_industry_view_widgets) |
| Window definition of the view industry gui. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_industry_directory_widgets |
| Widget definition of the industry directory gui. | |
| static GUIIndustryList::FilterFunction *const | _industry_filter_funcs [] = { &CargoFilter } |
| static WindowDesc | _industry_directory_desc (WDP_AUTO, "list_industries", 428, 190, WC_INDUSTRY_DIRECTORY, WC_NONE, {}, _nested_industry_directory_widgets, &IndustryDirectoryWindow::hotkeys) |
| Window definition of the industry directory gui. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_industry_cargoes_widgets |
| Widgets of the industry cargoes window. | |
| static WindowDesc | _industry_cargoes_desc (WDP_AUTO, "industry_cargoes", 300, 210, WC_INDUSTRY_CARGOES, WC_NONE, {}, _nested_industry_cargoes_widgets) |
| Window description for the industry cargoes window. | |
| static const uint | MAX_CARGOES = 16 |
| Maximum number of cargoes carried in a CFT_CARGO field in CargoesField. | |
GUIs related to industries.
Definition in file industry_gui.cpp.
| typedef GUIList<const Industry *, const CargoType &, const std::pair<CargoType, CargoType> &> GUIIndustryList |
Definition at line 1276 of file industry_gui.cpp.
| enum CargoesFieldType : uint8_t |
Available types of field.
Definition at line 1967 of file industry_gui.cpp.
| enum CargoSuffixDisplay : uint8_t |
Ways of displaying the cargo.
Definition at line 72 of file industry_gui.cpp.
| enum CargoSuffixInOut : uint8_t |
Definition at line 152 of file industry_gui.cpp.
| enum CargoSuffixType : uint8_t |
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 65 of file industry_gui.cpp.
|
static |
Cargo filter functions.
Check whether an industry accepts and produces a certain cargo pair.
| industry | The industry whose cargoes will being checked. |
| cargoes | The accepted and produced cargo pair to look for. |
Definition at line 1285 of file industry_gui.cpp.
References CargoFilterCriteria::CF_ANY, and CargoFilterCriteria::CF_NONE.
|
extern |
This function will create random industries during game creation.
It will scale the amount of industries by mapsize and difficulty level.
Definition at line 2481 of file industry_cmd.cpp.
|
inlinestatic |
Gets all strings to display after the cargoes of industries (using callback 37)
| use_input | get suffixes for output cargoes or input cargoes? |
| cst | the cargo suffix type (for which window is it requested). |
| ind | the industry (nullptr if in fund window) |
| ind_type | the industry type |
| indspec | the industry spec |
| cargoes | array with cargotypes. for INVALID_CARGO no suffix will be determined |
| suffixes | is filled with the suffixes |
Definition at line 168 of file industry_gui.cpp.
References IndustrySpec::behaviour, GRFFile::cargo_map, CargoTypesUnlimited, CSD_CARGO, GetCargoSuffix(), IndustrySpec::grf_prop, GRFFilePropsBase::grffile, IsValidCargoType(), lengthof, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by BuildIndustryWindow::DrawWidget(), and BuildIndustryWindow::UpdateWidgetSize().
| void GetCargoSuffix | ( | CargoSuffixInOut | use_input, |
| CargoSuffixType | cst, | ||
| const Industry * | ind, | ||
| IndustryType | ind_type, | ||
| const IndustrySpec * | indspec, | ||
| CargoType | cargo, | ||
| uint8_t | slot, | ||
| CargoSuffix & | suffix | ||
| ) |
Gets the strings to display after the cargo of industries (using callback 37)
| use_input | get suffixes for output cargo or input cargo? |
| cst | the cargo suffix type (for which window is it requested). |
| ind | the industry (nullptr if in fund window) |
| ind_type | the industry type |
| indspec | the industry spec |
| cargo | cargotype. for INVALID_CARGO no suffix will be determined |
| slot | accepts/produced slot number, used for old-style 3-in/2-out industries. |
| suffix | is filled with the suffix |
Definition at line 219 of file industry_gui.cpp.
References IndustrySpec::behaviour, GRFFile::cargo_map, CargoTypesUnlimited, CSD_CARGO, CargoSuffix::display, GetCargoSuffix(), IndustrySpec::grf_prop, GRFFilePropsBase::grffile, INDUSTRY_ORIGINAL_NUM_INPUTS, INDUSTRY_ORIGINAL_NUM_OUTPUTS, IsValidCargoType(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and CargoSuffix::text.
|
static |
Gets the string to display after the cargo name (using callback 37)
| cargo | the cargo for which the suffix is requested, meaning depends on presence of flag 18 in prop 1A |
| cst | the cargo suffix type (for which window is it requested). |
| ind | the industry (nullptr if in fund window) |
| ind_type | the industry type |
| indspec | the industry spec |
| suffix | is filled with the string to display |
Definition at line 97 of file industry_gui.cpp.
References CALLBACK_FAILED, IndustrySpec::callback_mask, CargoSuffix, CBID_INDUSTRY_CARGO_SUFFIX, CSD_CARGO, CSD_CARGO_AMOUNT, CSD_CARGO_AMOUNT_TEXT, CSD_CARGO_TEXT, CST_FUND, CargoSuffix::display, ErrorUnknownCallbackResult(), GB(), GetGRFStringWithTextStack(), GetIndustryCallback(), IndustrySpec::grf_prop, GRFFilePropsBase::grffile, GRFFilePropsBase::grfid, GRFSTR_MISC_GRF_TEXT, INVALID_TILE, Industry::location, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), CargoSuffix::text, and OrthogonalTileArea::tile.
Referenced by IndustryViewWindow::DrawInfo(), GetAllCargoSuffixes(), GetCargoSuffix(), and IndustryDirectoryWindow::GetIndustryString().
|
static |
Sort industry types by their name.
Definition at line 238 of file industry_gui.cpp.
References GetIndustrySpec(), GetString(), and StrNaturalCompare().
Referenced by SortIndustryTypes().
|
inlinestatic |
Definition at line 783 of file industry_gui.cpp.
| void ShowBuildIndustryWindow | ( | ) |
Definition at line 774 of file industry_gui.cpp.
| void ShowIndustryCargoesWindow | ( | ) |
Open the industry and cargoes window with an industry.
Definition at line 3203 of file industry_gui.cpp.
References NUM_INDUSTRYTYPES, and ShowIndustryCargoesWindow().
Referenced by MenuClickIndustry(), BuildIndustryWindow::OnClick(), IndustryViewWindow::OnClick(), and ShowIndustryCargoesWindow().
|
static |
Open the industry and cargoes window.
| id | Industry type to display, NUM_INDUSTRYTYPES selects a default industry type. |
Definition at line 3181 of file industry_gui.cpp.
References _sorted_industry_types, BringWindowToFrontById(), IndustrySpec::enabled, GetIndustrySpec(), Window::InvalidateData(), NUM_INDUSTRYTYPES, and WC_INDUSTRY_CARGOES.
| void ShowIndustryDirectory | ( | ) |
Definition at line 1928 of file industry_gui.cpp.
| void ShowIndustryViewWindow | ( | IndustryID | industry | ) |
Definition at line 1239 of file industry_gui.cpp.
| void SortIndustryTypes | ( | ) |
Initialize the list of sorted industry types.
Definition at line 249 of file industry_gui.cpp.
References _sorted_industry_types, IndustryTypeNameSorter(), and NUM_INDUSTRYTYPES.
Referenced by AfterLoadGRFs(), and ReadLanguagePack().
|
static |
Definition at line 1194 of file industry_gui.cpp.
| std::bitset<NUM_INDUSTRYTYPES> _displayed_industries |
Communication from the industry chain window to the smallmap window about what industries to display.
Definition at line 62 of file industry_gui.cpp.
Referenced by IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), and SmallMapWindow::OnInvalidateData().
| bool _ignore_industry_restrictions |
Definition at line 61 of file industry_gui.cpp.
|
static |
Definition at line 1325 of file industry_gui.cpp.
|
staticconstexpr |
Definition at line 260 of file industry_gui.cpp.
|
staticconstexpr |
Widgets of the industry cargoes window.
Definition at line 1934 of file industry_gui.cpp.
|
staticconstexpr |
Widget definition of the industry directory gui.
Definition at line 1245 of file industry_gui.cpp.
|
staticconstexpr |
Widget definition of the view industry gui.
Definition at line 1207 of file industry_gui.cpp.
| std::array<IndustryType, NUM_INDUSTRYTYPES> _sorted_industry_types |
Industry types sorted by name.
Definition at line 235 of file industry_gui.cpp.
Referenced by BuildIndustriesLegend(), IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), IndustryDirectoryWindow::IndustryTypeSorter(), IndustryCargoesWindow::OnClick(), ShowIndustryCargoesWindow(), and SortIndustryTypes().
|
static |
Maximum number of cargoes carried in a CFT_CARGO field in CargoesField.
Definition at line 1976 of file industry_gui.cpp.
Referenced by CargoesField::CargoClickedAt(), CargoesField::CargoLabelClickedAt(), CargoesRow::ConnectIndustryAccepted(), CargoesRow::ConnectIndustryProduced(), CargoesField::Draw(), and CargoesRow::MakeCargoLabel().