File diff r15609:02b794721f9c → r15610:623a23fb6560
src/autoreplace_gui.cpp
Show inline comments
 
@@ -60,13 +60,14 @@ static int CDECL EngineNumberSorter(cons
 
{
 
	int r = ListPositionOfEngine(*a) - ListPositionOfEngine(*b);
 

	
 
	return r;
 
}
 

	
 
/** Rebuild the left autoreplace list if an engine is removed or added
 
/**
 
 * Rebuild the left autoreplace list if an engine is removed or added
 
 * @param e Engine to check if it is removed or added
 
 * @param id_g The group the engine belongs to
 
 *  Note: this function only works if it is called either
 
 *   - when a new vehicle is build, but before it's counted in num_engines
 
 *   - when a vehicle is deleted and after it's substracted from num_engines
 
 *   - when not changing the count (used when changing replace orders)
 
@@ -81,13 +82,14 @@ void InvalidateAutoreplaceWindow(EngineI
 
		 * Either we just sold the last one, we build a new one or we stopped replacing it.
 
		 * In all cases, we need to update the left list */
 
		InvalidateWindowData(WC_REPLACE_VEHICLE, Engine::Get(e)->type, true);
 
	}
 
}
 

	
 
/** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
 
/**
 
 * When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
 
 * @param type The type of engine
 
 */
 
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
 
{
 
	InvalidateWindowData(WC_REPLACE_VEHICLE, type, false); // Update the autoreplace window
 
	InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
 
@@ -102,13 +104,14 @@ class ReplaceVehicleWindow : public Wind
 
	bool replace_engines;         ///< If \c true, engines are replaced, if \c false, wagons are replaced (only for trains).
 
	bool reset_sel_engine;        ///< Also reset #sel_engine while updating left and/or right (#update_left and/or #update_right) and no valid engine selected.
 
	GroupID sel_group;            ///< Group selected to replace.
 
	int details_height;           ///< Minimal needed height of the details panels (found so far).
 
	RailType sel_railtype;        ///< Type of rail tracks selected.
 

	
 
	/** Figure out if an engine should be added to a list.
 
	/**
 
	 * Figure out if an engine should be added to a list.
 
	 * @param e            The EngineID.
 
	 * @param draw_left    If \c true, the left list is drawn (the engines specific to the railtype you selected).
 
	 * @param show_engines If \c true, the locomotives are drawn, else the wagons are drawn (never both).
 
	 * @return \c true if the engine should be in the list (based on this check), else \c false.
 
	 */
 
	bool GenerateReplaceRailList(EngineID e, bool draw_left, bool show_engines)
 
@@ -123,13 +126,14 @@ class ReplaceVehicleWindow : public Wind
 
			if (rvi->railtype != this->sel_railtype) return false;
 
		}
 
		return true;
 
	}
 

	
 

	
 
	/** Generate an engines list
 
	/**
 
	 * Generate an engines list
 
	 * @param draw_left true if generating the left list, otherwise false
 
	 */
 
	void GenerateReplaceVehList(bool draw_left)
 
	{
 
		EngineID selected_engine = INVALID_ENGINE;
 
		VehicleType type = (VehicleType)this->window_number;