src/vehicle_gui.cpp
changeset 5996 d4b66530ded4
parent 5919 2b58160d667d
child 5998 9491f99be62d
equal deleted inserted replaced
5995:12c9d37a1e38 5996:d4b66530ded4
  1872 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  1872 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  1873 	_vehicle_list_widgets,
  1873 	_vehicle_list_widgets,
  1874 	PlayerVehWndProc
  1874 	PlayerVehWndProc
  1875 };
  1875 };
  1876 
  1876 
  1877 static void ShowVehicleListWindowLocal(PlayerID player, byte vehicle_type, StationID station, OrderID order, uint16 depot_airport_index)
  1877 static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, byte vehicle_type, uint16 unique_number)
  1878 {
  1878 {
  1879 	Window *w;
  1879 	Window *w;
  1880 	WindowNumber num;
  1880 	WindowNumber num;
  1881 
  1881 
  1882 	if (!IsValidPlayer(player)) return;
  1882 	if (!IsValidPlayer(player)) return;
  1883 
  1883 
  1884 	num = (vehicle_type << 11) | player;
  1884 	num = (unique_number << 16) | (vehicle_type << 11) | VLW_flag | player;
  1885 	if (order != INVALID_ORDER) {
       
  1886 		num |= (order << 16) | VLW_SHARED_ORDERS;
       
  1887 	} else if (depot_airport_index != INVALID_STATION) {
       
  1888 		num |= (depot_airport_index << 16) | VLW_DEPOT_LIST;
       
  1889 	} else if (station == INVALID_STATION) {
       
  1890 		num |= VLW_STANDARD;
       
  1891 	} else {
       
  1892 		num |= (station << 16) | VLW_STATION_LIST;
       
  1893 	}
       
  1894 
  1885 
  1895 	/* The vehicle list windows have been unified. Just some strings need
  1886 	/* The vehicle list windows have been unified. Just some strings need
  1896 	 * to be changed which happens in the WE_CREATE event and resizing
  1887 	 * to be changed which happens in the WE_CREATE event and resizing
  1897 	 * some of the windows to the correct size */
  1888 	 * some of the windows to the correct size */
  1898 	switch (vehicle_type) {
  1889 	switch (vehicle_type) {
  1899 		default: NOT_REACHED();
       
  1900 		case VEH_Train:
  1890 		case VEH_Train:
  1901 			w = AllocateWindowDescFront(&_player_vehicle_list_train_desc, num);
  1891 			w = AllocateWindowDescFront(&_player_vehicle_list_train_desc, num);
  1902 			if (w != NULL) ResizeWindow(w, 65, 38);
  1892 			if (w != NULL) ResizeWindow(w, 65, 38);
  1903 			break;
  1893 			break;
  1904 		case VEH_Road:
  1894 		case VEH_Road:
  1909 			w = AllocateWindowDescFront(&_player_vehicle_list_ship_desc, num);
  1899 			w = AllocateWindowDescFront(&_player_vehicle_list_ship_desc, num);
  1910 			break;
  1900 			break;
  1911 		case VEH_Aircraft:
  1901 		case VEH_Aircraft:
  1912 			w = AllocateWindowDescFront(&_player_vehicle_list_aircraft_desc, num);
  1902 			w = AllocateWindowDescFront(&_player_vehicle_list_aircraft_desc, num);
  1913 			break;
  1903 			break;
       
  1904 		default: NOT_REACHED(); return;
  1914 	}
  1905 	}
  1915 
  1906 
  1916 	if (w != NULL) {
  1907 	if (w != NULL) {
  1917 		/* Set the minimum window size to the current window size */
  1908 		/* Set the minimum window size to the current window size */
  1918 		w->resize.width = w->width;
  1909 		w->resize.width = w->width;
  1919 		w->resize.height = w->height;
  1910 		w->resize.height = w->height;
  1920 	}
  1911 	}
  1921 }
  1912 }
  1922 
  1913 
  1923 void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type)
  1914 void ShowVehicleListWindow(PlayerID player, byte vehicle_type)
  1924 {
  1915 {
  1925 	ShowVehicleListWindowLocal(player, vehicle_type, station, INVALID_ORDER, INVALID_STATION);
  1916 	ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
  1926 }
  1917 }
  1927 
  1918 
  1928 void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type)
  1919 void ShowVehicleListWindow(const Vehicle *v)
  1929 {
  1920 {
  1930 	if (v->orders == NULL) return; // no shared list to show
  1921 	if (v->orders == NULL) return; // no shared list to show
  1931 	ShowVehicleListWindowLocal(v->owner, vehicle_type, INVALID_STATION, v->orders->index, INVALID_STATION);
  1922 	ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->orders->index);
  1932 }
  1923 }
  1933 
  1924 
  1934 void ShowVehDepotOrders(PlayerID player, byte vehicle_type, TileIndex depot_tile)
  1925 void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station)
       
  1926 {
       
  1927 	ShowVehicleListWindowLocal(player, VLW_STATION_LIST, vehicle_type, station);
       
  1928 }
       
  1929 
       
  1930 void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile)
  1935 {
  1931 {
  1936 	uint16 depot_airport_index;
  1932 	uint16 depot_airport_index;
  1937 
  1933 
  1938 	if (vehicle_type == VEH_Aircraft) {
  1934 	if (vehicle_type == VEH_Aircraft) {
  1939 		depot_airport_index = GetStationIndex(depot_tile);
  1935 		depot_airport_index = GetStationIndex(depot_tile);
  1940 	} else {
  1936 	} else {
  1941 		Depot *depot = GetDepotByTile(depot_tile);
  1937 		Depot *depot = GetDepotByTile(depot_tile);
  1942 		if (depot == NULL) return; // no depot to show
  1938 		if (depot == NULL) return; // no depot to show
  1943 		depot_airport_index = depot->index;
  1939 		depot_airport_index = depot->index;
  1944 	}
  1940 	}
  1945 	ShowVehicleListWindowLocal(player, vehicle_type, INVALID_STATION, INVALID_ORDER, depot_airport_index);
  1941 	ShowVehicleListWindowLocal(player, VLW_DEPOT_LIST, vehicle_type, depot_airport_index);
  1946 }
  1942 }