OpenTTD Source 20241224-master-gee860a5c8e
|
The GUI for stations. More...
#include "stdafx.h"
#include "debug.h"
#include "gui.h"
#include "textbuf_gui.h"
#include "company_func.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "cargotype.h"
#include "station_gui.h"
#include "strings_func.h"
#include "string_func.h"
#include "window_func.h"
#include "viewport_func.h"
#include "dropdown_type.h"
#include "dropdown_common_type.h"
#include "dropdown_func.h"
#include "station_base.h"
#include "waypoint_base.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "sortlist_type.h"
#include "core/geometry_func.hpp"
#include "vehiclelist.h"
#include "town.h"
#include "linkgraph/linkgraph.h"
#include "zoom_func.h"
#include "station_cmd.h"
#include "widgets/station_widget.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | StationTypeFilter |
struct | GenericWaypointTypeFilter< ROAD, TILE_TYPE > |
class | CompanyStationsWindow |
The list of stations per company. More... | |
struct | CompanyStationsWindow::FilterState |
class | CargoSorter |
class | CargoDataEntry |
A cargo data entry representing one possible row in the station view window's top part. More... | |
struct | StationViewWindow |
The StationView window. More... | |
struct | StationViewWindow::RowDisplay |
A row being displayed in the cargo view (as opposed to being "hidden" behind a plus sign). More... | |
struct | TileAndStation |
Struct containing TileIndex and StationID. More... | |
struct | SelectStationWindow< T > |
Window for selecting stations/waypoints to (distant) join to. More... | |
Typedefs | |
using | RailWaypointTypeFilter = GenericWaypointTypeFilter< false, MP_RAILWAY > |
using | RoadWaypointTypeFilter = GenericWaypointTypeFilter< true, MP_ROAD > |
typedef GUIList< const Station *, const CargoTypes & > | GUIStationList |
typedef std::set< CargoDataEntry *, CargoSorter > | CargoDataSet |
Enumerations | |
enum | SortOrder { SO_DESCENDING , SO_ASCENDING } |
enum class | CargoSortType : uint8_t { AsGrouping , Count , StationString , StationID , CargoID } |
Functions | |
int | DrawStationCoverageAreaText (int left, int right, int top, StationCoverageType sct, int rad, bool supplies) |
Calculates and draws the accepted or supplied cargo around the selected tile(s) | |
template<typename T > | |
void | FindStationsAroundSelection () |
Find stations adjacent to the current tile highlight area, so that existing coverage area can be drawn. | |
void | CheckRedrawStationCoverage (const Window *w) |
Check whether we need to redraw the station coverage text. | |
template<typename T > | |
void | CheckRedrawWaypointCoverage () |
void | CheckRedrawRailWaypointCoverage (const Window *) |
void | CheckRedrawRoadWaypointCoverage (const Window *) |
static void | StationsWndShowStationRating (int left, int right, int y, CargoID type, uint amount, uint8_t rating) |
Draw small boxes of cargo amount and ratings data at the given coordinates. | |
void | ShowCompanyStations (CompanyID company) |
Opens window with list of company's stations. | |
static void | DrawCargoIcons (CargoID i, uint waiting, int left, int right, int y) |
Draws icons of waiting cargo in the StationView window. | |
void | ShowStationViewWindow (StationID station) |
Opens StationViewWindow for given station. | |
template<class T > | |
static bool | AddNearbyStation (TileIndex tile, void *user_data) |
Add station on this tile to _stations_nearby_list if it's fully within the station spread. | |
template<class T > | |
static const BaseStation * | FindStationsNearby (TileArea ta, bool distant_join) |
Circulate around the to-be-built station to find stations we could join. | |
template<class T > | |
static bool | StationJoinerNeeded (TileArea ta, const StationPickerCmdProc &proc) |
Check whether we need to show the station selection window. | |
template<class T > | |
void | ShowSelectBaseStationIfNeeded (TileArea ta, StationPickerCmdProc &&proc) |
Show the station selection window when needed. | |
void | ShowSelectStationIfNeeded (TileArea ta, StationPickerCmdProc proc) |
Show the station selection window when needed. | |
void | ShowSelectRailWaypointIfNeeded (TileArea ta, StationPickerCmdProc proc) |
Show the rail waypoint selection window when needed. | |
void | ShowSelectRoadWaypointIfNeeded (TileArea ta, StationPickerCmdProc proc) |
Show the road waypoint selection window when needed. | |
Variables | |
static constexpr NWidgetPart | _nested_company_stations_widgets [] |
static WindowDesc | _company_stations_desc (WDP_AUTO, "list_stations", 358, 162, WC_STATION_LIST, WC_NONE, 0, _nested_company_stations_widgets) |
static constexpr NWidgetPart | _nested_station_view_widgets [] |
static WindowDesc | _station_view_desc (WDP_AUTO, "view_station", 249, 117, WC_STATION_VIEW, WC_NONE, 0, _nested_station_view_widgets) |
static std::vector< TileAndStation > | _deleted_stations_nearby |
static std::vector< StationID > | _stations_nearby_list |
static constexpr NWidgetPart | _nested_select_station_widgets [] |
static WindowDesc | _select_station_desc (WDP_AUTO, "build_station_join", 200, 180, WC_SELECT_STATION, WC_NONE, WDF_CONSTRUCTION, _nested_select_station_widgets) |
The GUI for stations.
Definition in file station_gui.cpp.
typedef std::set<CargoDataEntry *, CargoSorter> CargoDataSet |
Definition at line 913 of file station_gui.cpp.
typedef GUIList<const Station*, const CargoTypes &> GUIStationList |
Definition at line 257 of file station_gui.cpp.
using RailWaypointTypeFilter = GenericWaypointTypeFilter<false, MP_RAILWAY> |
Definition at line 64 of file station_gui.cpp.
using RoadWaypointTypeFilter = GenericWaypointTypeFilter<true, MP_ROAD> |
Definition at line 65 of file station_gui.cpp.
|
strong |
Enumerator | |
---|---|
AsGrouping | by the same principle the entries are being grouped |
Count | by amount of cargo |
StationString | by station name |
StationID | by station id |
CargoID | by cargo id |
Definition at line 889 of file station_gui.cpp.
enum SortOrder |
Definition at line 882 of file station_gui.cpp.
|
static |
Add station on this tile to _stations_nearby_list if it's fully within the station spread.
tile | Tile just being checked |
user_data | Pointer to TileArea context |
T | the station filter type |
Definition at line 2198 of file station_gui.cpp.
References _local_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::Get(), GetStationIndex(), OrthogonalTileArea::h, IsTileType(), MP_STATION, BaseStation::owner, BaseStation::rect, CommandCost::Succeeded(), OrthogonalTileArea::tile, and OrthogonalTileArea::w.
void CheckRedrawRailWaypointCoverage | ( | const Window * | w | ) |
Definition at line 198 of file station_gui.cpp.
void CheckRedrawRoadWaypointCoverage | ( | const Window * | w | ) |
Definition at line 203 of file station_gui.cpp.
void CheckRedrawStationCoverage | ( | const Window * | w | ) |
Check whether we need to redraw the station coverage text.
If it is needed actually make the window for redrawing.
w | the window to check. |
Definition at line 160 of file station_gui.cpp.
References _ctrl_pressed, _settings_client, TileHighlightData::dirty, TileHighlightData::drawstyle, ClientSettings::gui, HT_RECT, Window::SetDirty(), and GUISettings::station_show_coverage.
Referenced by BuildAirportWindow::OnRealtimeTick(), BuildDocksStationWindow::OnRealtimeTick(), BuildRailStationWindow::OnRealtimeTick(), and BuildRoadStationWindow::OnRealtimeTick().
void CheckRedrawWaypointCoverage | ( | ) |
Definition at line 180 of file station_gui.cpp.
|
static |
Draws icons of waiting cargo in the StationView window.
i | type of cargo |
waiting | number of waiting units |
left | left most coordinate to draw on |
right | right most coordinate to draw on |
y | y coordinate |
Definition at line 867 of file station_gui.cpp.
References _current_text_dir, DrawSprite(), CargoSpec::Get(), CargoSpec::GetCargoIcon(), ScaleSpriteTrad(), and TD_RTL.
Referenced by StationViewWindow::DrawEntries().
int DrawStationCoverageAreaText | ( | int | left, |
int | right, | ||
int | top, | ||
StationCoverageType | sct, | ||
int | rad, | ||
bool | supplies | ||
) |
Calculates and draws the accepted or supplied cargo around the selected tile(s)
left | x position where the string is to be drawn |
right | the right most position to draw on |
top | y position where the string is to be drawn |
sct | which type of cargo is to be displayed (passengers/non-passengers) |
rad | radius around selected tile(s) to be searched |
supplies | if supplied cargoes should be drawn, else accepted cargoes |
Definition at line 77 of file station_gui.cpp.
References CC_PASSENGERS, DrawStringMultiLine(), TileHighlightData::drawstyle, GetAcceptanceAroundTiles(), GetProductionAroundTiles(), HT_RECT, IsCargoInClass(), NUM_CARGO, TileHighlightData::pos, SCT_ALL, SCT_NON_PASSENGERS_ONLY, SCT_PASSENGERS_ONLY, SetBit(), SetDParam(), Map::Size(), TileHighlightData::size, TILE_SIZE, and TileVirtXY().
Referenced by BuildAirportWindow::OnPaint(), BuildDocksStationWindow::OnPaint(), BuildRailStationWindow::OnPaint(), and BuildRoadStationWindow::OnPaint().
void FindStationsAroundSelection | ( | ) |
Find stations adjacent to the current tile highlight area, so that existing coverage area can be drawn.
Definition at line 109 of file station_gui.cpp.
References _ctrl_pressed, _local_company, GetTileOwner(), OrthogonalTileArea::h, IsTileType(), Map::MaxX(), Map::MaxY(), MP_STATION, TileHighlightData::pos, TileHighlightData::size, OrthogonalTileArea::tile, TILE_SIZE, TileVirtXY(), TileX(), TileXY(), TileY(), and OrthogonalTileArea::w.
|
static |
Circulate around the to-be-built station to find stations we could join.
Make sure that only stations are returned where joining wouldn't exceed station spread and are our own station.
ta | Base tile area of the to-be-built station |
distant_join | Search for adjacent stations (false) or stations fully within station spread |
T | the station filter type, for stations to look for |
Definition at line 2240 of file station_gui.cpp.
References _local_company, _settings_game, CircularTileSearch(), DIR_N, DistanceMax(), BaseStation::GetByTile(), GetStationIndex(), OrthogonalTileArea::h, IsInsideBS(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::Iterate(), MP_STATION, Map::Size(), GameSettings::station, StationSettings::station_spread, OrthogonalTileArea::tile, TileAddByDir(), TileAddXY(), TileX(), TileY(), and OrthogonalTileArea::w.
void ShowCompanyStations | ( | CompanyID | company | ) |
Opens window with list of company's stations.
company | whose stations' list show |
Definition at line 814 of file station_gui.cpp.
Referenced by MenuClickStations(), and MainToolbarWindow::OnHotkey().
void ShowSelectBaseStationIfNeeded | ( | TileArea | ta, |
StationPickerCmdProc && | proc | ||
) |
Show the station selection window when needed.
If not, build the station.
cmd | Command to build the station. |
ta | Area to build the station in |
the | class to find stations for |
Definition at line 2468 of file station_gui.cpp.
References _settings_client, ClientSettings::gui, GUISettings::persistent_buildingtools, and ResetObjectToPlace().
void ShowSelectRailWaypointIfNeeded | ( | TileArea | ta, |
StationPickerCmdProc | proc | ||
) |
Show the rail waypoint selection window when needed.
If not, build the waypoint.
ta | Area to build the waypoint in |
proc | Function called to execute the build command. |
Definition at line 2493 of file station_gui.cpp.
Referenced by BuildRailToolbarWindow::OnPlaceMouseUp().
void ShowSelectRoadWaypointIfNeeded | ( | TileArea | ta, |
StationPickerCmdProc | proc | ||
) |
Show the road waypoint selection window when needed.
If not, build the waypoint.
ta | Area to build the waypoint in |
proc | Function called to execute the build command. |
Definition at line 2503 of file station_gui.cpp.
Referenced by BuildRoadToolbarWindow::OnPlaceMouseUp().
void ShowSelectStationIfNeeded | ( | TileArea | ta, |
StationPickerCmdProc | proc | ||
) |
Show the station selection window when needed.
If not, build the station.
ta | Area to build the station in |
proc | Function called to execute the build command. |
Definition at line 2483 of file station_gui.cpp.
Referenced by BuildDocksToolbarWindow::OnPlaceObject(), PlaceAirport(), PlaceRail_Station(), and PlaceRoadStop().
void ShowStationViewWindow | ( | StationID | station | ) |
Opens StationViewWindow for given station.
station | station which window should be opened |
Definition at line 2176 of file station_gui.cpp.
|
static |
Check whether we need to show the station selection window.
cmd | Command to build the station. |
ta | Tile area of the to-be-built station |
T | the station filter type |
Definition at line 2438 of file station_gui.cpp.
References _ctrl_pressed, _settings_game, Window::Close(), StationSettings::distant_join_stations, FindWindowById(), GameSettings::station, UpdateTileSelection(), and WC_SELECT_STATION.
|
static |
Draw small boxes of cargo amount and ratings data at the given coordinates.
If amount exceeds 576 units, it is shown 'full', same goes for the rating: at above 90% orso (224) it is also 'full'
left | left most coordinate to draw the box at |
right | right most coordinate to draw the box at |
y | coordinate to draw the box at |
type | Cargo type |
amount | Cargo amount |
rating | ratings data for that particular cargo |
< number of units to show station as 'full'
< rating needed so it is shown as 'full'
Definition at line 220 of file station_gui.cpp.
References CargoSpec::abbrev, DrawString(), FS_SMALL, CargoSpec::Get(), GetCharacterHeight(), GetContrastColour(), GfxFillRect(), CargoSpec::IsValid(), PC_GREEN, PC_RED, SA_CENTER, and ScaleGUITrad().
Referenced by CompanyStationsWindow::DrawWidget().
|
static |
Definition at line 2187 of file station_gui.cpp.
|
staticconstexpr |
Definition at line 769 of file station_gui.cpp.
|
staticconstexpr |
Definition at line 2281 of file station_gui.cpp.
|
staticconstexpr |
Definition at line 821 of file station_gui.cpp.
|
static |
Definition at line 2188 of file station_gui.cpp.