src/window_gui.h
changeset 10502 996d9308d650
parent 10498 f198d0a1aab7
child 10504 7c80c8aaa1df
equal deleted inserted replaced
10501:10f2642f41dc 10502:996d9308d650
   555 	VL_DESC    = 1 << 0, ///< sort descending or ascending
   555 	VL_DESC    = 1 << 0, ///< sort descending or ascending
   556 	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
   556 	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
   557 	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
   557 	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
   558 	VL_END     = 1 << 3,
   558 	VL_END     = 1 << 3,
   559 };
   559 };
   560 
       
   561 DECLARE_ENUM_AS_BIT_SET(SortListFlags);
   560 DECLARE_ENUM_AS_BIT_SET(SortListFlags);
   562 
   561 
   563 struct Listing {
   562 struct Listing {
   564 	bool order;    ///< Ascending/descending
   563 	bool order;    ///< Ascending/descending
   565 	byte criteria; ///< Sorting criteria
   564 	byte criteria; ///< Sorting criteria
   566 };
   565 };
   567 
   566 
   568 struct list_d {
   567 template <typename T>
       
   568 struct GUIList {
       
   569 	T* sort_list;        ///< The items to sort.
       
   570 	SortListFlags flags; ///< used to control sorting/resorting/etc.
   569 	uint16 list_length;  ///< length of the list being sorted
   571 	uint16 list_length;  ///< length of the list being sorted
       
   572 	uint16 resort_timer; ///< resort list after a given amount of ticks if set
   570 	byte sort_type;      ///< what criteria to sort on
   573 	byte sort_type;      ///< what criteria to sort on
   571 	SortListFlags flags; ///< used to control sorting/resorting/etc.
   574 };
   572 	uint16 resort_timer; ///< resort list after a given amount of ticks if set
       
   573 };
       
   574 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d));
       
   575 
       
   576 struct vehiclelist_d {
       
   577 	const Vehicle** sort_list;  // List of vehicles (sorted)
       
   578 	Listing *_sorting;          // pointer to the appropiate subcategory of _sorting
       
   579 	uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
       
   580 	VehicleType vehicle_type;   // The vehicle type that is sorted
       
   581 	list_d l;                   // General list struct
       
   582 };
       
   583 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
       
   584 
   575 
   585 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   576 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   586 enum WindowWidgetBehaviours {
   577 enum WindowWidgetBehaviours {
   587 	WWB_PUSHBUTTON  = 1 << 5,
   578 	WWB_PUSHBUTTON  = 1 << 5,
   588 
   579