src/station_gui.cpp
changeset 5859 158718283d16
parent 5838 9c3129cb019b
child 5860 7fdc9b423ba1
equal deleted inserted replaced
5858:dfe44c585495 5859:158718283d16
   264 static void PlayerStationsWndProc(Window *w, WindowEvent *e)
   264 static void PlayerStationsWndProc(Window *w, WindowEvent *e)
   265 {
   265 {
   266 	const PlayerID owner = (PlayerID)w->window_number;
   266 	const PlayerID owner = (PlayerID)w->window_number;
   267 	static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
   267 	static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
   268 	static uint16 cargo_filter = CARGO_ALL_SELECTED;
   268 	static uint16 cargo_filter = CARGO_ALL_SELECTED;
       
   269 	static Listing station_sort = {0, 0};
       
   270 
   269 	plstations_d *sl = &WP(w, plstations_d);
   271 	plstations_d *sl = &WP(w, plstations_d);
   270 
   272 
   271 	switch (e->event) {
   273 	switch (e->event) {
   272 	case WE_CREATE: { /* set up resort timer */
   274 	case WE_CREATE: { /* set up resort timer */
   273 		int i;
   275 		int i;
   281 		SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, cargo_filter == CARGO_ALL_SELECTED);
   283 		SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, cargo_filter == CARGO_ALL_SELECTED);
   282 		SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_NOCARGOWAITING, HASBIT(cargo_filter, STATIONLIST_WIDGET_NOCARGOWAITING - NUM_CARGO));
   284 		SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_NOCARGOWAITING, HASBIT(cargo_filter, STATIONLIST_WIDGET_NOCARGOWAITING - NUM_CARGO));
   283 
   285 
   284 		sl->sort_list = NULL;
   286 		sl->sort_list = NULL;
   285 		sl->flags = SL_REBUILD;
   287 		sl->flags = SL_REBUILD;
   286 		sl->sort_type = 0;
   288 		sl->sort_type = station_sort.criteria;
       
   289 		if (station_sort.order) sl->flags |= SL_ORDER;
   287 		sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
   290 		sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
   288 		break;
   291 		break;
   289 	}
   292 	}
   290 
   293 
   291 	case WE_PAINT: {
   294 	case WE_PAINT: {
   434 			SetWindowDirty(w);
   437 			SetWindowDirty(w);
   435 			break;
   438 			break;
   436 		}
   439 		}
   437 		case STATIONLIST_WIDGET_SORTBY: /*flip sorting method asc/desc*/
   440 		case STATIONLIST_WIDGET_SORTBY: /*flip sorting method asc/desc*/
   438 			sl->flags ^= SL_ORDER; //DESC-flag
   441 			sl->flags ^= SL_ORDER; //DESC-flag
       
   442 			station_sort.order = GB(sl->flags, 0, 1);
   439 			sl->flags |= SL_RESORT;
   443 			sl->flags |= SL_RESORT;
   440 			w->flags4 |= 5 << WF_TIMEOUT_SHL;
   444 			w->flags4 |= 5 << WF_TIMEOUT_SHL;
   441 			LowerWindowWidget(w, STATIONLIST_WIDGET_SORTBY);
   445 			LowerWindowWidget(w, STATIONLIST_WIDGET_SORTBY);
   442 			SetWindowDirty(w);
   446 			SetWindowDirty(w);
   443 		break;
   447 		break;
   469 
   473 
   470 	case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
   474 	case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
   471 		if (sl->sort_type != e->we.dropdown.index) {
   475 		if (sl->sort_type != e->we.dropdown.index) {
   472 			// value has changed -> resort
   476 			// value has changed -> resort
   473 			sl->sort_type = e->we.dropdown.index;
   477 			sl->sort_type = e->we.dropdown.index;
       
   478 			station_sort.criteria = sl->sort_type;
   474 			sl->flags |= SL_RESORT;
   479 			sl->flags |= SL_RESORT;
   475 		}
   480 		}
   476 		SetWindowDirty(w);
   481 		SetWindowDirty(w);
   477 		break;
   482 		break;
   478 
   483