vehicle_gui.c
changeset 1802 448f187042d3
parent 1763 9e6f367ae02e
child 1859 b3af0081df39
equal deleted inserted replaced
1801:0deeaf4cc09d 1802:448f187042d3
   161 	else if(v->profit_last_year < 10000)
   161 	else if(v->profit_last_year < 10000)
   162 		ormod = PALETTE_TO_YELLOW;
   162 		ormod = PALETTE_TO_YELLOW;
   163 	else
   163 	else
   164 		ormod = PALETTE_TO_GREEN;
   164 		ormod = PALETTE_TO_GREEN;
   165 	DrawSprite(SPR_BLOT | ormod, x, y);
   165 	DrawSprite(SPR_BLOT | ormod, x, y);
       
   166 }
       
   167 
       
   168 /** Draw the list of available refit options.
       
   169  * Draw the list and highlight the selected refit option (if any)
       
   170  * @param *v vehicle(type) to get the refit-options of
       
   171  * @param sel selected refit cargo-type in the window
       
   172  * @return the cargo type that is hightlighted, CT_INVALID if none
       
   173  */
       
   174 CargoID DrawVehicleRefitWindow(const Vehicle *v, int sel)
       
   175 {
       
   176 	uint32 cmask;
       
   177 	CargoID cid, cargo = CT_INVALID;
       
   178 	int y = 25;
       
   179 #define show_cargo(ctype) { \
       
   180 		byte colour = 16; \
       
   181 		if (sel == 0) { \
       
   182 			cargo = ctype; \
       
   183 			colour = 12; \
       
   184 } \
       
   185 		sel--; \
       
   186 		DrawString(6, y, _cargoc.names_s[ctype], colour); \
       
   187 		y += 10; \
       
   188 }
       
   189 
       
   190 		/* Check if engine has custom refit or normal ones, and get its bitmasked value.
       
   191 		 * Now just and it with the bitmasked available cargo on the current landscape, and
       
   192 		* where the bits are set: those are available */
       
   193 		cmask = (_engine_refit_masks[v->engine_type] != 0) ? _engine_refit_masks[v->engine_type] : _default_refitmasks[v->type - VEH_Train];
       
   194 		cmask &= _landscape_global_cargo_mask[_opt_ptr->landscape];
       
   195 
       
   196 		/* Check which cargo has been selected from the refit window and draw list */
       
   197 		for (cid = 0; cmask != 0; cmask >>= 1, cid++) {
       
   198 			if (HASBIT(cmask, 0)) // vehicle is refittable to this cargo
       
   199 				show_cargo(_local_cargo_id_ctype[cid]);
       
   200 		}
       
   201 		return cargo;
   166 }
   202 }
   167 
   203 
   168 /************ Sorter functions *****************/
   204 /************ Sorter functions *****************/
   169 int CDECL GeneralOwnerSorter(const void *a, const void *b)
   205 int CDECL GeneralOwnerSorter(const void *a, const void *b)
   170 {
   206 {