#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "gui.h"
#include "window_gui.h"
#include "textbuf_gui.h"
#include "station.h"
#include "player_func.h"
#include "economy_func.h"
#include "town.h"
#include "command_func.h"
#include "variables.h"
#include "vehicle_gui.h"
#include "cargotype.h"
#include "station_gui.h"
#include "strings_func.h"
#include "core/alloc_func.hpp"
#include "window_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "widgets/dropdown_func.h"
#include "table/strings.h"
#include "table/sprites.h"
Go to the source code of this file.
Data Structures | |
struct | plstations_d |
Information about station list. More... | |
struct | CargoData |
Typedefs | |
typedef int CDECL | StationSortListingTypeFunction (const void *, const void *) |
typedef std::list< CargoData > | CargoDataList |
Enumerations | |
enum | StationListFlags { SL_ORDER = 1 << 0, SL_RESORT = 1 << 1, SL_REBUILD = 1 << 2 } |
Flags for station list. More... | |
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. | |
static int CDECL | StationNameSorter (const void *a, const void *b) |
static int CDECL | StationTypeSorter (const void *a, const void *b) |
static int CDECL | StationWaitingSorter (const void *a, const void *b) |
static int CDECL | StationRatingMaxSorter (const void *a, const void *b) |
qsort-compatible version of sorting two stations by maximum rating | |
DECLARE_ENUM_AS_BIT_SET (StationListFlags) | |
assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(plstations_d)) | |
void | RebuildStationLists () |
Set the 'SL_REBUILD' flag for all station lists. | |
void | ResortStationLists () |
Set the 'SL_RESORT' flag for all station lists. | |
static void | BuildStationsList (plstations_d *sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_empty) |
Rebuild station list if the SL_REBUILD flag is set. | |
static void | SortStationsList (plstations_d *sl) |
Sort station list if the SL_RESORT flag is set. | |
static void | PlayerStationsWndProc (Window *w, WindowEvent *e) |
Fuction called when any WindowEvent occurs for PlayerStations window. | |
void | ShowPlayerStations (PlayerID player) |
Opens window with list of player's stations. | |
static void | DrawCargoIcons (CargoID i, uint waiting, int x, int y, uint width) |
Draws icons of wainting cargo in the StationView window. | |
static void | DrawStationViewWindow (Window *w) |
Redraws whole StationView window. | |
static void | StationViewWndProc (Window *w, WindowEvent *e) |
Fuction called when any WindowEvent occurs for any StationView window. | |
void | ShowStationViewWindow (StationID station) |
Opens StationViewWindow for given station. | |
Variables | |
static StationSortListingTypeFunction | StationNameSorter |
static StationSortListingTypeFunction | StationTypeSorter |
static StationSortListingTypeFunction | StationWaitingSorter |
static StationSortListingTypeFunction | StationRatingMaxSorter |
bool | _station_show_coverage |
const StringID | _station_sort_listing [] |
static char | _bufcache [64] |
static const Station * | _last_station |
static int | _internal_sort_order |
static const uint32 | _cargo_filter_max = ~0 |
static uint32 | _cargo_filter = _cargo_filter_max |
static const Widget | _player_stations_widgets [] |
static const WindowDesc | _player_stations_desc |
static const Widget | _station_view_widgets [] |
static const WindowDesc | _station_view_desc |
Definition in file station_gui.cpp.
enum StationListFlags |
Flags for station list.
SL_ORDER | Order - ascending (=0), descending (=1). |
SL_RESORT | Resort the list. |
SL_REBUILD | Rebuild the list. |
Definition at line 168 of file station_gui.cpp.
static void BuildStationsList | ( | plstations_d * | sl, | |
PlayerID | owner, | |||
byte | facilities, | |||
uint32 | cargo_filter, | |||
bool | include_empty | |||
) | [static] |
Rebuild station list if the SL_REBUILD flag is set.
sl | pointer to plstations_d (station list and flags) | |
owner | player whose stations are to be in list | |
facilities | types of stations of interest | |
cargo_filter | bitmap of cargo types to include | |
include_empty | whether we should include stations without waiting cargo |
Definition at line 227 of file station_gui.cpp.
References plstations_d::flags, HasBit(), HasStationInUse(), plstations_d::list_length, OWNER_NONE, SL_REBUILD, SL_RESORT, and plstations_d::sort_list.
static void DrawCargoIcons | ( | CargoID | i, | |
uint | waiting, | |||
int | x, | |||
int | y, | |||
uint | width | |||
) | [static] |
Draws icons of wainting cargo in the StationView window.
i | type of cargo | |
waiting | number of wainting units | |
x | x on-screen coordinate where to start with drawing icons | |
y | y coordinate |
Definition at line 693 of file station_gui.cpp.
References min().
Referenced by DrawStationViewWindow().
static void DrawStationViewWindow | ( | Window * | w | ) | [static] |
Redraws whole StationView window.
w | pointer to window |
< coordinates used for printing waiting/accepted/rating of cargo
< = w->vscroll.pos
Definition at line 735 of file station_gui.cpp.
References CargoPacket::count, DrawCargoIcons(), HasBit(), CargoPacket::source, SVW_ACCEPTLIST, SVW_ACCEPTS, SVW_PLANES, SVW_RATINGLIST, SVW_RENAME, SVW_ROADVEHS, SVW_SHIPS, SVW_TRAINS, and SVW_WAITING.
Referenced by StationViewWndProc().
static void PlayerStationsWndProc | ( | Window * | w, | |
WindowEvent * | e | |||
) | [static] |
Fuction called when any WindowEvent occurs for PlayerStations window.
w | pointer to the PlayerStations window | |
e | pointer to window event |
< offset from left of widget
Definition at line 302 of file station_gui.cpp.
void ShowPlayerStations | ( | PlayerID | player | ) |
Opens window with list of player's stations.
player | player whose stations' list show |
Definition at line 613 of file station_gui.cpp.
References AllocateWindowDescFront(), HasBit(), ReallocT(), RESIZE_NONE, ResizeWindow(), SLW_CARGOALL, SLW_CARGOSTART, SLW_NOCARGOWAITING, SLW_PAN_RIGHT, WWT_LAST, and WWT_PANEL.
void ShowStationViewWindow | ( | StationID | station | ) |
Opens StationViewWindow for given station.
station | station which window should be opened |
Definition at line 986 of file station_gui.cpp.
References AllocateWindowDescFront(), and OWNER_NONE.
static void SortStationsList | ( | plstations_d * | sl | ) | [static] |
Sort station list if the SL_RESORT flag is set.
sl | pointer to plstations_d (station list and flags) |
Definition at line 277 of file station_gui.cpp.
References DAY_TICKS, plstations_d::flags, plstations_d::list_length, plstations_d::resort_timer, SL_ORDER, SL_RESORT, plstations_d::sort_list, plstations_d::sort_type, and StationRatingMaxSorter().
static int CDECL StationRatingMaxSorter | ( | const void * | a, | |
const void * | b | |||
) | [static] |
qsort-compatible version of sorting two stations by maximum rating
a | First object to be sorted, must be of type (const Station *) | |
b | Second object to be sorted, must be of type (const Station *) |
>0 | a should come before b in the list | |
<0 | b should come before a in the list |
Definition at line 152 of file station_gui.cpp.
References HasBit(), and max().
Referenced by SortStationsList().
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 54 of file station_gui.cpp.
References minu().
static void StationViewWndProc | ( | Window * | w, | |
WindowEvent * | e | |||
) | [static] |
Fuction called when any WindowEvent occurs for any StationView window.
w | pointer to the StationView window | |
e | pointer to window event |
Definition at line 880 of file station_gui.cpp.
References _cmd_text, CMD_MSG, CMD_RENAME_STATION, CS_ALPHANUMERAL, DoCommandP(), DrawStationViewWindow(), OWNER_NONE, ResizeButtons(), ResizeWindowForWidget(), SetWindowDirty(), ShowQueryString(), SVW_ACCEPTLIST, SVW_LOCATION, SVW_PLANES, SVW_RATINGS, SVW_RENAME, SVW_ROADVEHS, SVW_SHIPS, and SVW_TRAINS.
const WindowDesc _player_stations_desc [static] |
Initial value:
{ 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, _player_stations_widgets, PlayerStationsWndProc }
Definition at line 600 of file station_gui.cpp.
const Widget _player_stations_widgets[] [static] |
Initial value:
{ { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, { WWT_PANEL, RESIZE_RB, 14, 0, 345, 37, 161, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, { WWT_SCROLLBAR, RESIZE_LRB, 14, 346, 357, 37, 149, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_RESIZEBOX, RESIZE_LRTB, 14, 346, 357, 150, 161, 0x0, STR_RESIZE_BUTTON}, { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 13, 14, 24, STR_TRAIN, STR_USE_CTRL_TO_SELECT_MORE}, { WWT_TEXTBTN, RESIZE_NONE, 14, 14, 27, 14, 24, STR_LORRY, STR_USE_CTRL_TO_SELECT_MORE}, { WWT_TEXTBTN, RESIZE_NONE, 14, 28, 41, 14, 24, STR_BUS, STR_USE_CTRL_TO_SELECT_MORE}, { WWT_TEXTBTN, RESIZE_NONE, 14, 42, 55, 14, 24, STR_PLANE, STR_USE_CTRL_TO_SELECT_MORE}, { WWT_TEXTBTN, RESIZE_NONE, 14, 56, 69, 14, 24, STR_SHIP, STR_USE_CTRL_TO_SELECT_MORE}, { WWT_PANEL, RESIZE_NONE, 14, 70, 83, 14, 24, 0x0, STR_SELECT_ALL_FACILITIES}, { WWT_PANEL, RESIZE_NONE, 14, 83, 88, 14, 24, 0x0, STR_NULL}, { WWT_PANEL, RESIZE_NONE, 14, 89, 102, 14, 24, 0x0, STR_NO_WAITING_CARGO}, { WWT_PANEL, RESIZE_NONE, 14, 103, 116, 14, 24, 0x0, STR_SELECT_ALL_TYPES}, { WWT_PANEL, RESIZE_RIGHT, 14, 117, 357, 14, 24, 0x0, STR_NULL}, { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 80, 25, 36, STR_SORT_BY, STR_SORT_ORDER_TIP}, { WWT_DROPDOWN, RESIZE_NONE, 14, 81, 243, 25, 36, 0x0, STR_SORT_CRITERIA_TIP}, { WWT_PANEL, RESIZE_RIGHT, 14, 244, 357, 25, 36, 0x0, STR_NULL}, { WIDGETS_END}, }
Definition at line 574 of file station_gui.cpp.
const StringID _station_sort_listing[] |
Initial value:
{ STR_SORT_BY_DROPDOWN_NAME, STR_SORT_BY_FACILITY, STR_SORT_BY_WAITING, STR_SORT_BY_RATING_MAX, INVALID_STRING_ID }
Definition at line 87 of file station_gui.cpp.
const WindowDesc _station_view_desc [static] |
Initial value:
{ 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, StationViewWndProc }
Definition at line 973 of file station_gui.cpp.
const Widget _station_view_widgets[] [static] |
Initial value:
{ { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_STICKYBOX, RESIZE_LR, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, { WWT_PANEL, RESIZE_RB, 14, 0, 236, 14, 65, 0x0, STR_NULL}, { WWT_SCROLLBAR, RESIZE_LRB, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, { WWT_PANEL, RESIZE_RTB, 14, 0, 248, 66, 97, 0x0, STR_NULL}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 59, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, { WWT_PUSHTXTBTN, RESIZE_TB, 14, 60, 120, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, { WWT_PUSHTXTBTN, RESIZE_RTB, 14, 121, 180, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 181, 194, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 195, 208, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 209, 222, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 223, 236, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, { WWT_RESIZEBOX, RESIZE_LRTB, 14, 237, 248, 98, 109, 0x0, STR_RESIZE_BUTTON}, { WIDGETS_END}, }
Definition at line 667 of file station_gui.cpp.