@@ -290,15 +290,16 @@ public:
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);
@@ -357,20 +358,17 @@ public:
*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);
d.width += padding.width + 2;
d.height += padding.height;
virtual void OnPaint()
{
@@ -403,23 +401,24 @@ public:
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;
@@ -450,19 +449,17 @@ public:
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
@@ -519,15 +516,14 @@ public:
this->facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
this->stations.ForceRebuild();
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;
@@ -548,15 +544,14 @@ public:
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;
@@ -565,22 +560,20 @@ public:
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;
@@ -674,30 +667,21 @@ const StringID CompanyStationsWindow::so
* @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),
Status change: