src/autoreplace_gui.cpp
changeset 6638 09c5d7bf69a5
parent 6398 35d30aee9e8c
child 6643 f81bee57bc09
equal deleted inserted replaced
6637:5a8e524c14f4 6638:09c5d7bf69a5
    60 }
    60 }
    61 
    61 
    62 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
    62 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
    63  * @param type The type of engine
    63  * @param type The type of engine
    64  */
    64  */
    65 void AddRemoveEngineFromAutoreplaceAndBuildWindows(byte type)
    65 void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
    66 {
    66 {
    67 	_rebuild_left_list = false; // left list is only for the vehicles the player owns and is not related to being buildable
    67 	_rebuild_left_list = false; // left list is only for the vehicles the player owns and is not related to being buildable
    68 	_rebuild_right_list = true;
    68 	_rebuild_right_list = true;
    69 	InvalidateWindowData(WC_REPLACE_VEHICLE, type); // Update the autoreplace window
    69 	InvalidateWindowData(WC_REPLACE_VEHICLE, type); // Update the autoreplace window
    70 	InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
    70 	InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
   200 	WP(w, replaceveh_d).update_right = false;
   200 	WP(w, replaceveh_d).update_right = false;
   201 	WP(w, replaceveh_d).init_lists   = false;
   201 	WP(w, replaceveh_d).init_lists   = false;
   202 }
   202 }
   203 
   203 
   204 
   204 
   205 void DrawEngineList(byte type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count);
   205 void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count);
   206 
   206 
   207 static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
   207 static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
   208 {
   208 {
   209 	/* Strings for the pulldown menu */
   209 	/* Strings for the pulldown menu */
   210 	static const StringID _vehicle_type_names[] = {
   210 	static const StringID _vehicle_type_names[] = {
   294 				EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw
   294 				EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw
   295 				EngineID start  = i == 0 ? w->vscroll.pos : w->vscroll2.pos; // what is the offset for the start (scrolling)
   295 				EngineID start  = i == 0 ? w->vscroll.pos : w->vscroll2.pos; // what is the offset for the start (scrolling)
   296 				EngineID end    = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list));
   296 				EngineID end    = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list));
   297 
   297 
   298 				/* Do the actual drawing */
   298 				/* Do the actual drawing */
   299 				DrawEngineList(w->window_number, x, 15, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0);
   299 				DrawEngineList((VehicleType)w->window_number, x, 15, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0);
   300 
   300 
   301 				/* Also draw the details if an engine is selected */
   301 				/* Also draw the details if an engine is selected */
   302 				if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
   302 				if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
   303 					const Widget *wi = &w->widget[i == 0 ? 3 : 11];
   303 					const Widget *wi = &w->widget[i == 0 ? 3 : 11];
   304 					DrawVehiclePurchaseInfo(wi->left + 2, wi->top + 1, wi->right - wi->left - 2, WP(w, replaceveh_d).sel_engine[i]);
   304 					DrawVehiclePurchaseInfo(wi->left + 2, wi->top + 1, wi->right - wi->left - 2, WP(w, replaceveh_d).sel_engine[i]);
   478 	_replace_ship_aircraft_vehicle_widgets,
   478 	_replace_ship_aircraft_vehicle_widgets,
   479 	ReplaceVehicleWndProc
   479 	ReplaceVehicleWndProc
   480 };
   480 };
   481 
   481 
   482 
   482 
   483 void ShowReplaceVehicleWindow(byte vehicletype)
   483 void ShowReplaceVehicleWindow(VehicleType vehicletype)
   484 {
   484 {
   485 	Window *w;
   485 	Window *w;
   486 
   486 
   487 	DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
   487 	DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
   488 
   488