2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file station_gui.cpp The GUI for stations. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2005-02-05 15:58:59 +00:00
|
|
|
#include "debug.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
|
|
|
#include "textbuf_gui.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "vehicle_gui.h"
|
2007-02-20 22:09:21 +00:00
|
|
|
#include "cargotype.h"
|
2007-12-05 17:08:10 +00:00
|
|
|
#include "station_gui.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
|
|
|
#include "gfx_func.h"
|
2008-01-14 16:10:58 +00:00
|
|
|
#include "widgets/dropdown_func.h"
|
2009-06-24 17:39:54 +00:00
|
|
|
#include "station_base.h"
|
2009-07-31 16:28:28 +00:00
|
|
|
#include "waypoint_base.h"
|
2009-01-08 16:35:45 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_base.h"
|
2008-09-13 10:04:36 +00:00
|
|
|
#include "sortlist_type.h"
|
2006-12-07 04:12:29 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
#include "table/sprites.h"
|
|
|
|
|
2010-01-05 16:59:57 +00:00
|
|
|
/**
|
|
|
|
* Draw a (multi)line of cargos seperated by commas, and prefixed with a string.
|
|
|
|
* @param cargo_mask Mask of cargos to include in the list.
|
|
|
|
* @param r Rectangle to draw the cargos in.
|
|
|
|
* @param prefix String to use as prefix for the list of cargos.
|
|
|
|
* @return Bottom position of the last line used for drawing the cargos.
|
|
|
|
*/
|
|
|
|
int DrawCargoListText(uint32 cargo_mask, const Rect &r, StringID prefix)
|
|
|
|
{
|
|
|
|
bool first = true;
|
|
|
|
char string[512];
|
|
|
|
char *b = InlineString(string, prefix);
|
|
|
|
|
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
|
|
|
if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
|
|
|
|
if (HasBit(cargo_mask, i)) {
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
} else {
|
|
|
|
/* Add a comma if this is not the first item */
|
|
|
|
*b++ = ',';
|
|
|
|
*b++ = ' ';
|
|
|
|
}
|
|
|
|
b = InlineString(b, CargoSpec::Get(i)->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If first is still true then no cargo is accepted */
|
|
|
|
if (first) b = InlineString(b, STR_JUST_NOTHING);
|
|
|
|
|
|
|
|
*b = '\0';
|
|
|
|
|
|
|
|
/* Make sure we detect any buffer overflow */
|
|
|
|
assert(b < endof(string));
|
|
|
|
|
|
|
|
SetDParamStr(0, string);
|
|
|
|
return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_JUST_RAW_STRING);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates and draws the accepted or supplied cargo around the selected tile(s)
|
|
|
|
* @param left x position where the string is to be drawn
|
|
|
|
* @param right the right most position to draw on
|
|
|
|
* @param top y position where the string is to be drawn
|
|
|
|
* @param sct which type of cargo is to be displayed (passengers/non-passengers)
|
|
|
|
* @param rad radius around selected tile(s) to be searched
|
|
|
|
* @param supplies if supplied cargos should be drawn, else accepted cargos
|
|
|
|
* @return Returns the y value below the string that was drawn
|
|
|
|
*/
|
|
|
|
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
|
|
|
|
{
|
|
|
|
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
|
|
|
|
if (tile < MapSize()) {
|
|
|
|
CargoArray cargos;
|
|
|
|
if (supplies) {
|
|
|
|
cargos = GetProductionAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad);
|
|
|
|
} else {
|
|
|
|
cargos = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert cargo counts to a set of cargo bits, and draw the result. */
|
|
|
|
uint32 cargo_mask = 0;
|
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
|
|
|
switch (sct) {
|
|
|
|
case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
|
|
|
|
case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
|
|
|
|
case SCT_ALL: break;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
if (cargos[i] >= (supplies ? 1U : 8U)) SetBit(cargo_mask, i);
|
|
|
|
}
|
|
|
|
Rect r = {left, top, right, INT32_MAX};
|
|
|
|
return DrawCargoListText(cargo_mask, r, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether we need to redraw the station coverage text.
|
|
|
|
* If it is needed actually make the window for redrawing.
|
|
|
|
* @param w the window to check.
|
|
|
|
*/
|
|
|
|
void CheckRedrawStationCoverage(const Window *w)
|
|
|
|
{
|
|
|
|
if (_thd.dirty & 1) {
|
|
|
|
_thd.dirty &= ~1;
|
|
|
|
w->SetDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-05 17:08:10 +00:00
|
|
|
/**
|
|
|
|
* Draw small boxes of cargo amount and ratings data at the given
|
2006-12-09 00:46:02 +00:00
|
|
|
* coordinates. If amount exceeds 576 units, it is shown 'full', same
|
|
|
|
* goes for the rating: at above 90% orso (224) it is also 'full'
|
2007-12-05 17:08:10 +00:00
|
|
|
*
|
2009-03-22 14:55:49 +00:00
|
|
|
* @param left left most coordinate to draw the box at
|
|
|
|
* @param right right most coordinate to draw the box at
|
|
|
|
* @param y coordinate to draw the box at
|
|
|
|
* @param type Cargo type
|
2006-12-09 00:46:02 +00:00
|
|
|
* @param amount Cargo amount
|
2007-12-05 17:08:10 +00:00
|
|
|
* @param rating ratings data for that particular cargo
|
|
|
|
*
|
|
|
|
* @note Each cargo-bar is 16 pixels wide and 6 pixels high
|
|
|
|
* @note Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
|
|
|
|
*/
|
2009-03-22 14:55:49 +00:00
|
|
|
static void StationsWndShowStationRating(int left, int right, int y, CargoID type, uint amount, byte rating)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-12-05 17:08:10 +00:00
|
|
|
static const uint units_full = 576; ///< number of units to show station as 'full'
|
|
|
|
static const uint rating_full = 224; ///< rating needed so it is shown as 'full'
|
|
|
|
|
2009-07-16 19:00:13 +00:00
|
|
|
const CargoSpec *cs = CargoSpec::Get(type);
|
2007-02-23 09:56:20 +00:00
|
|
|
if (!cs->IsValid()) return;
|
2007-02-20 22:09:21 +00:00
|
|
|
|
|
|
|
int colour = cs->rating_colour;
|
2007-12-05 17:08:10 +00:00
|
|
|
uint w = (minu(amount, units_full) + 5) / 36;
|
2006-12-09 00:46:02 +00:00
|
|
|
|
2009-11-17 12:05:55 +00:00
|
|
|
int height = GetCharacterHeight(FS_SMALL);
|
|
|
|
|
2006-12-09 00:46:02 +00:00
|
|
|
/* Draw total cargo (limited) on station (fits into 16 pixels) */
|
2009-11-17 12:05:55 +00:00
|
|
|
if (w != 0) GfxFillRect(left, y, left + w - 1, y + height, colour);
|
2006-12-09 00:46:02 +00:00
|
|
|
|
|
|
|
/* Draw a one pixel-wide bar of additional cargo meter, useful
|
|
|
|
* for stations with only a small amount (<=30) */
|
|
|
|
if (w == 0) {
|
|
|
|
uint rest = amount / 5;
|
|
|
|
if (rest != 0) {
|
2009-03-22 14:55:49 +00:00
|
|
|
w += left;
|
2009-11-17 12:05:55 +00:00
|
|
|
GfxFillRect(w, y + height - rest, w, y + height, colour);
|
2006-12-09 00:46:02 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-03-22 14:55:49 +00:00
|
|
|
DrawString(left + 1, right, y, cs->abbrev, TC_BLACK);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-12-09 00:46:02 +00:00
|
|
|
/* Draw green/red ratings bar (fits into 14 pixels) */
|
2009-11-17 12:05:55 +00:00
|
|
|
y += height + 2;
|
2009-03-22 14:55:49 +00:00
|
|
|
GfxFillRect(left + 1, y, left + 14, y, 0xB8);
|
2007-12-05 17:08:10 +00:00
|
|
|
rating = minu(rating, rating_full) / 16;
|
2009-03-22 14:55:49 +00:00
|
|
|
if (rating != 0) GfxFillRect(left + 1, y, left + rating, y, 0xD0);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
typedef GUIList<const Station*> GUIStationList;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-05-03 10:38:35 +00:00
|
|
|
/** Enum for CompanyStations, referring to _company_stations_widgets */
|
|
|
|
enum StationListWidgets {
|
|
|
|
SLW_CAPTION, ///< Window caption
|
|
|
|
SLW_LIST, ///< The main panel, list of stations
|
|
|
|
SLW_SCROLLBAR, ///< Scrollbar next to the main panel
|
|
|
|
|
|
|
|
SLW_TRAIN, ///< 'TRAIN' button - list only facilities where is a railroad station
|
|
|
|
SLW_TRUCK, ///< 'TRUCK' button - list only facilities where is a truck stop
|
|
|
|
SLW_BUS, ///< 'BUS' button - list only facilities where is a bus stop
|
|
|
|
SLW_AIRPLANE, ///< 'AIRPLANE' button - list only facilities where is an airport
|
|
|
|
SLW_SHIP, ///< 'SHIP' button - list only facilities where is a dock
|
|
|
|
SLW_FACILALL, ///< 'ALL' button - list all facilities
|
|
|
|
|
|
|
|
SLW_NOCARGOWAITING, ///< 'NO' button - list stations where no cargo is waiting
|
|
|
|
SLW_CARGOALL, ///< 'ALL' button - list all stations
|
|
|
|
|
|
|
|
SLW_SORTBY, ///< 'Sort by' button - reverse sort direction
|
|
|
|
SLW_SORTDROPBTN, ///< Dropdown button
|
|
|
|
|
|
|
|
SLW_CARGOSTART, ///< Widget numbers used for list of cargo types (not present in _company_stations_widgets)
|
|
|
|
};
|
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* The list of stations per company.
|
2008-05-27 09:57:29 +00:00
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
class CompanyStationsWindow : public Window
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-27 09:57:29 +00:00
|
|
|
protected:
|
|
|
|
/* Runtime saved values */
|
|
|
|
static Listing last_sorting;
|
|
|
|
static byte facilities; // types of stations of interest
|
|
|
|
static bool include_empty; // whether we should include stations without waiting cargo
|
|
|
|
static const uint32 cargo_filter_max;
|
|
|
|
static uint32 cargo_filter; // bitmap of cargo types to include
|
|
|
|
static const Station *last_station;
|
|
|
|
|
|
|
|
/* Constants for sorting stations */
|
|
|
|
static const StringID sorter_names[];
|
2009-03-15 16:04:39 +00:00
|
|
|
static GUIStationList::SortFunction * const sorter_funcs[];
|
2004-09-06 18:15:13 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
GUIStationList stations;
|
2004-09-06 18:15:13 +00:00
|
|
|
|
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/**
|
|
|
|
* (Re)Build station list
|
|
|
|
*
|
2008-09-30 20:39:50 +00:00
|
|
|
* @param owner company whose stations are to be in list
|
2008-05-27 09:57:29 +00:00
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
void BuildStationsList(const Owner owner)
|
2008-05-27 09:57:29 +00:00
|
|
|
{
|
|
|
|
if (!this->stations.NeedRebuild()) return;
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
DEBUG(misc, 3, "Building station list for company %d", owner);
|
2008-05-27 09:57:29 +00:00
|
|
|
|
|
|
|
this->stations.Clear();
|
|
|
|
|
|
|
|
const Station *st;
|
|
|
|
FOR_ALL_STATIONS(st) {
|
2009-07-22 08:59:57 +00:00
|
|
|
if (st->owner == owner || (st->owner == OWNER_NONE && HasStationInUse(st->index, owner))) {
|
2008-05-27 09:57:29 +00:00
|
|
|
if (this->facilities & st->facilities) { // only stations with selected facilities
|
|
|
|
int num_waiting_cargo = 0;
|
|
|
|
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
|
|
|
if (!st->goods[j].cargo.Empty()) {
|
|
|
|
num_waiting_cargo++; // count number of waiting cargo
|
|
|
|
if (HasBit(this->cargo_filter, j)) {
|
|
|
|
*this->stations.Append() = st;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* stations without waiting cargo */
|
|
|
|
if (num_waiting_cargo == 0 && this->include_empty) {
|
|
|
|
*this->stations.Append() = st;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
this->stations.Compact();
|
|
|
|
this->stations.RebuildDone();
|
2009-09-02 08:40:31 +00:00
|
|
|
|
|
|
|
this->vscroll.SetCount(this->stations.Length()); // Update the scrollbar
|
2008-05-27 09:57:29 +00:00
|
|
|
}
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/** Sort stations by their name */
|
2009-01-10 00:31:47 +00:00
|
|
|
static int CDECL StationNameSorter(const Station * const *a, const Station * const *b)
|
2008-05-27 09:57:29 +00:00
|
|
|
{
|
|
|
|
static char buf_cache[64];
|
|
|
|
char buf[64];
|
2007-11-15 17:54:46 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
SetDParam(0, (*a)->index);
|
2009-07-20 11:21:57 +00:00
|
|
|
GetString(buf, STR_STATION_NAME, lastof(buf));
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
if (*b != last_station) {
|
|
|
|
last_station = *b;
|
|
|
|
SetDParam(0, (*b)->index);
|
2009-07-20 11:21:57 +00:00
|
|
|
GetString(buf_cache, STR_STATION_NAME, lastof(buf_cache));
|
2008-05-27 09:57:29 +00:00
|
|
|
}
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
return strcmp(buf, buf_cache);
|
2006-05-11 10:33:58 +00:00
|
|
|
}
|
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/** Sort stations by their type */
|
2009-01-10 00:31:47 +00:00
|
|
|
static int CDECL StationTypeSorter(const Station * const *a, const Station * const *b)
|
2008-05-27 09:57:29 +00:00
|
|
|
{
|
|
|
|
return (*a)->facilities - (*b)->facilities;
|
|
|
|
}
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/** Sort stations by their waiting cargo */
|
2009-01-10 00:31:47 +00:00
|
|
|
static int CDECL StationWaitingSorter(const Station * const *a, const Station * const *b)
|
2008-05-27 09:57:29 +00:00
|
|
|
{
|
2008-06-23 22:51:21 +00:00
|
|
|
Money diff = 0;
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
|
|
|
if (!HasBit(cargo_filter, j)) continue;
|
2008-06-23 22:51:21 +00:00
|
|
|
if (!(*a)->goods[j].cargo.Empty()) diff += GetTransportedGoodsIncome((*a)->goods[j].cargo.Count(), 20, 50, j);
|
|
|
|
if (!(*b)->goods[j].cargo.Empty()) diff -= GetTransportedGoodsIncome((*b)->goods[j].cargo.Count(), 20, 50, j);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-06-23 22:51:21 +00:00
|
|
|
return ClampToI32(diff);
|
2008-05-27 09:57:29 +00:00
|
|
|
}
|
2004-09-14 14:19:53 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/** Sort stations by their rating */
|
2009-01-10 00:31:47 +00:00
|
|
|
static int CDECL StationRatingMaxSorter(const Station * const *a, const Station * const *b)
|
2008-05-27 09:57:29 +00:00
|
|
|
{
|
|
|
|
byte maxr1 = 0;
|
|
|
|
byte maxr2 = 0;
|
2007-12-05 17:08:10 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
2009-04-12 19:23:26 +00:00
|
|
|
if (!HasBit(cargo_filter, j)) continue;
|
2008-05-27 09:57:29 +00:00
|
|
|
if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr1 = max(maxr1, (*a)->goods[j].rating);
|
|
|
|
if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr2 = max(maxr2, (*b)->goods[j].rating);
|
|
|
|
}
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
return maxr1 - maxr2;
|
|
|
|
}
|
2004-09-14 14:19:53 +00:00
|
|
|
|
2009-04-12 19:15:53 +00:00
|
|
|
/** Sort stations by their rating */
|
|
|
|
static int CDECL StationRatingMinSorter(const Station * const *a, const Station * const *b)
|
|
|
|
{
|
2009-04-12 19:23:26 +00:00
|
|
|
byte minr1 = 255;
|
|
|
|
byte minr2 = 255;
|
2009-04-12 19:15:53 +00:00
|
|
|
|
|
|
|
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
2009-04-12 19:23:26 +00:00
|
|
|
if (!HasBit(cargo_filter, j)) continue;
|
2009-04-12 19:15:53 +00:00
|
|
|
if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) minr1 = min(minr1, (*a)->goods[j].rating);
|
|
|
|
if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) minr2 = min(minr2, (*b)->goods[j].rating);
|
|
|
|
}
|
|
|
|
|
2009-04-12 19:23:26 +00:00
|
|
|
return -(minr1 - minr2);
|
2009-04-12 19:15:53 +00:00
|
|
|
}
|
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/** Sort the stations list */
|
|
|
|
void SortStationsList()
|
|
|
|
{
|
2008-05-27 10:27:30 +00:00
|
|
|
if (!this->stations.Sort()) return;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
/* Reset name sorter sort cache */
|
|
|
|
this->last_station = NULL;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-27 20:33:44 +00:00
|
|
|
/* Set the modified widget dirty */
|
2009-09-13 19:15:59 +00:00
|
|
|
this->SetWidgetDirty(SLW_LIST);
|
2008-05-27 09:57:29 +00:00
|
|
|
}
|
2008-05-27 09:24:45 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
public:
|
2009-11-08 19:31:57 +00:00
|
|
|
CompanyStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
2008-05-11 18:50:12 +00:00
|
|
|
{
|
2009-11-08 19:31:57 +00:00
|
|
|
this->stations.SetListing(this->last_sorting);
|
|
|
|
this->stations.SetSortFuncs(this->sorter_funcs);
|
|
|
|
this->stations.ForceRebuild();
|
|
|
|
this->stations.NeedResort();
|
|
|
|
this->SortStationsList();
|
2007-01-11 15:30:35 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
this->InitNested(desc, window_number);
|
|
|
|
this->owner = (Owner)this->window_number;
|
2008-05-11 18:50:12 +00:00
|
|
|
|
2009-11-08 19:36:17 +00:00
|
|
|
for (uint i = 0; i < NUM_CARGO; i++) {
|
|
|
|
const CargoSpec *cs = CargoSpec::Get(i);
|
|
|
|
if (cs->IsValid() && HasBit(this->cargo_filter, i)) this->LowerWidget(SLW_CARGOSTART + i);
|
2008-05-11 18:50:12 +00:00
|
|
|
}
|
2006-05-11 15:14:50 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
if (this->cargo_filter == this->cargo_filter_max) this->cargo_filter = _cargo_mask;
|
2007-12-05 17:08:10 +00:00
|
|
|
|
2008-05-11 18:50:12 +00:00
|
|
|
for (uint i = 0; i < 5; i++) {
|
2008-05-27 09:57:29 +00:00
|
|
|
if (HasBit(this->facilities, i)) this->LowerWidget(i + SLW_TRAIN);
|
2008-05-11 18:50:12 +00:00
|
|
|
}
|
2008-05-27 09:57:29 +00:00
|
|
|
this->SetWidgetLoweredState(SLW_FACILALL, this->facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
|
|
|
|
this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty);
|
|
|
|
this->SetWidgetLoweredState(SLW_NOCARGOWAITING, this->include_empty);
|
2008-05-11 18:50:12 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
this->GetWidget<NWidgetCore>(SLW_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
|
2008-05-11 18:50:12 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
~CompanyStationsWindow()
|
2008-05-27 09:24:45 +00:00
|
|
|
{
|
2008-05-27 09:57:29 +00:00
|
|
|
this->last_sorting = this->stations.GetListing();
|
2008-05-27 09:24:45 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 18:28:14 +00:00
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
2008-05-11 18:50:12 +00:00
|
|
|
{
|
2009-11-08 19:31:57 +00:00
|
|
|
switch (widget) {
|
2009-11-23 20:13:37 +00:00
|
|
|
case SLW_SORTBY: {
|
|
|
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
|
|
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the word is centered, also looks nice.
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
case SLW_SORTDROPBTN: {
|
|
|
|
Dimension d = {0, 0};
|
|
|
|
for (int i = 0; this->sorter_names[i] != INVALID_STRING_ID; i++) {
|
|
|
|
d = maxdim(d, GetStringBoundingBox(this->sorter_names[i]));
|
|
|
|
}
|
|
|
|
d.width += padding.width;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
case SLW_LIST:
|
|
|
|
resize->height = FONT_HEIGHT_NORMAL;
|
|
|
|
size->height = WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM;
|
|
|
|
break;
|
2009-11-23 20:13:37 +00:00
|
|
|
|
|
|
|
case SLW_TRAIN:
|
|
|
|
case SLW_TRUCK:
|
|
|
|
case SLW_BUS:
|
|
|
|
case SLW_AIRPLANE:
|
|
|
|
case SLW_SHIP:
|
|
|
|
size->height = max<uint>(FONT_HEIGHT_SMALL, 10) + padding.height;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLW_CARGOALL:
|
|
|
|
case SLW_FACILALL:
|
|
|
|
case SLW_NOCARGOWAITING: {
|
|
|
|
Dimension d = GetStringBoundingBox(widget == SLW_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL);
|
|
|
|
d.width += padding.width + 2;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (widget >= SLW_CARGOSTART) {
|
|
|
|
const CargoSpec *cs = CargoSpec::Get(widget - SLW_CARGOSTART);
|
|
|
|
if (cs->IsValid()) {
|
|
|
|
Dimension d = GetStringBoundingBox(cs->abbrev);
|
|
|
|
d.width += padding.width + 2;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-11-08 19:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-17 18:49:39 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
this->BuildStationsList((Owner)this->window_number);
|
|
|
|
this->SortStationsList();
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2009-11-08 19:31:57 +00:00
|
|
|
}
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case SLW_SORTBY:
|
|
|
|
/* draw arrow pointing up/down for ascending/descending sorting */
|
|
|
|
this->DrawSortButtonState(SLW_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
|
|
|
break;
|
2006-12-07 04:12:29 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
case SLW_LIST: {
|
2009-11-16 14:48:22 +00:00
|
|
|
bool rtl = _dynlang.text_dir == TD_RTL;
|
2009-11-08 19:31:57 +00:00
|
|
|
int max = min(this->vscroll.GetPosition() + this->vscroll.GetCapacity(), this->stations.Length());
|
|
|
|
int y = r.top + WD_FRAMERECT_TOP;
|
|
|
|
for (int i = this->vscroll.GetPosition(); i < max; ++i) { // do until max number of stations of owner
|
|
|
|
const Station *st = this->stations[i];
|
|
|
|
assert(st->xy != INVALID_TILE);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
/* Do not do the complex check HasStationInUse here, it may be even false
|
|
|
|
* when the order had been removed and the station list hasn't been removed yet */
|
|
|
|
assert(st->owner == owner || st->owner == OWNER_NONE);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
SetDParam(0, st->index);
|
|
|
|
SetDParam(1, st->facilities);
|
2009-11-16 14:48:22 +00:00
|
|
|
int x = DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_LIST_STATION);
|
|
|
|
x += rtl ? -5 : 5;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
/* show cargo waiting and station ratings */
|
|
|
|
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
|
|
|
if (!st->goods[j].cargo.Empty()) {
|
2009-11-16 14:48:22 +00:00
|
|
|
/* For RTL we work in exactly the opposite direction. So
|
|
|
|
* decrement the space needed first, then draw to the left
|
|
|
|
* instead of drawing to the left and then incrementing
|
|
|
|
* the space. */
|
|
|
|
if (rtl) {
|
|
|
|
x -= 20;
|
|
|
|
if (x < r.left + WD_FRAMERECT_LEFT) break;
|
|
|
|
}
|
|
|
|
StationsWndShowStationRating(x, x + 16, y, j, st->goods[j].cargo.Count(), st->goods[j].rating);
|
|
|
|
if (!rtl) {
|
|
|
|
x += 20;
|
|
|
|
if (x > r.right - WD_FRAMERECT_RIGHT) break;
|
|
|
|
}
|
2009-11-08 19:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
if (this->vscroll.GetCount() == 0) { // company has no stations
|
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_LIST_NONE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-12-19 23:35:14 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
case SLW_NOCARGOWAITING: {
|
|
|
|
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
|
|
|
|
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_CENTER);
|
|
|
|
break;
|
|
|
|
}
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
case SLW_CARGOALL: {
|
|
|
|
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
|
|
|
|
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_CENTER);
|
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
case SLW_FACILALL: {
|
|
|
|
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
|
|
|
|
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
|
|
|
|
break;
|
|
|
|
}
|
2008-05-11 18:50:12 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
default:
|
|
|
|
if (widget >= SLW_CARGOSTART) {
|
2009-11-08 19:36:17 +00:00
|
|
|
const CargoSpec *cs = CargoSpec::Get(widget - SLW_CARGOSTART);
|
|
|
|
if (cs->IsValid()) {
|
|
|
|
int cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? 2 : 1;
|
2009-11-23 20:13:37 +00:00
|
|
|
GfxFillRect(r.left + cg_ofst, r.top + cg_ofst, r.right - 2 + cg_ofst, r.bottom - 2 + cg_ofst, cs->rating_colour);
|
|
|
|
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, cs->abbrev, TC_BLACK, SA_CENTER);
|
2009-11-08 19:31:57 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2009-11-08 19:36:17 +00:00
|
|
|
break;
|
2009-11-08 19:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetStringParameters(int widget) const
|
|
|
|
{
|
|
|
|
if (widget == SLW_CAPTION) {
|
|
|
|
SetDParam(0, this->window_number);
|
|
|
|
SetDParam(1, this->vscroll.GetCount());
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-11 18:50:12 +00:00
|
|
|
}
|
2006-12-07 04:12:29 +00:00
|
|
|
|
2008-05-11 18:50:12 +00:00
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case SLW_LIST: {
|
2009-11-08 19:31:57 +00:00
|
|
|
uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(SLW_LIST)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2009-09-02 08:40:31 +00:00
|
|
|
if (id_v >= this->vscroll.GetCapacity()) return; // click out of bounds
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2009-09-02 08:40:31 +00:00
|
|
|
id_v += this->vscroll.GetPosition();
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2008-05-27 09:24:45 +00:00
|
|
|
if (id_v >= this->stations.Length()) return; // click out of list bound
|
2008-05-05 11:36:43 +00:00
|
|
|
|
2008-05-27 09:24:45 +00:00
|
|
|
const Station *st = this->stations[id_v];
|
2008-05-11 18:50:12 +00:00
|
|
|
/* do not check HasStationInUse - it is slow and may be invalid */
|
2009-07-22 08:59:57 +00:00
|
|
|
assert(st->owner == (Owner)this->window_number || st->owner == OWNER_NONE);
|
2008-05-11 18:50:12 +00:00
|
|
|
|
|
|
|
if (_ctrl_pressed) {
|
|
|
|
ShowExtraViewPortWindow(st->xy);
|
|
|
|
} else {
|
|
|
|
ScrollMainWindowToTile(st->xy);
|
2007-03-03 09:40:34 +00:00
|
|
|
}
|
2008-05-11 18:50:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2008-05-11 18:50:12 +00:00
|
|
|
case SLW_TRAIN:
|
|
|
|
case SLW_TRUCK:
|
|
|
|
case SLW_BUS:
|
|
|
|
case SLW_AIRPLANE:
|
|
|
|
case SLW_SHIP:
|
|
|
|
if (_ctrl_pressed) {
|
2008-05-27 09:57:29 +00:00
|
|
|
ToggleBit(this->facilities, widget - SLW_TRAIN);
|
2008-05-11 18:50:12 +00:00
|
|
|
this->ToggleWidgetLoweredState(widget);
|
|
|
|
} else {
|
|
|
|
uint i;
|
2008-05-27 09:57:29 +00:00
|
|
|
FOR_EACH_SET_BIT(i, this->facilities) {
|
2008-05-11 18:50:12 +00:00
|
|
|
this->RaiseWidget(i + SLW_TRAIN);
|
2007-03-03 09:40:34 +00:00
|
|
|
}
|
2008-05-27 09:57:29 +00:00
|
|
|
SetBit(this->facilities, widget - SLW_TRAIN);
|
2008-05-11 18:50:12 +00:00
|
|
|
this->LowerWidget(widget);
|
|
|
|
}
|
2008-05-27 09:57:29 +00:00
|
|
|
this->SetWidgetLoweredState(SLW_FACILALL, this->facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
|
2008-05-27 09:24:45 +00:00
|
|
|
this->stations.ForceRebuild();
|
2008-05-11 18:50:12 +00:00
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLW_FACILALL:
|
|
|
|
for (uint i = 0; i < 5; i++) {
|
|
|
|
this->LowerWidget(i + SLW_TRAIN);
|
|
|
|
}
|
|
|
|
this->LowerWidget(SLW_FACILALL);
|
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
this->facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
|
2008-05-27 09:24:45 +00:00
|
|
|
this->stations.ForceRebuild();
|
2008-05-11 18:50:12 +00:00
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLW_CARGOALL: {
|
2009-11-08 19:36:17 +00:00
|
|
|
for (uint i = 0; i < NUM_CARGO; i++) {
|
|
|
|
const CargoSpec *cs = CargoSpec::Get(i);
|
|
|
|
if (cs->IsValid()) this->LowerWidget(SLW_CARGOSTART + i);
|
2008-05-11 18:50:12 +00:00
|
|
|
}
|
|
|
|
this->LowerWidget(SLW_NOCARGOWAITING);
|
|
|
|
this->LowerWidget(SLW_CARGOALL);
|
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
this->cargo_filter = _cargo_mask;
|
|
|
|
this->include_empty = true;
|
2008-05-27 09:24:45 +00:00
|
|
|
this->stations.ForceRebuild();
|
2008-05-11 18:50:12 +00:00
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SLW_SORTBY: // flip sorting method asc/desc
|
2008-05-27 09:24:45 +00:00
|
|
|
this->stations.ToggleSortOrder();
|
2008-09-23 15:24:15 +00:00
|
|
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
2008-05-11 18:50:12 +00:00
|
|
|
this->LowerWidget(SLW_SORTBY);
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SLW_SORTDROPBTN: // select sorting criteria dropdown menu
|
2008-05-27 09:57:29 +00:00
|
|
|
ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), SLW_SORTDROPBTN, 0, 0);
|
2008-05-11 18:50:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SLW_NOCARGOWAITING:
|
|
|
|
if (_ctrl_pressed) {
|
2008-05-27 09:57:29 +00:00
|
|
|
this->include_empty = !this->include_empty;
|
2008-05-11 18:50:12 +00:00
|
|
|
this->ToggleWidgetLoweredState(SLW_NOCARGOWAITING);
|
|
|
|
} else {
|
2009-11-08 19:36:17 +00:00
|
|
|
for (uint i = 0; i < NUM_CARGO; i++) {
|
|
|
|
const CargoSpec *cs = CargoSpec::Get(i);
|
|
|
|
if (cs->IsValid()) this->RaiseWidget(SLW_CARGOSTART + i);
|
2007-03-03 09:40:34 +00:00
|
|
|
}
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
this->cargo_filter = 0;
|
|
|
|
this->include_empty = true;
|
2006-12-07 04:12:29 +00:00
|
|
|
|
2008-05-11 18:50:12 +00:00
|
|
|
this->LowerWidget(SLW_NOCARGOWAITING);
|
|
|
|
}
|
2008-05-27 09:57:29 +00:00
|
|
|
this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty);
|
2008-05-27 09:24:45 +00:00
|
|
|
this->stations.ForceRebuild();
|
2008-05-11 18:50:12 +00:00
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (widget >= SLW_CARGOSTART) { // change cargo_filter
|
|
|
|
/* Determine the selected cargo type */
|
2009-11-08 19:36:17 +00:00
|
|
|
const CargoSpec *cs = CargoSpec::Get(widget - SLW_CARGOSTART);
|
|
|
|
if (!cs->IsValid()) break;
|
2007-03-03 09:40:34 +00:00
|
|
|
|
2007-03-09 22:55:57 +00:00
|
|
|
if (_ctrl_pressed) {
|
2009-07-16 20:40:06 +00:00
|
|
|
ToggleBit(this->cargo_filter, cs->Index());
|
2008-05-11 18:50:12 +00:00
|
|
|
this->ToggleWidgetLoweredState(widget);
|
2007-03-09 22:55:57 +00:00
|
|
|
} else {
|
2009-11-08 19:36:17 +00:00
|
|
|
for (uint i = 0; i < NUM_CARGO; i++) {
|
|
|
|
const CargoSpec *cs = CargoSpec::Get(i);
|
|
|
|
if (cs->IsValid()) this->RaiseWidget(SLW_CARGOSTART + i);
|
2007-03-09 22:55:57 +00:00
|
|
|
}
|
2008-05-11 18:50:12 +00:00
|
|
|
this->RaiseWidget(SLW_NOCARGOWAITING);
|
2007-03-09 22:55:57 +00:00
|
|
|
|
2008-05-27 09:57:29 +00:00
|
|
|
this->cargo_filter = 0;
|
|
|
|
this->include_empty = false;
|
2007-03-09 22:55:57 +00:00
|
|
|
|
2009-07-16 20:40:06 +00:00
|
|
|
SetBit(this->cargo_filter, cs->Index());
|
2008-05-11 18:50:12 +00:00
|
|
|
this->LowerWidget(widget);
|
2007-03-09 22:55:57 +00:00
|
|
|
}
|
2008-05-27 09:57:29 +00:00
|
|
|
this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty);
|
2008-05-27 09:24:45 +00:00
|
|
|
this->stations.ForceRebuild();
|
2008-05-11 18:50:12 +00:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-03-09 22:55:57 +00:00
|
|
|
|
2008-05-11 18:50:12 +00:00
|
|
|
virtual void OnDropdownSelect(int widget, int index)
|
|
|
|
{
|
2008-05-27 09:24:45 +00:00
|
|
|
if (this->stations.SortType() != index) {
|
|
|
|
this->stations.SetSortType(index);
|
2008-05-27 20:33:44 +00:00
|
|
|
|
|
|
|
/* Display the current sort variant */
|
2009-11-08 19:31:57 +00:00
|
|
|
this->GetWidget<NWidgetCore>(SLW_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
|
2008-05-27 20:33:44 +00:00
|
|
|
|
2008-05-27 09:24:45 +00:00
|
|
|
this->SetDirty();
|
2008-05-11 18:50:12 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-09 22:55:57 +00:00
|
|
|
|
2008-05-11 18:50:12 +00:00
|
|
|
virtual void OnTick()
|
|
|
|
{
|
2009-05-06 15:06:57 +00:00
|
|
|
if (_pause_mode != PM_UNPAUSED) return;
|
2008-05-27 09:24:45 +00:00
|
|
|
if (this->stations.NeedResort()) {
|
2008-09-30 20:39:50 +00:00
|
|
|
DEBUG(misc, 3, "Periodic rebuild station list company %d", this->window_number);
|
2008-05-11 18:50:12 +00:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-11 18:50:12 +00:00
|
|
|
virtual void OnTimeout()
|
|
|
|
{
|
|
|
|
this->RaiseWidget(SLW_SORTBY);
|
|
|
|
this->SetDirty();
|
|
|
|
}
|
2006-05-11 10:33:58 +00:00
|
|
|
|
2009-10-24 14:53:55 +00:00
|
|
|
virtual void OnResize()
|
2008-05-11 18:50:12 +00:00
|
|
|
{
|
2009-12-20 20:08:39 +00:00
|
|
|
this->vscroll.SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-18 16:51:44 +00:00
|
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
{
|
2008-05-27 09:24:45 +00:00
|
|
|
if (data == 0) {
|
|
|
|
this->stations.ForceRebuild();
|
|
|
|
} else {
|
|
|
|
this->stations.ForceResort();
|
|
|
|
}
|
2008-05-18 16:51:44 +00:00
|
|
|
}
|
2008-05-11 18:50:12 +00:00
|
|
|
};
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
Listing CompanyStationsWindow::last_sorting = {false, 0};
|
|
|
|
byte CompanyStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
|
|
|
|
bool CompanyStationsWindow::include_empty = true;
|
|
|
|
const uint32 CompanyStationsWindow::cargo_filter_max = UINT32_MAX;
|
|
|
|
uint32 CompanyStationsWindow::cargo_filter = UINT32_MAX;
|
|
|
|
const Station *CompanyStationsWindow::last_station = NULL;
|
2008-05-27 09:57:29 +00:00
|
|
|
|
|
|
|
/* Availible station sorting functions */
|
2009-03-15 16:04:39 +00:00
|
|
|
GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = {
|
2008-05-27 09:57:29 +00:00
|
|
|
&StationNameSorter,
|
|
|
|
&StationTypeSorter,
|
|
|
|
&StationWaitingSorter,
|
2009-04-12 19:15:53 +00:00
|
|
|
&StationRatingMaxSorter,
|
|
|
|
&StationRatingMinSorter
|
2008-05-27 09:57:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Names of the sorting functions */
|
2008-09-30 20:39:50 +00:00
|
|
|
const StringID CompanyStationsWindow::sorter_names[] = {
|
2009-07-23 19:31:50 +00:00
|
|
|
STR_SORT_BY_NAME,
|
2008-05-27 09:57:29 +00:00
|
|
|
STR_SORT_BY_FACILITY,
|
|
|
|
STR_SORT_BY_WAITING,
|
|
|
|
STR_SORT_BY_RATING_MAX,
|
2009-04-12 19:15:53 +00:00
|
|
|
STR_SORT_BY_RATING_MIN,
|
2008-05-27 09:57:29 +00:00
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
2008-05-11 18:50:12 +00:00
|
|
|
|
2009-11-08 19:31:57 +00:00
|
|
|
/** Make a horizontal row of cargo buttons, starting at widget #SLW_CARGOSTART.
|
|
|
|
* @param biggest_index Pointer to store biggest used widget number of the buttons.
|
|
|
|
* @return Horizontal row.
|
|
|
|
*/
|
|
|
|
static NWidgetBase *CargoWidgets(int *biggest_index)
|
|
|
|
{
|
|
|
|
NWidgetHorizontal *container = new NWidgetHorizontal();
|
|
|
|
|
2009-11-08 19:36:17 +00:00
|
|
|
for (uint i = 0; i < NUM_CARGO; i++) {
|
|
|
|
const CargoSpec *cs = CargoSpec::Get(i);
|
|
|
|
if (cs->IsValid()) {
|
|
|
|
NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, SLW_CARGOSTART + i);
|
|
|
|
panel->SetMinimalSize(14, 11);
|
|
|
|
panel->SetResize(0, 0);
|
2009-11-22 18:26:01 +00:00
|
|
|
panel->SetFill(0, 1);
|
2009-11-08 19:36:17 +00:00
|
|
|
panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE);
|
|
|
|
container->Add(panel);
|
|
|
|
} else {
|
|
|
|
NWidgetLeaf *nwi = new NWidgetLeaf(WWT_EMPTY, COLOUR_GREY, SLW_CARGOSTART + i, 0x0, STR_NULL);
|
|
|
|
nwi->SetMinimalSize(0, 11);
|
|
|
|
nwi->SetResize(0, 0);
|
2009-11-22 18:26:01 +00:00
|
|
|
nwi->SetFill(0, 1);
|
2009-11-08 19:36:17 +00:00
|
|
|
container->Add(nwi);
|
|
|
|
}
|
2009-11-08 19:31:57 +00:00
|
|
|
}
|
2009-11-08 19:36:17 +00:00
|
|
|
*biggest_index = SLW_CARGOSTART + NUM_CARGO;
|
2009-11-08 19:31:57 +00:00
|
|
|
return container;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-05-03 10:46:24 +00:00
|
|
|
static const NWidgetPart _nested_company_stations_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
2009-05-03 10:46:24 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, SLW_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_TRAIN), SetMinimalSize(14, 11), SetDataTip(STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_TRUCK), SetMinimalSize(14, 11), SetDataTip(STR_LORRY, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_BUS), SetMinimalSize(14, 11), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_AIRPLANE), SetMinimalSize(14, 11), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_SHIP), SetMinimalSize(14, 11), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, SLW_FACILALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1), EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(5, 11), SetFill(0, 1), EndContainer(),
|
2009-11-08 19:31:57 +00:00
|
|
|
NWidgetFunction(CargoWidgets),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, SLW_NOCARGOWAITING), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, SLW_CARGOALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1), EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-08-05 17:59:21 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
|
2009-11-08 19:31:57 +00:00
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, SLW_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(STR_SORT_BY_NAME, STR_TOOLTIP_SORT_CRITERIAP), // widget_data gets overwritten.
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, SLW_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), EndContainer(),
|
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidget(WWT_SCROLLBAR, COLOUR_GREY, SLW_SCROLLBAR),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _company_stations_desc(
|
2009-11-28 14:42:35 +00:00
|
|
|
WDP_AUTO, 358, 162,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_STATION_LIST, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
0,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_company_stations_widgets, lengthof(_nested_company_stations_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-12-05 17:08:10 +00:00
|
|
|
/**
|
2008-09-30 20:39:50 +00:00
|
|
|
* Opens window with list of company's stations
|
2007-12-05 17:08:10 +00:00
|
|
|
*
|
2008-09-30 20:39:50 +00:00
|
|
|
* @param company whose stations' list show
|
2007-12-05 17:08:10 +00:00
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
void ShowCompanyStations(CompanyID company)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2009-05-17 01:00:56 +00:00
|
|
|
if (!Company::IsValidID(company)) return;
|
2006-10-31 21:15:56 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
AllocateWindowDescFront<CompanyStationsWindow>(&_company_stations_desc, company);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-05-03 10:46:24 +00:00
|
|
|
static const NWidgetPart _nested_station_view_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
2009-05-03 10:46:24 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, SVW_CAPTION), SetDataTip(STR_STATION_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, SVW_WAITING), SetMinimalSize(237, 52), SetResize(1, 10), EndContainer(),
|
|
|
|
NWidget(WWT_SCROLLBAR, COLOUR_GREY, SVW_SCROLLBAR),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, SVW_ACCEPTLIST), SetMinimalSize(249, 32), SetResize(1, 0), EndContainer(),
|
2009-11-08 15:26:20 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_LOCATION), SetMinimalSize(60, 12), SetResize(1, 0), SetFill(1, 1),
|
2009-11-08 15:26:20 +00:00
|
|
|
SetDataTip(STR_BUTTON_LOCATION, STR_STATION_VIEW_CENTER_TOOLTIP),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_ACCEPTS), SetMinimalSize(61, 12), SetResize(1, 0), SetFill(1, 1),
|
2009-11-08 15:26:20 +00:00
|
|
|
SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_RENAME), SetMinimalSize(60, 12), SetResize(1, 0), SetFill(1, 1),
|
2009-11-08 15:26:20 +00:00
|
|
|
SetDataTip(STR_BUTTON_RENAME, STR_STATION_VIEW_RENAME_TOOLTIP),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_TRAINS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_ROADVEHS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_LORRY, STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_PLANES), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_PLANE, STR_STATION_VIEW_SCHEDULED_AIRCRAFT_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_SHIPS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2008-03-28 04:57:32 +00:00
|
|
|
/**
|
|
|
|
* Draws icons of waiting cargo in the StationView window
|
|
|
|
*
|
|
|
|
* @param i type of cargo
|
|
|
|
* @param waiting number of waiting units
|
2009-11-18 20:22:39 +00:00
|
|
|
* @param left left most coordinate to draw on
|
|
|
|
* @param right right most coordinate to draw on
|
2008-03-28 04:57:32 +00:00
|
|
|
* @param y y coordinate
|
2009-09-19 09:51:14 +00:00
|
|
|
* @param width the width of the view
|
2008-03-28 04:57:32 +00:00
|
|
|
*/
|
2009-11-18 20:22:39 +00:00
|
|
|
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int y)
|
2008-03-28 04:57:32 +00:00
|
|
|
{
|
2009-11-18 20:22:39 +00:00
|
|
|
uint num = min((waiting + 5) / 10, (right - left) / 10); // maximum is width / 10 icons so it won't overflow
|
2008-03-28 04:57:32 +00:00
|
|
|
if (num == 0) return;
|
|
|
|
|
2009-12-05 16:00:58 +00:00
|
|
|
SpriteID sprite = CargoSpec::Get(i)->GetCargoIcon();
|
2008-03-28 04:57:32 +00:00
|
|
|
|
2009-11-18 20:22:39 +00:00
|
|
|
int x = _dynlang.text_dir == TD_RTL ? right - num * 10 : left;
|
2007-03-23 20:51:42 +00:00
|
|
|
do {
|
|
|
|
DrawSprite(sprite, PAL_NONE, x, y);
|
|
|
|
x += 10;
|
|
|
|
} while (--num);
|
|
|
|
}
|
|
|
|
|
2008-01-26 22:15:39 +00:00
|
|
|
struct CargoData {
|
|
|
|
CargoID cargo;
|
|
|
|
StationID source;
|
|
|
|
uint count;
|
|
|
|
|
|
|
|
CargoData(CargoID cargo, StationID source, uint count) :
|
|
|
|
cargo(cargo),
|
|
|
|
source(source),
|
|
|
|
count(count)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::list<CargoData> CargoDataList;
|
|
|
|
|
2007-12-05 17:08:10 +00:00
|
|
|
/**
|
2008-05-11 17:24:52 +00:00
|
|
|
* The StationView window
|
2007-12-05 17:08:10 +00:00
|
|
|
*/
|
2008-05-11 17:24:52 +00:00
|
|
|
struct StationViewWindow : public Window {
|
|
|
|
uint32 cargo; ///< Bitmask of cargo types to expand
|
2008-05-27 22:02:26 +00:00
|
|
|
uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type
|
2009-11-18 20:22:39 +00:00
|
|
|
uint expand_shrink_width; ///< The width allocated to the expand/shrink 'button'
|
2008-05-11 17:24:52 +00:00
|
|
|
|
2009-11-08 15:26:20 +00:00
|
|
|
/** Height of the #SVW_ACCEPTLIST widget for different views. */
|
|
|
|
enum AcceptListHeight {
|
2009-11-16 20:40:35 +00:00
|
|
|
ALH_RATING = 13, ///< Height of the cargo ratings view.
|
|
|
|
ALH_ACCEPTS = 3, ///< Height of the accepted cargo view.
|
2009-11-08 15:26:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
2008-05-11 17:24:52 +00:00
|
|
|
{
|
2009-11-08 15:26:20 +00:00
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
/* Nested widget tree creation is done in two steps to ensure that this->GetWidget<NWidgetCore>(SVW_ACCEPTS) exists in UpdateWidgetSize(). */
|
|
|
|
this->FinishInitNested(desc, window_number);
|
|
|
|
|
2009-05-16 23:34:14 +00:00
|
|
|
Owner owner = Station::Get(window_number)->owner;
|
2009-02-09 02:33:10 +00:00
|
|
|
if (owner != OWNER_NONE) this->owner = owner;
|
2008-05-11 17:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~StationViewWindow()
|
|
|
|
{
|
2009-11-08 15:26:20 +00:00
|
|
|
WindowNumber wno = (this->window_number << 16) | VLW_STATION_LIST | Station::Get(this->window_number)->owner;
|
2008-05-11 17:24:52 +00:00
|
|
|
|
2009-01-02 20:59:04 +00:00
|
|
|
DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11), false);
|
|
|
|
DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false);
|
|
|
|
DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11), false);
|
|
|
|
DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11), false);
|
2008-05-11 17:24:52 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 18:28:14 +00:00
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
2009-11-08 15:26:20 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case SVW_WAITING:
|
|
|
|
resize->height = FONT_HEIGHT_NORMAL;
|
|
|
|
size->height = WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM;
|
2009-11-18 20:22:39 +00:00
|
|
|
this->expand_shrink_width = max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
2009-11-08 15:26:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SVW_ACCEPTLIST:
|
2009-11-16 20:40:35 +00:00
|
|
|
size->height = WD_FRAMERECT_TOP + ((this->GetWidget<NWidgetCore>(SVW_ACCEPTS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? ALH_ACCEPTS : ALH_RATING) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
2009-11-08 15:26:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
CargoDataList cargolist;
|
|
|
|
uint32 transfers = 0;
|
2009-11-08 12:45:16 +00:00
|
|
|
this->OrderWaitingCargo(&cargolist, &transfers);
|
|
|
|
|
|
|
|
this->vscroll.SetCount((int)cargolist.size() + 1); // update scrollbar
|
|
|
|
|
|
|
|
/* disable some buttons */
|
|
|
|
const Station *st = Station::Get(this->window_number);
|
|
|
|
this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_company);
|
|
|
|
this->SetWidgetDisabledState(SVW_TRAINS, !(st->facilities & FACIL_TRAIN));
|
|
|
|
this->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
|
|
|
|
this->SetWidgetDisabledState(SVW_PLANES, !(st->facilities & FACIL_AIRPORT));
|
|
|
|
this->SetWidgetDisabledState(SVW_SHIPS, !(st->facilities & FACIL_DOCK));
|
|
|
|
|
|
|
|
this->DrawWidgets();
|
|
|
|
|
2009-12-21 16:24:29 +00:00
|
|
|
if (!this->IsShaded()) {
|
|
|
|
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(SVW_WAITING);
|
|
|
|
Rect waiting_rect = {nwi->pos_x, nwi->pos_y, nwi->pos_x + nwi->current_x - 1, nwi->pos_y + nwi->current_y - 1};
|
|
|
|
this->DrawWaitingCargo(waiting_rect, cargolist, transfers);
|
|
|
|
}
|
2009-11-08 15:26:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
if (widget != SVW_ACCEPTLIST) return;
|
2009-11-08 12:45:16 +00:00
|
|
|
|
2009-11-08 15:26:20 +00:00
|
|
|
if (this->GetWidget<NWidgetCore>(SVW_ACCEPTS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) {
|
|
|
|
this->DrawAcceptedCargo(r);
|
2009-11-08 12:45:16 +00:00
|
|
|
} else {
|
2009-11-08 15:26:20 +00:00
|
|
|
this->DrawCargoRatings(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetStringParameters(int widget) const
|
|
|
|
{
|
|
|
|
if (widget == SVW_CAPTION) {
|
|
|
|
const Station *st = Station::Get(this->window_number);
|
|
|
|
SetDParam(0, st->index);
|
|
|
|
SetDParam(1, st->facilities);
|
2009-11-08 12:45:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Order waiting cargo by type and destination.
|
|
|
|
* @param cargolist [out] Ordered cargo.
|
|
|
|
* @param transfers [out] Bitmask for cargoes being transfered.
|
|
|
|
* @pre \c *cargolist must be empty.
|
|
|
|
*/
|
|
|
|
void OrderWaitingCargo(CargoDataList *cargolist, uint32 *transfers)
|
|
|
|
{
|
|
|
|
assert(cargolist->size() == 0);
|
|
|
|
*transfers = 0;
|
|
|
|
|
|
|
|
StationID station_id = this->window_number;
|
|
|
|
const Station *st = Station::Get(station_id);
|
2008-05-11 17:24:52 +00:00
|
|
|
|
|
|
|
/* count types of cargos waiting in station */
|
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
|
|
|
if (st->goods[i].cargo.Empty()) {
|
|
|
|
this->cargo_rows[i] = 0;
|
|
|
|
} else {
|
|
|
|
/* Add an entry for total amount of cargo of this type waiting. */
|
2009-11-08 12:45:16 +00:00
|
|
|
cargolist->push_back(CargoData(i, INVALID_STATION, st->goods[i].cargo.Count()));
|
2008-05-11 17:24:52 +00:00
|
|
|
|
|
|
|
/* Set the row for this cargo entry for the expand/hide button */
|
2009-11-08 12:45:16 +00:00
|
|
|
this->cargo_rows[i] = (uint16)cargolist->size();
|
2008-05-11 17:24:52 +00:00
|
|
|
|
|
|
|
/* Add an entry for each distinct cargo source. */
|
2009-10-18 14:28:26 +00:00
|
|
|
const StationCargoList::List *packets = st->goods[i].cargo.Packets();
|
2009-10-19 09:15:47 +00:00
|
|
|
for (StationCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
|
2008-05-11 17:24:52 +00:00
|
|
|
const CargoPacket *cp = *it;
|
2009-10-18 17:53:34 +00:00
|
|
|
if (cp->SourceStation() != station_id) {
|
2008-05-11 17:24:52 +00:00
|
|
|
bool added = false;
|
|
|
|
|
|
|
|
/* Enable the expand/hide button for this cargo type */
|
2009-11-08 12:45:16 +00:00
|
|
|
SetBit(*transfers, i);
|
2008-05-11 17:24:52 +00:00
|
|
|
|
|
|
|
/* Don't add cargo lines if not expanded */
|
|
|
|
if (!HasBit(this->cargo, i)) break;
|
|
|
|
|
|
|
|
/* Check if we already have this source in the list */
|
2009-11-08 12:45:16 +00:00
|
|
|
for (CargoDataList::iterator jt(cargolist->begin()); jt != cargolist->end(); jt++) {
|
2008-05-11 17:24:52 +00:00
|
|
|
CargoData *cd = &(*jt);
|
2009-10-18 17:53:34 +00:00
|
|
|
if (cd->cargo == i && cd->source == cp->SourceStation()) {
|
2009-10-06 17:23:15 +00:00
|
|
|
cd->count += cp->Count();
|
2008-05-11 17:24:52 +00:00
|
|
|
added = true;
|
|
|
|
break;
|
|
|
|
}
|
2008-01-26 22:15:39 +00:00
|
|
|
}
|
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
if (!added) cargolist->push_back(CargoData(i, cp->SourceStation(), cp->Count()));
|
2008-05-11 17:24:52 +00:00
|
|
|
}
|
2008-01-26 22:15:39 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2009-11-08 12:45:16 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
/** Draw waiting cargo.
|
|
|
|
* @param r Rectangle of the widget.
|
|
|
|
* @param cargolist Cargo, ordered by type and destination.
|
|
|
|
* @param transfers Bitmask for cargoes that are transfered.
|
|
|
|
*/
|
|
|
|
void DrawWaitingCargo(const Rect &r, const CargoDataList &cargolist, uint32 transfers) const
|
|
|
|
{
|
|
|
|
int y = r.top + WD_FRAMERECT_TOP;
|
2009-09-02 08:40:31 +00:00
|
|
|
int pos = this->vscroll.GetPosition();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
const Station *st = Station::Get(this->window_number);
|
2008-05-11 17:24:52 +00:00
|
|
|
if (--pos < 0) {
|
2009-11-08 12:45:16 +00:00
|
|
|
StringID str = STR_JUST_NOTHING;
|
2008-05-11 17:24:52 +00:00
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
|
|
|
if (!st->goods[i].cargo.Empty()) str = STR_EMPTY;
|
|
|
|
}
|
|
|
|
SetDParam(0, str);
|
2009-11-08 12:45:16 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_VIEW_WAITING_TITLE);
|
|
|
|
y += FONT_HEIGHT_NORMAL;
|
2005-11-14 19:48:04 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-18 20:22:39 +00:00
|
|
|
bool rtl = _dynlang.text_dir == TD_RTL;
|
|
|
|
int text_left = rtl ? r.left + this->expand_shrink_width : r.left + WD_FRAMERECT_LEFT;
|
|
|
|
int text_right = rtl ? r.right - WD_FRAMERECT_LEFT : r.right - this->expand_shrink_width;
|
|
|
|
int shrink_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - this->expand_shrink_width + WD_FRAMERECT_LEFT;
|
|
|
|
int shrink_right = rtl ? r.left + this->expand_shrink_width - WD_FRAMERECT_RIGHT : r.right - WD_FRAMERECT_RIGHT;
|
|
|
|
|
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
int maxrows = this->vscroll.GetCapacity();
|
2008-05-11 17:24:52 +00:00
|
|
|
for (CargoDataList::const_iterator it = cargolist.begin(); it != cargolist.end() && pos > -maxrows; ++it) {
|
|
|
|
if (--pos < 0) {
|
|
|
|
const CargoData *cd = &(*it);
|
|
|
|
if (cd->source == INVALID_STATION) {
|
|
|
|
/* Heading */
|
2009-11-18 20:22:39 +00:00
|
|
|
DrawCargoIcons(cd->cargo, cd->count, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y);
|
2008-05-11 17:24:52 +00:00
|
|
|
SetDParam(0, cd->cargo);
|
|
|
|
SetDParam(1, cd->count);
|
|
|
|
if (HasBit(transfers, cd->cargo)) {
|
|
|
|
/* This cargo has transfers waiting so show the expand or shrink 'button' */
|
|
|
|
const char *sym = HasBit(this->cargo, cd->cargo) ? "-" : "+";
|
2009-11-18 20:22:39 +00:00
|
|
|
DrawString(text_left, text_right, y, STR_STATION_VIEW_WAITING_CARGO, TC_FROMSTRING, SA_RIGHT);
|
|
|
|
DrawString(shrink_left, shrink_right, y, sym, TC_YELLOW, SA_RIGHT);
|
2008-05-11 17:24:52 +00:00
|
|
|
} else {
|
2009-11-08 12:45:16 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_VIEW_WAITING_CARGO, TC_FROMSTRING, SA_RIGHT);
|
2008-05-11 17:24:52 +00:00
|
|
|
}
|
2008-03-27 15:51:11 +00:00
|
|
|
} else {
|
2008-05-11 17:24:52 +00:00
|
|
|
SetDParam(0, cd->cargo);
|
|
|
|
SetDParam(1, cd->count);
|
|
|
|
SetDParam(2, cd->source);
|
2009-11-08 12:45:16 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_VIEW_EN_ROUTE_FROM, TC_FROMSTRING, SA_RIGHT);
|
2008-03-27 15:51:11 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
y += FONT_HEIGHT_NORMAL;
|
2008-05-11 17:24:52 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2009-11-08 12:45:16 +00:00
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
/** Draw accepted cargo in the #SVW_ACCEPTLIST widget.
|
|
|
|
* @param r Rectangle of the widget.
|
|
|
|
*/
|
|
|
|
void DrawAcceptedCargo(const Rect &r) const
|
|
|
|
{
|
|
|
|
const Station *st = Station::Get(this->window_number);
|
2009-12-19 16:02:29 +00:00
|
|
|
|
|
|
|
uint32 cargo_mask = 0;
|
2009-11-08 12:45:16 +00:00
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
2009-12-19 16:02:29 +00:00
|
|
|
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) SetBit(cargo_mask, i);
|
2009-11-08 12:45:16 +00:00
|
|
|
}
|
2009-12-19 16:02:29 +00:00
|
|
|
Rect s = {r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, r.right - WD_FRAMERECT_RIGHT, r.bottom - WD_FRAMERECT_BOTTOM};
|
|
|
|
DrawCargoListText(cargo_mask, s, STR_STATION_VIEW_ACCEPTS_CARGO);
|
2009-11-08 12:45:16 +00:00
|
|
|
}
|
2008-01-26 22:15:39 +00:00
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
/** Draw cargo ratings in the #SVW_ACCEPTLIST widget.
|
|
|
|
* @param r Rectangle of the widget.
|
|
|
|
*/
|
|
|
|
void DrawCargoRatings(const Rect &r) const
|
|
|
|
{
|
|
|
|
const Station *st = Station::Get(this->window_number);
|
|
|
|
int y = r.top + WD_FRAMERECT_TOP;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_VIEW_CARGO_RATINGS_TITLE);
|
|
|
|
y += FONT_HEIGHT_NORMAL;
|
2007-03-11 22:29:37 +00:00
|
|
|
|
2009-11-08 12:45:16 +00:00
|
|
|
const CargoSpec *cs;
|
|
|
|
FOR_ALL_CARGOSPECS(cs) {
|
|
|
|
const GoodsEntry *ge = &st->goods[cs->Index()];
|
|
|
|
if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue;
|
|
|
|
|
|
|
|
SetDParam(0, cs->name);
|
|
|
|
SetDParam(2, ToPercent8(ge->rating));
|
|
|
|
SetDParam(1, STR_CARGO_RATING_APPALLING + (ge->rating >> 5));
|
2009-11-18 20:22:39 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT + 6, r.right - WD_FRAMERECT_RIGHT - 6, y, STR_STATION_VIEW_CARGO_RATING);
|
2009-11-08 12:45:16 +00:00
|
|
|
y += FONT_HEIGHT_NORMAL;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
void HandleCargoWaitingClick(int row)
|
|
|
|
{
|
|
|
|
if (row == 0) return;
|
2008-03-27 15:51:11 +00:00
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
|
|
|
if (this->cargo_rows[c] == row) {
|
|
|
|
ToggleBit(this->cargo, c);
|
2009-09-13 19:15:59 +00:00
|
|
|
this->SetWidgetDirty(SVW_WAITING);
|
2008-05-11 17:24:52 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-27 15:51:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case SVW_WAITING:
|
2009-11-08 15:26:20 +00:00
|
|
|
this->HandleCargoWaitingClick((pt.y - this->GetWidget<NWidgetBase>(SVW_WAITING)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL + this->vscroll.GetPosition());
|
2008-05-11 17:24:52 +00:00
|
|
|
break;
|
2007-03-03 09:40:34 +00:00
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
case SVW_LOCATION:
|
|
|
|
if (_ctrl_pressed) {
|
2009-05-16 23:34:14 +00:00
|
|
|
ShowExtraViewPortWindow(Station::Get(this->window_number)->xy);
|
2008-05-11 17:24:52 +00:00
|
|
|
} else {
|
2009-05-16 23:34:14 +00:00
|
|
|
ScrollMainWindowToTile(Station::Get(this->window_number)->xy);
|
2008-05-11 17:24:52 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-11-08 15:26:20 +00:00
|
|
|
case SVW_RATINGS: {
|
|
|
|
/* Swap between 'accepts' and 'ratings' view. */
|
|
|
|
int height_change;
|
|
|
|
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(SVW_RATINGS);
|
|
|
|
if (this->GetWidget<NWidgetCore>(SVW_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) {
|
|
|
|
nwi->SetDataTip(STR_STATION_VIEW_ACCEPTS_BUTTON, STR_STATION_VIEW_ACCEPTS_TOOLTIP); // Switch to accepts view.
|
|
|
|
height_change = ALH_RATING - ALH_ACCEPTS;
|
2008-05-11 17:24:52 +00:00
|
|
|
} else {
|
2009-11-08 15:26:20 +00:00
|
|
|
nwi->SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP); // Switch to ratings view.
|
|
|
|
height_change = ALH_ACCEPTS - ALH_RATING;
|
2007-03-03 09:40:34 +00:00
|
|
|
}
|
2009-11-29 09:01:03 +00:00
|
|
|
this->ReInit(0, height_change * FONT_HEIGHT_NORMAL);
|
2008-05-11 17:24:52 +00:00
|
|
|
break;
|
2009-11-08 15:26:20 +00:00
|
|
|
}
|
2004-12-10 18:16:08 +00:00
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
case SVW_RENAME:
|
|
|
|
SetDParam(0, this->window_number);
|
2009-11-08 15:26:20 +00:00
|
|
|
ShowQueryString(STR_STATION_NAME, STR_STATION_VIEW_RENAME_STATION_CAPTION, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS,
|
|
|
|
this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
|
2008-05-11 17:24:52 +00:00
|
|
|
break;
|
2004-12-10 18:16:08 +00:00
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
case SVW_TRAINS: { // Show a list of scheduled trains to this station
|
2009-05-16 23:34:14 +00:00
|
|
|
const Station *st = Station::Get(this->window_number);
|
2008-05-11 17:24:52 +00:00
|
|
|
ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)this->window_number);
|
|
|
|
break;
|
2007-03-03 09:40:34 +00:00
|
|
|
}
|
2004-12-10 18:16:08 +00:00
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
|
2009-05-16 23:34:14 +00:00
|
|
|
const Station *st = Station::Get(this->window_number);
|
2008-05-11 17:24:52 +00:00
|
|
|
ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)this->window_number);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SVW_PLANES: { // Show a list of scheduled aircraft to this station
|
2009-05-16 23:34:14 +00:00
|
|
|
const Station *st = Station::Get(this->window_number);
|
2009-02-04 16:45:07 +00:00
|
|
|
/* Since oilrigs have no owners, show the scheduled aircraft of local company */
|
|
|
|
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
2008-05-11 17:24:52 +00:00
|
|
|
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
|
|
|
|
break;
|
2007-03-03 09:40:34 +00:00
|
|
|
}
|
2004-12-10 18:16:08 +00:00
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
case SVW_SHIPS: { // Show a list of scheduled ships to this station
|
2009-05-16 23:34:14 +00:00
|
|
|
const Station *st = Station::Get(this->window_number);
|
2009-02-04 16:45:07 +00:00
|
|
|
/* Since oilrigs/bouys have no owners, show the scheduled ships of local company */
|
|
|
|
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
2008-05-11 17:24:52 +00:00
|
|
|
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-10 18:16:08 +00:00
|
|
|
|
2008-05-11 17:24:52 +00:00
|
|
|
virtual void OnQueryTextFinished(char *str)
|
|
|
|
{
|
2008-09-15 19:02:50 +00:00
|
|
|
if (str == NULL) return;
|
|
|
|
|
2009-04-21 23:40:56 +00:00
|
|
|
DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), NULL, str);
|
2008-05-11 17:24:52 +00:00
|
|
|
}
|
2008-01-26 22:15:39 +00:00
|
|
|
|
2009-10-24 14:53:55 +00:00
|
|
|
virtual void OnResize()
|
2008-05-11 17:24:52 +00:00
|
|
|
{
|
2009-12-20 20:08:39 +00:00
|
|
|
this->vscroll.SetCapacityFromWidget(this, SVW_WAITING, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-11 17:24:52 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _station_view_desc(
|
2009-11-28 14:42:35 +00:00
|
|
|
WDP_AUTO, 249, 110,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_STATION_VIEW, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_UNCLICK_BUTTONS,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_station_view_widgets, lengthof(_nested_station_view_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-12-05 17:08:10 +00:00
|
|
|
/**
|
|
|
|
* Opens StationViewWindow for given station
|
|
|
|
*
|
|
|
|
* @param station station which window should be opened
|
|
|
|
*/
|
2005-10-07 07:35:15 +00:00
|
|
|
void ShowStationViewWindow(StationID station)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-11 17:24:52 +00:00
|
|
|
AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2009-07-03 13:33:00 +00:00
|
|
|
/** Struct containing TileIndex and StationID */
|
|
|
|
struct TileAndStation {
|
|
|
|
TileIndex tile; ///< TileIndex
|
|
|
|
StationID station; ///< StationID
|
|
|
|
};
|
|
|
|
|
|
|
|
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
|
2009-01-08 16:35:45 +00:00
|
|
|
static SmallVector<StationID, 8> _stations_nearby_list;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add station on this tile to _stations_nearby_list if it's fully within the
|
|
|
|
* station spread.
|
|
|
|
* @param tile Tile just being checked
|
2009-07-26 09:25:00 +00:00
|
|
|
* @param user_data Pointer to TileArea context
|
2009-07-31 16:28:28 +00:00
|
|
|
* @tparam T the type of station to look for
|
2009-01-08 16:35:45 +00:00
|
|
|
*/
|
2009-07-31 16:28:28 +00:00
|
|
|
template <class T>
|
2009-01-08 16:35:45 +00:00
|
|
|
static bool AddNearbyStation(TileIndex tile, void *user_data)
|
|
|
|
{
|
2009-07-26 09:25:00 +00:00
|
|
|
TileArea *ctx = (TileArea *)user_data;
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2009-07-03 13:33:00 +00:00
|
|
|
/* First check if there were deleted stations here */
|
|
|
|
for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
|
|
|
|
TileAndStation *ts = _deleted_stations_nearby.Get(i);
|
|
|
|
if (ts->tile == tile) {
|
|
|
|
*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
|
|
|
|
_deleted_stations_nearby.Erase(ts);
|
|
|
|
i--;
|
|
|
|
}
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if own station and if we stay within station spread */
|
|
|
|
if (!IsTileType(tile, MP_STATION)) return false;
|
|
|
|
|
|
|
|
StationID sid = GetStationIndex(tile);
|
2009-07-26 09:25:00 +00:00
|
|
|
|
|
|
|
/* This station is (likely) a waypoint */
|
2009-07-31 16:28:28 +00:00
|
|
|
if (!T::IsValidID(sid)) return false;
|
2009-07-26 09:25:00 +00:00
|
|
|
|
2009-07-31 16:28:28 +00:00
|
|
|
T *st = T::Get(sid);
|
2009-01-08 16:35:45 +00:00
|
|
|
if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
|
|
|
|
|
|
|
|
if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST)) {
|
|
|
|
*_stations_nearby_list.Append() = sid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // We want to include *all* nearby stations
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2009-09-19 09:51:14 +00:00
|
|
|
* @param ta Base tile area of the to-be-built station
|
2009-01-08 16:35:45 +00:00
|
|
|
* @param distant_join Search for adjacent stations (false) or stations fully
|
|
|
|
* within station spread
|
2009-07-31 16:28:28 +00:00
|
|
|
* @tparam T the type of station to look for
|
2009-01-08 16:35:45 +00:00
|
|
|
**/
|
2009-07-31 16:28:28 +00:00
|
|
|
template <class T>
|
|
|
|
static const T *FindStationsNearby(TileArea ta, bool distant_join)
|
2009-01-08 16:35:45 +00:00
|
|
|
{
|
2009-07-26 21:07:03 +00:00
|
|
|
TileArea ctx = ta;
|
2009-01-08 16:35:45 +00:00
|
|
|
|
|
|
|
_stations_nearby_list.Clear();
|
|
|
|
_deleted_stations_nearby.Clear();
|
|
|
|
|
|
|
|
/* Check the inside, to return, if we sit on another station */
|
2010-01-04 18:30:10 +00:00
|
|
|
TILE_AREA_LOOP(t, ta) {
|
2009-07-31 16:28:28 +00:00
|
|
|
if (t < MapSize() && IsTileType(t, MP_STATION) && T::IsValidID(GetStationIndex(t))) return T::GetByTile(t);
|
2009-07-26 21:50:30 +00:00
|
|
|
}
|
2009-01-08 16:35:45 +00:00
|
|
|
|
|
|
|
/* Look for deleted stations */
|
2009-07-26 09:25:00 +00:00
|
|
|
const BaseStation *st;
|
|
|
|
FOR_ALL_BASE_STATIONS(st) {
|
2009-07-31 16:28:28 +00:00
|
|
|
if (T::IsExpected(st) && !st->IsInUse() && st->owner == _local_company) {
|
2009-01-08 16:35:45 +00:00
|
|
|
/* Include only within station spread (yes, it is strictly less than) */
|
2009-07-26 21:07:03 +00:00
|
|
|
if (max(DistanceMax(ta.tile, st->xy), DistanceMax(TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1), st->xy)) < _settings_game.station.station_spread) {
|
2009-07-03 13:33:00 +00:00
|
|
|
TileAndStation *ts = _deleted_stations_nearby.Append();
|
|
|
|
ts->tile = st->xy;
|
|
|
|
ts->station = st->index;
|
2009-01-08 16:35:45 +00:00
|
|
|
|
|
|
|
/* Add the station when it's within where we're going to build */
|
|
|
|
if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&
|
|
|
|
IsInsideBS(TileY(st->xy), TileY(ctx.tile), ctx.h)) {
|
2009-07-31 16:28:28 +00:00
|
|
|
AddNearbyStation<T>(st->xy, &ctx);
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only search tiles where we have a chance to stay within the station spread.
|
|
|
|
* The complete check needs to be done in the callback as we don't know the
|
|
|
|
* extent of the found station, yet. */
|
2009-07-26 21:07:03 +00:00
|
|
|
if (distant_join && min(ta.w, ta.h) >= _settings_game.station.station_spread) return NULL;
|
|
|
|
uint max_dist = distant_join ? _settings_game.station.station_spread - min(ta.w, ta.h) : 1;
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2009-07-26 21:07:03 +00:00
|
|
|
TileIndex tile = TILE_ADD(ctx.tile, TileOffsByDir(DIR_N));
|
2009-07-31 16:28:28 +00:00
|
|
|
CircularTileSearch(&tile, max_dist, ta.w, ta.h, AddNearbyStation<T>, &ctx);
|
2009-01-08 16:35:45 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum JoinStationWidgets {
|
|
|
|
JSW_WIDGET_CAPTION,
|
|
|
|
JSW_PANEL,
|
|
|
|
JSW_SCROLLBAR,
|
|
|
|
};
|
|
|
|
|
2009-05-03 10:46:24 +00:00
|
|
|
static const NWidgetPart _nested_select_station_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
2009-08-05 17:59:21 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, JSW_WIDGET_CAPTION), SetDataTip(STR_JOIN_STATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-22 14:46:14 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, JSW_PANEL), SetResize(1, 0), EndContainer(),
|
2009-05-03 10:46:24 +00:00
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidget(WWT_SCROLLBAR, COLOUR_DARK_GREEN, JSW_SCROLLBAR),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
|
2009-05-03 10:46:24 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-07-31 16:28:28 +00:00
|
|
|
/**
|
|
|
|
* Window for selecting stations/waypoints to (distant) join to.
|
|
|
|
* @tparam T The type of station to join with
|
|
|
|
*/
|
|
|
|
template <class T>
|
2009-01-08 16:35:45 +00:00
|
|
|
struct SelectStationWindow : Window {
|
|
|
|
CommandContainer select_station_cmd; ///< Command to build new station
|
2009-07-26 21:07:03 +00:00
|
|
|
TileArea area; ///< Location of new station
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2009-07-26 21:07:03 +00:00
|
|
|
SelectStationWindow(const WindowDesc *desc, CommandContainer cmd, TileArea ta) :
|
2009-09-23 20:14:59 +00:00
|
|
|
Window(),
|
2009-01-08 16:35:45 +00:00
|
|
|
select_station_cmd(cmd),
|
2009-07-26 21:07:03 +00:00
|
|
|
area(ta)
|
2009-01-08 16:35:45 +00:00
|
|
|
{
|
2009-09-23 20:14:59 +00:00
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
this->GetWidget<NWidgetCore>(JSW_WIDGET_CAPTION)->widget_data = T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CAPTION : STR_JOIN_STATION_CAPTION;
|
|
|
|
this->FinishInitNested(desc, 0);
|
2009-09-23 19:41:25 +00:00
|
|
|
this->OnInvalidateData(0);
|
2009-09-23 20:14:59 +00:00
|
|
|
}
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2009-11-22 18:28:14 +00:00
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
2009-09-23 20:14:59 +00:00
|
|
|
{
|
|
|
|
if (widget != JSW_PANEL) return;
|
|
|
|
|
|
|
|
/* Determine the widest string */
|
|
|
|
Dimension d = GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
|
|
|
|
for (uint i = 0; i < _stations_nearby_list.Length(); i++) {
|
|
|
|
const T *st = T::Get(_stations_nearby_list[i]);
|
|
|
|
SetDParam(0, st->index);
|
|
|
|
SetDParam(1, st->facilities);
|
|
|
|
d = maxdim(d, GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION));
|
|
|
|
}
|
|
|
|
|
|
|
|
resize->height = d.height;
|
2009-11-22 14:46:14 +00:00
|
|
|
d.height *= 5;
|
2009-09-23 20:14:59 +00:00
|
|
|
d.width += WD_FRAMERECT_RIGHT + WD_FRAMERECT_LEFT;
|
|
|
|
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
2009-11-22 14:46:14 +00:00
|
|
|
*size = d;
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
this->DrawWidgets();
|
2009-09-23 20:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
if (widget != JSW_PANEL) return;
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2009-09-23 20:14:59 +00:00
|
|
|
uint y = r.top + WD_FRAMERECT_TOP;
|
2009-09-02 08:40:31 +00:00
|
|
|
if (this->vscroll.GetPosition() == 0) {
|
2009-09-23 20:14:59 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
|
|
|
|
y += this->resize.step_height;
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
|
2009-09-23 20:14:59 +00:00
|
|
|
for (uint i = max<uint>(1, this->vscroll.GetPosition()); i <= _stations_nearby_list.Length(); ++i, y += this->resize.step_height) {
|
2009-01-08 16:35:45 +00:00
|
|
|
/* Don't draw anything if it extends past the end of the window. */
|
2009-09-02 08:40:31 +00:00
|
|
|
if (i - this->vscroll.GetPosition() >= this->vscroll.GetCapacity()) break;
|
2009-01-08 16:35:45 +00:00
|
|
|
|
2009-07-31 16:28:28 +00:00
|
|
|
const T *st = T::Get(_stations_nearby_list[i - 1]);
|
2009-01-08 16:35:45 +00:00
|
|
|
SetDParam(0, st->index);
|
|
|
|
SetDParam(1, st->facilities);
|
2009-09-23 20:14:59 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION);
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
if (widget != JSW_PANEL) return;
|
|
|
|
|
2010-01-04 17:54:57 +00:00
|
|
|
uint32 st_index = (pt.y - this->GetWidget<NWidgetBase>(JSW_PANEL)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height + this->vscroll.GetPosition();
|
2009-01-08 16:35:45 +00:00
|
|
|
bool distant_join = (st_index > 0);
|
|
|
|
if (distant_join) st_index--;
|
|
|
|
|
|
|
|
if (distant_join && st_index >= _stations_nearby_list.Length()) return;
|
|
|
|
|
|
|
|
/* Insert station to be joined into stored command */
|
|
|
|
SB(this->select_station_cmd.p2, 16, 16,
|
2009-04-10 22:47:19 +00:00
|
|
|
(distant_join ? _stations_nearby_list[st_index] : NEW_STATION));
|
2009-01-08 16:35:45 +00:00
|
|
|
|
|
|
|
/* Execute stored Command */
|
|
|
|
DoCommandP(&this->select_station_cmd);
|
|
|
|
|
|
|
|
/* Close Window; this might cause double frees! */
|
|
|
|
DeleteWindowById(WC_SELECT_STATION, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnTick()
|
|
|
|
{
|
|
|
|
if (_thd.dirty & 2) {
|
|
|
|
_thd.dirty &= ~2;
|
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-24 14:53:55 +00:00
|
|
|
virtual void OnResize()
|
2009-01-08 16:35:45 +00:00
|
|
|
{
|
2009-12-20 20:08:39 +00:00
|
|
|
this->vscroll.SetCapacityFromWidget(this, JSW_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
{
|
2009-07-31 16:28:28 +00:00
|
|
|
FindStationsNearby<T>(this->area, true);
|
2009-09-23 19:41:25 +00:00
|
|
|
this->vscroll.SetCount(_stations_nearby_list.Length() + 1);
|
2009-01-08 16:35:45 +00:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _select_station_desc(
|
2009-11-28 14:42:35 +00:00
|
|
|
WDP_AUTO, 200, 180,
|
2009-01-08 16:35:45 +00:00
|
|
|
WC_SELECT_STATION, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_select_station_widgets, lengthof(_nested_select_station_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2009-01-08 16:35:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether we need to show the station selection window.
|
|
|
|
* @param cmd Command to build the station.
|
2009-09-19 09:51:14 +00:00
|
|
|
* @param ta Tile area of the to-be-built station
|
2009-07-31 16:28:28 +00:00
|
|
|
* @tparam T the type of station
|
2009-01-08 16:35:45 +00:00
|
|
|
* @return whether we need to show the station selection window.
|
|
|
|
*/
|
2009-07-31 16:28:28 +00:00
|
|
|
template <class T>
|
2009-07-26 21:07:03 +00:00
|
|
|
static bool StationJoinerNeeded(CommandContainer cmd, TileArea ta)
|
2009-01-08 16:35:45 +00:00
|
|
|
{
|
|
|
|
/* Only show selection if distant join is enabled in the settings */
|
|
|
|
if (!_settings_game.station.distant_join_stations) return false;
|
|
|
|
|
2009-01-13 17:28:11 +00:00
|
|
|
/* If a window is already opened and we didn't ctrl-click,
|
|
|
|
* return true (i.e. just flash the old window) */
|
|
|
|
Window *selection_window = FindWindowById(WC_SELECT_STATION, 0);
|
|
|
|
if (selection_window != NULL) {
|
|
|
|
if (!_ctrl_pressed) return true;
|
|
|
|
|
|
|
|
/* Abort current distant-join and start new one */
|
|
|
|
delete selection_window;
|
|
|
|
UpdateTileSelection();
|
|
|
|
}
|
2009-01-08 16:35:45 +00:00
|
|
|
|
|
|
|
/* only show the popup, if we press ctrl */
|
|
|
|
if (!_ctrl_pressed) return false;
|
|
|
|
|
2009-01-13 17:28:11 +00:00
|
|
|
/* Now check if we could build there */
|
|
|
|
if (CmdFailed(DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))))) return false;
|
|
|
|
|
2009-01-13 18:41:56 +00:00
|
|
|
/* Test for adjacent station or station below selection.
|
|
|
|
* If adjacent-stations is disabled and we are building next to a station, do not show the selection window.
|
|
|
|
* but join the other station immediatelly. */
|
2009-07-31 16:28:28 +00:00
|
|
|
const T *st = FindStationsNearby<T>(ta, false);
|
2009-01-13 18:41:56 +00:00
|
|
|
return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.Length() == 0);
|
2009-01-08 16:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the station selection window when needed. If not, build the station.
|
|
|
|
* @param cmd Command to build the station.
|
2009-07-31 16:28:28 +00:00
|
|
|
* @param ta Area to build the station in
|
|
|
|
* @tparam the class to find stations for
|
2009-01-08 16:35:45 +00:00
|
|
|
*/
|
2009-07-31 16:28:28 +00:00
|
|
|
template <class T>
|
|
|
|
void ShowSelectBaseStationIfNeeded(CommandContainer cmd, TileArea ta)
|
2009-01-08 16:35:45 +00:00
|
|
|
{
|
2009-07-31 16:28:28 +00:00
|
|
|
if (StationJoinerNeeded<T>(cmd, ta)) {
|
2009-02-08 15:45:34 +00:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2009-01-08 16:35:45 +00:00
|
|
|
if (BringWindowToFrontById(WC_SELECT_STATION, 0)) return;
|
2009-07-31 16:28:28 +00:00
|
|
|
new SelectStationWindow<T>(&_select_station_desc, cmd, ta);
|
2009-01-08 16:35:45 +00:00
|
|
|
} else {
|
|
|
|
DoCommandP(&cmd);
|
|
|
|
}
|
|
|
|
}
|
2009-07-31 16:28:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the station selection window when needed. If not, build the station.
|
|
|
|
* @param cmd Command to build the station.
|
|
|
|
* @param ta Area to build the station in
|
|
|
|
*/
|
|
|
|
void ShowSelectStationIfNeeded(CommandContainer cmd, TileArea ta)
|
|
|
|
{
|
|
|
|
ShowSelectBaseStationIfNeeded<Station>(cmd, ta);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the waypoint selection window when needed. If not, build the waypoint.
|
|
|
|
* @param cmd Command to build the waypoint.
|
|
|
|
* @param ta Area to build the waypoint in
|
|
|
|
*/
|
|
|
|
void ShowSelectWaypointIfNeeded(CommandContainer cmd, TileArea ta)
|
|
|
|
{
|
|
|
|
ShowSelectBaseStationIfNeeded<Waypoint>(cmd, ta);
|
|
|
|
}
|