#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "gui.h"
#include "window_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 "window_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "widgets/dropdown_func.h"
#include "newgrf_cargo.h"
#include "station_map.h"
#include "tilehighlight_func.h"
#include "core/smallmap_type.hpp"
#include "company_base.h"
#include "sortlist_type.h"
#include "settings_type.h"
#include "table/strings.h"
#include "table/sprites.h"
Go to the source code of this file.
Data Structures | |
| class | CompanyStationsWindow |
| The list of stations per company. More... | |
| struct | CargoData |
| struct | StationViewWindow |
| The StationView window. More... | |
| struct | FindNearbyStationContext |
| Context for FindStationsNearby. More... | |
| struct | SelectStationWindow |
Typedefs | |
| typedef GUIList< const Station * > | GUIStationList |
| typedef std::list< CargoData > | CargoDataList |
Enumerations | |
| enum | JoinStationWidgets { JSW_WIDGET_CLOSEBOX = 0, JSW_WIDGET_CAPTION, JSW_PANEL, JSW_SCROLLBAR, JSW_EMPTY, JSW_RESIZEBOX } |
Functions | |
| static void | StationsWndShowStationRating (int x, int y, CargoID type, uint amount, byte 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. | |
| SpriteID | GetCargoSprite (CargoID i) |
| static void | DrawCargoIcons (CargoID i, uint waiting, int x, int y, uint width) |
| Draws icons of waiting cargo in the StationView window. | |
| void | ShowStationViewWindow (StationID station) |
| Opens StationViewWindow for given station. | |
| 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. | |
| static const Station * | FindStationsNearby (TileIndex tile, int w, int h, bool distant_join) |
| Circulate around the to-be-built station to find stations we could join. | |
| static bool | StationJoinerNeeded (CommandContainer cmd, int w, int h) |
| Check whether we need to show the station selection window. | |
| void | ShowSelectStationIfNeeded (CommandContainer cmd, int w, int h) |
| Show the station selection window when needed. | |
Variables | |
| static const Widget | _company_stations_widgets [] |
| static const WindowDesc | _company_stations_desc (WDP_AUTO, WDP_AUTO, 358, 162, 358, 162, WC_STATION_LIST, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET|WDF_STICKY_BUTTON|WDF_RESIZABLE, _company_stations_widgets) |
| static const Widget | _station_view_widgets [] |
| static const WindowDesc | _station_view_desc (WDP_AUTO, WDP_AUTO, 249, 110, 249, 110, WC_STATION_VIEW, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET|WDF_UNCLICK_BUTTONS|WDF_STICKY_BUTTON|WDF_RESIZABLE, _station_view_widgets) |
| static SmallVector< StationID, 8 > | _stations_nearby_list |
|
static SmallMap< TileIndex, StationID, 8 > | _deleted_stations_nearby |
| static const Widget | _select_station_widgets [] |
| static const WindowDesc | _select_station_desc (WDP_AUTO, WDP_AUTO, 200, 92, 200, 182, WC_SELECT_STATION, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET|WDF_RESIZABLE|WDF_CONSTRUCTION, _select_station_widgets) |
Definition in file station_gui.cpp.
| static bool AddNearbyStation | ( | TileIndex | tile, | |
| void * | user_data | |||
| ) | [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 FindNearbyStationContext context |
Definition at line 1019 of file station_gui.cpp.
References SmallVector< T, S >::Append(), StationRect::BeforeAddRect(), SmallVector< T, S >::Contains(), SmallVector< SmallPair< T, U >, S >::End(), SmallMap< T, U, S >::Find(), GetStationIndex(), FindNearbyStationContext::h, SmallVector< T, S >::Include(), IsTileType(), MP_STATION, Station::owner, Station::rect, SmallPair< T, U >::second, FindNearbyStationContext::tile, and FindNearbyStationContext::w.
Referenced by FindStationsNearby().
| static void DrawCargoIcons | ( | CargoID | i, | |
| uint | waiting, | |||
| int | x, | |||
| int | y, | |||
| uint | width | |||
| ) | [static] |
Draws icons of waiting cargo in the StationView window.
| i | type of cargo | |
| waiting | number of waiting units | |
| x | x on-screen coordinate where to start with drawing icons | |
| y | y coordinate |
Definition at line 677 of file station_gui.cpp.
References DrawSprite(), and min().
Referenced by StationViewWindow::OnPaint().
| static const Station* FindStationsNearby | ( | TileIndex | tile, | |
| int | w, | |||
| int | h, | |||
| bool | distant_join | |||
| ) | [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.
| tile | Base tile of the to-be-built station | |
| w | Width of the to-be-built station | |
| h | Height of the to-be-built station | |
| distant_join | Search for adjacent stations (false) or stations fully within station spread |
Definition at line 1054 of file station_gui.cpp.
References _settings_game, AddNearbyStation(), BEGIN_TILE_LOOP, CircularTileSearch(), SmallVector< SmallPair< T, U >, S >::Clear(), SmallVector< T, S >::Clear(), DIR_N, DistanceMax(), END_TILE_LOOP, Station::facilities, FindNearbyStationContext::h, PoolItem< T, Tid, Tpool >::index, SmallMap< T, U, S >::Insert(), IsInsideBS(), IsTileType(), MapSize(), max(), min(), MP_STATION, Station::owner, GameSettings::station, StationSettings::station_spread, FindNearbyStationContext::tile, TILE_ADD, TILE_ADDXY, TileOffsByDir(), TileX(), TileY(), FindNearbyStationContext::w, and Station::xy.
Referenced by StationJoinerNeeded().
| void ShowCompanyStations | ( | CompanyID | company | ) |
Opens window with list of company's stations.
| company | whose stations' list show |
Definition at line 627 of file station_gui.cpp.
| void ShowSelectStationIfNeeded | ( | CommandContainer | cmd, | |
| int | w, | |||
| int | h | |||
| ) |
Show the station selection window when needed.
If not, build the station.
| cmd | Command to build the station. | |
| w | Width of the to-be-built station | |
| h | Height of the to-be-built station |
Definition at line 1252 of file station_gui.cpp.
References _settings_client, BringWindowToFrontById(), DoCommandP(), ClientSettings::gui, GUISettings::persistent_buildingtools, and StationJoinerNeeded().
| void ShowStationViewWindow | ( | StationID | station | ) |
Opens StationViewWindow for given station.
| station | station which window should be opened |
Definition at line 998 of file station_gui.cpp.
| static bool StationJoinerNeeded | ( | CommandContainer | cmd, | |
| int | w, | |||
| int | h | |||
| ) | [static] |
Check whether we need to show the station selection window.
| cmd | Command to build the station. | |
| w | Width of the to-be-built station | |
| h | Height of the to-be-built station |
Definition at line 1217 of file station_gui.cpp.
References _ctrl_pressed, _settings_game, StationSettings::adjacent_stations, CommandContainer::cmd, CmdFailed(), CommandFlagsToDCFlags(), StationSettings::distant_join_stations, DoCommand(), FindStationsNearby(), FindWindowById(), GetCommandFlags(), SmallVector< T, S >::Length(), GameSettings::station, CommandContainer::tile, and UpdateTileSelection().
Referenced by ShowSelectStationIfNeeded().
| static void StationsWndShowStationRating | ( | int | x, | |
| int | y, | |||
| CargoID | type, | |||
| uint | amount, | |||
| byte | rating | |||
| ) | [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'
| x | 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 |
Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
< number of units to show station as 'full'
< rating needed so it is shown as 'full'
Definition at line 46 of file station_gui.cpp.
References DrawString(), GfxFillRect(), and minu().
Referenced by CompanyStationsWindow::OnPaint().
const Widget _company_stations_widgets[] [static] |
Initial value:
{
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 345, 37, 161, 0x0, STR_3057_STATION_NAMES_CLICK_ON},
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 346, 357, 37, 149, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 346, 357, 150, 161, 0x0, STR_RESIZE_BUTTON},
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 13, 14, 24, STR_TRAIN, STR_USE_CTRL_TO_SELECT_MORE},
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 14, 27, 14, 24, STR_LORRY, STR_USE_CTRL_TO_SELECT_MORE},
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 28, 41, 14, 24, STR_BUS, STR_USE_CTRL_TO_SELECT_MORE},
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 42, 55, 14, 24, STR_PLANE, STR_USE_CTRL_TO_SELECT_MORE},
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 56, 69, 14, 24, STR_SHIP, STR_USE_CTRL_TO_SELECT_MORE},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 70, 83, 14, 24, 0x0, STR_SELECT_ALL_FACILITIES},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 83, 88, 14, 24, 0x0, STR_NULL},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 89, 102, 14, 24, 0x0, STR_NO_WAITING_CARGO},
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 103, 116, 14, 24, 0x0, STR_SELECT_ALL_TYPES},
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 117, 357, 14, 24, 0x0, STR_NULL},
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 80, 25, 36, STR_SORT_BY, STR_SORT_ORDER_TIP},
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 81, 243, 25, 36, 0x0, STR_SORT_CRITERIA_TIP},
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 244, 357, 25, 36, 0x0, STR_NULL},
{ WIDGETS_END},
}
Definition at line 589 of file station_gui.cpp.
const Widget _select_station_widgets[] [static] |
Initial value:
{
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_DARK_GREEN, 11, 199, 0, 13, STR_SELECT_STATION_TO_JOIN, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, RESIZE_RB, COLOUR_DARK_GREEN, 0, 187, 14, 79, 0x0, STR_NULL},
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_DARK_GREEN, 188, 199, 14, 79, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PANEL, RESIZE_RTB, COLOUR_DARK_GREEN, 0, 187, 80, 91, 0x0, STR_NULL},
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_DARK_GREEN, 188, 199, 80, 91, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
}
Definition at line 1107 of file station_gui.cpp.
const Widget _station_view_widgets[] [static] |
Initial value:
{
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 236, 14, 65, 0x0, STR_NULL},
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PANEL, RESIZE_RTB, COLOUR_GREY, 0, 248, 66, 97, 0x0, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 59, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION},
{ WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 60, 120, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS},
{ WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 121, 180, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION},
{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 181, 194, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP },
{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 195, 208, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP },
{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 209, 222, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP },
{ WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 223, 236, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP },
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 237, 248, 98, 109, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
}
Definition at line 634 of file station_gui.cpp.
1.5.6