src/station_gui.cpp
changeset 9297 1cb8d7bbdc8a
parent 9273 35e0224ea8f1
child 9317 f14eb8815829
equal deleted inserted replaced
9296:b7375d368dc9 9297:1cb8d7bbdc8a
   166 }
   166 }
   167 
   167 
   168 typedef GUIList<const Station*> GUIStationList;
   168 typedef GUIList<const Station*> GUIStationList;
   169 
   169 
   170 /**
   170 /**
   171  * Set the station sort flag for all station-list windows.
       
   172  * @param sl_flag Sort list flag to set for all station-list windows
       
   173  */
       
   174 static void SetStationListsFlag(SortListFlags sl_flag)
       
   175 {
       
   176 	Window *const *wz;
       
   177 
       
   178 	FOR_ALL_WINDOWS(wz) {
       
   179 		Window *w = *wz;
       
   180 		if (w->window_class == WC_STATION_LIST) {
       
   181 			dynamic_cast<GUIStationList*>(w)->flags |= sl_flag;
       
   182 			w->SetDirty();
       
   183 		}
       
   184 	}
       
   185 }
       
   186 
       
   187 /**
       
   188  * Set the 'VL_REBUILD' flag for all station lists
       
   189  */
       
   190 void RebuildStationLists()
       
   191 {
       
   192 	SetStationListsFlag(VL_REBUILD);
       
   193 }
       
   194 
       
   195 /**
       
   196  * Set the 'VL_RESORT' flag for all station lists
       
   197  */
       
   198 void ResortStationLists()
       
   199 {
       
   200 	SetStationListsFlag(VL_RESORT);
       
   201 }
       
   202 
       
   203 /**
       
   204  * Rebuild station list if the VL_REBUILD flag is set
   171  * Rebuild station list if the VL_REBUILD flag is set
   205  *
   172  *
   206  * @param sl pointer to plstations_d (station list and flags)
   173  * @param sl pointer to plstations_d (station list and flags)
   207  * @param owner player whose stations are to be in list
   174  * @param owner player whose stations are to be in list
   208  * @param facilities types of stations of interest
   175  * @param facilities types of stations of interest
   602 	}
   569 	}
   603 
   570 
   604 	virtual void OnResize(Point new_size, Point delta)
   571 	virtual void OnResize(Point new_size, Point delta)
   605 	{
   572 	{
   606 		this->vscroll.cap += delta.y / 10;
   573 		this->vscroll.cap += delta.y / 10;
       
   574 	}
       
   575 
       
   576 	virtual void OnInvalidateData(int data)
       
   577 	{
       
   578 		this->flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
   607 	}
   579 	}
   608 };
   580 };
   609 
   581 
   610 Listing PlayerStationsWindow::station_sort = {0, 0};
   582 Listing PlayerStationsWindow::station_sort = {0, 0};
   611 byte PlayerStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
   583 byte PlayerStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;