src/autoreplace_gui.cpp
branchnoai
changeset 9722 ebf0ece7d8f6
parent 9701 d1ac22c62f64
child 9723 eee46cb39750
equal deleted inserted replaced
9721:9a27928bcd5e 9722:ebf0ece7d8f6
   162 			/* This is for engines we can replace to and they should depend on what we selected to replace from */
   162 			/* This is for engines we can replace to and they should depend on what we selected to replace from */
   163 			if (!IsEngineBuildable(e, type, _local_player)) continue; // we need to be able to build the engine
   163 			if (!IsEngineBuildable(e, type, _local_player)) continue; // we need to be able to build the engine
   164 			if (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo
   164 			if (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo
   165 
   165 
   166 			/* Road vehicles can't be replaced by trams and vice-versa */
   166 			/* Road vehicles can't be replaced by trams and vice-versa */
   167 			if (type == VEH_ROAD && HASBIT(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HASBIT(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue;
   167 			if (type == VEH_ROAD && HasBit(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HasBit(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue;
   168 			if (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew)
   168 			if (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew)
   169 		}
   169 		}
   170 
   170 
   171 		EngList_Add(list, e);
   171 		EngList_Add(list, e);
   172 		if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
   172 		if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
   280 			DrawWindowWidgets(w);
   280 			DrawWindowWidgets(w);
   281 
   281 
   282 			if (w->window_number == VEH_TRAIN) {
   282 			if (w->window_number == VEH_TRAIN) {
   283 				/* Draw the selected railtype in the pulldown menu */
   283 				/* Draw the selected railtype in the pulldown menu */
   284 				RailType railtype = _railtype_selected_in_replace_gui;
   284 				RailType railtype = _railtype_selected_in_replace_gui;
   285 				DrawString(157, w->widget[14].top + 1, _rail_types_list[railtype], 0x10);
   285 				DrawString(157, w->widget[14].top + 1, _rail_types_list[railtype], TC_BLACK);
   286 			}
   286 			}
   287 
   287 
   288 			/* sets up the string for the vehicle that is being replaced to */
   288 			/* sets up the string for the vehicle that is being replaced to */
   289 			if (selected_id[0] != INVALID_ENGINE) {
   289 			if (selected_id[0] != INVALID_ENGINE) {
   290 				if (!EngineHasReplacementForPlayer(p, selected_id[0], selected_group)) {
   290 				if (!EngineHasReplacementForPlayer(p, selected_id[0], selected_group)) {
   295 				}
   295 				}
   296 			} else {
   296 			} else {
   297 				SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
   297 				SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
   298 			}
   298 			}
   299 
   299 
   300 			DrawString(145, w->widget[5].top + 1, STR_02BD, 0x10);
   300 			DrawString(145, w->widget[5].top + 1, STR_02BD, TC_BLACK);
   301 
   301 
   302 			/* Draw the lists */
   302 			/* Draw the lists */
   303 			for(byte i = 0; i < 2; i++) {
   303 			for(byte i = 0; i < 2; i++) {
   304 				uint16 x        = i == 0 ? 2 : 230; // at what X offset
   304 				uint16 x        = i == 0 ? 2 : 230; // at what X offset
   305 				EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw
   305 				EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw