@@ -284,27 +284,28 @@ public:
{
this->stations.SetListing(this->last_sorting);
this->stations.SetSortFuncs(this->sorter_funcs);
this->stations.ForceRebuild();
this->stations.NeedResort();
this->SortStationsList();
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(WID_STL_SCROLLBAR);
this->FinishInitNested(desc, window_number);
this->owner = (Owner)this->window_number;
CargoID cid;
FOR_EACH_SET_CARGO_ID(cid, this->cargo_filter) {
if (CargoSpec::Get(cid)->IsValid()) this->LowerWidget(WID_STL_CARGOSTART + cid);
const CargoSpec *cs;
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
if (!HasBit(this->cargo_filter, cs->Index())) continue;
this->LowerWidget(WID_STL_CARGOSTART + index);
}
if (this->cargo_filter == this->cargo_filter_max) this->cargo_filter = _cargo_mask;
for (uint i = 0; i < 5; i++) {
if (HasBit(this->facilities, i)) this->LowerWidget(i + WID_STL_TRAIN);
this->SetWidgetLoweredState(WID_STL_NOCARGOWAITING, this->include_empty);
this->GetWidget<NWidgetCore>(WID_STL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
@@ -351,32 +352,29 @@ public:
case WID_STL_CARGOALL:
case WID_STL_FACILALL:
case WID_STL_NOCARGOWAITING: {
Dimension d = GetStringBoundingBox(widget == WID_STL_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL);
d.width += padding.width + 2;
d.height += padding.height;
*size = maxdim(*size, d);
break;
default:
if (widget >= WID_STL_CARGOSTART) {
const CargoSpec *cs = CargoSpec::Get(widget - WID_STL_CARGOSTART);
if (cs->IsValid()) {
Dimension d = GetStringBoundingBox(cs->abbrev);
Dimension d = GetStringBoundingBox(_sorted_cargo_specs[widget - WID_STL_CARGOSTART]->abbrev);
virtual void OnPaint()
this->BuildStationsList((Owner)this->window_number);
this->DrawWidgets();
@@ -397,35 +395,36 @@ public:
assert(st->xy != INVALID_TILE);
/* 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);
SetDParam(0, st->index);
SetDParam(1, st->facilities);
int x = DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_LIST_STATION);
x += rtl ? -5 : 5;
/* show cargo waiting and station ratings */
for (CargoID j = 0; j < NUM_CARGO; j++) {
if (!st->goods[j].cargo.Empty()) {
for (uint j = 0; j < _sorted_standard_cargo_specs_size; j++) {
CargoID cid = _sorted_cargo_specs[j]->Index();
if (!st->goods[cid].cargo.Empty()) {
/* 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);
StationsWndShowStationRating(x, x + 16, y, cid, st->goods[cid].cargo.Count(), st->goods[cid].rating);
if (!rtl) {
x += 20;
if (x > r.right - WD_FRAMERECT_RIGHT) break;
y += FONT_HEIGHT_NORMAL;
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;
@@ -444,31 +443,29 @@ public:
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_HOR_CENTER);
case WID_STL_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);
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART];
int cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? 2 : 1;
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_HOR_CENTER);
virtual void SetStringParameters(int widget) const
if (widget == WID_STL_CAPTION) {
SetDParam(0, this->window_number);
SetDParam(1, this->vscroll->GetCount());
@@ -513,27 +510,26 @@ public:
for (uint i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) {
this->LowerWidget(i);
this->facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
this->SetDirty();
case WID_STL_CARGOALL: {
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
if (cs->IsValid()) this->LowerWidget(WID_STL_CARGOSTART + i);
for (uint i = 0; i < _sorted_standard_cargo_specs_size; i++) {
this->LowerWidget(WID_STL_CARGOSTART + i);
this->LowerWidget(WID_STL_NOCARGOWAITING);
this->cargo_filter = _cargo_mask;
this->include_empty = true;
case WID_STL_SORTBY: // flip sorting method asc/desc
this->stations.ToggleSortOrder();
@@ -542,51 +538,48 @@ public:
case WID_STL_SORTDROPBTN: // select sorting criteria dropdown menu
ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), WID_STL_SORTDROPBTN, 0, 0);
case WID_STL_NOCARGOWAITING:
if (_ctrl_pressed) {
this->include_empty = !this->include_empty;
this->ToggleWidgetLoweredState(WID_STL_NOCARGOWAITING);
} else {
if (cs->IsValid()) this->RaiseWidget(WID_STL_CARGOSTART + i);
this->RaiseWidget(WID_STL_CARGOSTART + i);
this->cargo_filter = 0;
if (widget >= WID_STL_CARGOSTART) { // change cargo_filter
/* Determine the selected cargo type */
if (!cs->IsValid()) break;
ToggleBit(this->cargo_filter, cs->Index());
this->ToggleWidgetLoweredState(widget);
this->RaiseWidget(WID_STL_NOCARGOWAITING);
this->include_empty = false;
SetBit(this->cargo_filter, cs->Index());
this->LowerWidget(widget);
@@ -668,42 +661,33 @@ const StringID CompanyStationsWindow::so
INVALID_STRING_ID
};
/**
* Make a horizontal row of cargo buttons, starting at widget #WID_STL_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();
NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i);
panel->SetMinimalSize(14, 11);
panel->SetResize(0, 0);
panel->SetFill(0, 1);
panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE);
container->Add(panel);
NWidgetLeaf *nwi = new NWidgetLeaf(WWT_EMPTY, COLOUR_GREY, WID_STL_CARGOSTART + i, 0x0, STR_NULL);
nwi->SetMinimalSize(0, 11);
nwi->SetResize(0, 0);
nwi->SetFill(0, 1);
container->Add(nwi);
*biggest_index = WID_STL_CARGOSTART + NUM_CARGO;
*biggest_index = WID_STL_CARGOSTART + _sorted_standard_cargo_specs_size;
return container;
static const NWidgetPart _nested_company_stations_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_STL_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
EndContainer(),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_TRAIN), SetMinimalSize(14, 11), SetDataTip(STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
Status change: