src/build_vehicle_gui.cpp
changeset 7251 6c9c673182e9
parent 7246 9ac33793ac75
child 7258 8ea218277d00
equal deleted inserted replaced
7250:896c3efea8aa 7251:6c9c673182e9
   670 	EngineID eid, sel_id;
   670 	EngineID eid, sel_id;
   671 	int num_engines = 0;
   671 	int num_engines = 0;
   672 	int num_wagons  = 0;
   672 	int num_wagons  = 0;
   673 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
   673 	buildvehicle_d *bv = &WP(w, buildvehicle_d);
   674 
   674 
   675 	bv->filter.railtype = (w->window_number == 0) ? RAILTYPE_END : GetRailType(w->window_number);
   675 	bv->filter.railtype = (w->window_number <= VEH_END) ? RAILTYPE_END : GetRailType(w->window_number);
   676 
   676 
   677 	EngList_RemoveAll(&bv->eng_list);
   677 	EngList_RemoveAll(&bv->eng_list);
   678 
   678 
   679 	/* Make list of all available train engines and wagons.
   679 	/* Make list of all available train engines and wagons.
   680 	 * Also check to see if the previously selected engine is still available,
   680 	 * Also check to see if the previously selected engine is still available,
   762 	 * and if not, reset selection to INVALID_ENGINE. This could be the case
   762 	 * and if not, reset selection to INVALID_ENGINE. This could be the case
   763 	 * when planes become obsolete and are removed */
   763 	 * when planes become obsolete and are removed */
   764 	sel_id = INVALID_ENGINE;
   764 	sel_id = INVALID_ENGINE;
   765 	for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
   765 	for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
   766 		if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
   766 		if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
   767 		if (w->window_number != 0 && !IsAircraftBuildableAtStation(eid, w->window_number)) continue;
   767 		/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
       
   768 		if (w->window_number > VEH_END && !IsAircraftBuildableAtStation(eid, w->window_number)) continue;
   768 
   769 
   769 		EngList_Add(&bv->eng_list, eid);
   770 		EngList_Add(&bv->eng_list, eid);
   770 		if (eid == bv->sel_engine) sel_id = eid;
   771 		if (eid == bv->sel_engine) sel_id = eid;
   771 	}
   772 	}
   772 
   773 
   885 static void DrawBuildVehicleWindow(Window *w)
   886 static void DrawBuildVehicleWindow(Window *w)
   886 {
   887 {
   887 	const buildvehicle_d *bv = &WP(w, buildvehicle_d);
   888 	const buildvehicle_d *bv = &WP(w, buildvehicle_d);
   888 	uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
   889 	uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
   889 
   890 
   890 	SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number == 0);
   891 	SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
   891 
   892 
   892 	SetVScrollCount(w, EngList_Count(&bv->eng_list));
   893 	SetVScrollCount(w, EngList_Count(&bv->eng_list));
   893 	SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles
   894 	SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles
   894 	DrawWindowWidgets(w);
   895 	DrawWindowWidgets(w);
   895 
   896