src/vehicle_gui.cpp
changeset 8993 35c33a4819de
parent 8974 4d93998b3c1d
child 8994 fb5e761cf141
equal deleted inserted replaced
8992:0b2fb43cc875 8993:35c33a4819de
    33 #include "core/alloc_func.hpp"
    33 #include "core/alloc_func.hpp"
    34 #include "string_func.h"
    34 #include "string_func.h"
    35 #include "settings_type.h"
    35 #include "settings_type.h"
    36 #include "widgets/dropdown_func.h"
    36 #include "widgets/dropdown_func.h"
    37 #include "order_func.h"
    37 #include "order_func.h"
    38 #include "depot_base.h"
       
    39 
    38 
    40 #include "table/sprites.h"
    39 #include "table/sprites.h"
    41 #include "table/strings.h"
    40 #include "table/strings.h"
    42 
    41 
    43 struct refit_d {
    42 struct refit_d {
   101 	STR_SORT_BY_VALUE,
   100 	STR_SORT_BY_VALUE,
   102 	STR_SORT_BY_LENGTH,
   101 	STR_SORT_BY_LENGTH,
   103 	INVALID_STRING_ID
   102 	INVALID_STRING_ID
   104 };
   103 };
   105 
   104 
   106 void RebuildVehicleLists()
   105 /**
       
   106  * Set sort list flag for all vehicle list windows
       
   107  * @param sl_flag Sort list flag to set
       
   108  */
       
   109 static void SetVehicleListsFlag(SortListFlags sl_flag)
   107 {
   110 {
   108 	Window* const *wz;
   111 	Window* const *wz;
   109 
   112 
   110 	FOR_ALL_WINDOWS(wz) {
   113 	FOR_ALL_WINDOWS(wz) {
   111 		Window *w = *wz;
   114 		Window *w = *wz;
   113 		switch (w->window_class) {
   116 		switch (w->window_class) {
   114 			case WC_TRAINS_LIST:
   117 			case WC_TRAINS_LIST:
   115 			case WC_ROADVEH_LIST:
   118 			case WC_ROADVEH_LIST:
   116 			case WC_SHIPS_LIST:
   119 			case WC_SHIPS_LIST:
   117 			case WC_AIRCRAFT_LIST:
   120 			case WC_AIRCRAFT_LIST:
   118 				WP(w, vehiclelist_d).l.flags |= VL_REBUILD;
   121 				WP(w, vehiclelist_d).l.flags |= sl_flag;
   119 				SetWindowDirty(w);
   122 				SetWindowDirty(w);
   120 				break;
   123 				break;
   121 
   124 
   122 			default: break;
   125 			default: break;
   123 		}
   126 		}
   124 	}
   127 	}
   125 }
   128 }
   126 
   129 
       
   130 /**
       
   131  * Rebuild all vehicle list windows
       
   132  */
       
   133 void RebuildVehicleLists()
       
   134 {
       
   135 	SetVehicleListsFlag(VL_REBUILD);
       
   136 }
       
   137 
       
   138 /**
       
   139  * Resort all vehicle list windows
       
   140  */
   127 void ResortVehicleLists()
   141 void ResortVehicleLists()
   128 {
   142 {
   129 	Window* const *wz;
   143 	SetVehicleListsFlag(VL_RESORT);
   130 
       
   131 	FOR_ALL_WINDOWS(wz) {
       
   132 		Window *w = *wz;
       
   133 
       
   134 		switch (w->window_class) {
       
   135 			case WC_TRAINS_LIST:
       
   136 			case WC_ROADVEH_LIST:
       
   137 			case WC_SHIPS_LIST:
       
   138 			case WC_AIRCRAFT_LIST:
       
   139 				WP(w, vehiclelist_d).l.flags |= VL_RESORT;
       
   140 				SetWindowDirty(w);
       
   141 				break;
       
   142 
       
   143 			default: break;
       
   144 		}
       
   145 	}
       
   146 }
   144 }
   147 
   145 
   148 void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type)
   146 void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type)
   149 {
   147 {
   150 	if (!(vl->l.flags & VL_REBUILD)) return;
   148 	if (!(vl->l.flags & VL_REBUILD)) return;