src/window.h
branchNewGRF_ports
changeset 6719 4cc327ad39d5
parent 6604 ad6057954de6
child 6720 35756db7e577
equal deleted inserted replaced
6718:5a8b295aa345 6719:4cc327ad39d5
     7 
     7 
     8 #include "macros.h"
     8 #include "macros.h"
     9 #include "string.h"
     9 #include "string.h"
    10 #include "order.h"
    10 #include "order.h"
    11 #include "rail.h"
    11 #include "rail.h"
       
    12 #include "road.h"
    12 #include "airport.h"
    13 #include "airport.h"
       
    14 #include "vehicle.h"
    13 
    15 
    14 struct WindowEvent;
    16 struct WindowEvent;
    15 
    17 
    16 typedef void WindowProc(Window *w, WindowEvent *e);
    18 typedef void WindowProc(Window *w, WindowEvent *e);
    17 
    19 
   131 
   133 
   132 		struct {
   134 		struct {
   133 			Point pt;
   135 			Point pt;
   134 			TileIndex tile;
   136 			TileIndex tile;
   135 			TileIndex starttile;
   137 			TileIndex starttile;
   136 			int userdata;
   138 			byte select_method;
       
   139 			byte select_proc;
   137 		} place;
   140 		} place;
   138 
   141 
   139 		struct {
   142 		struct {
   140 			Point pt;
   143 			Point pt;
   141 			int widget;
   144 			int widget;
   277 	const char *orig;
   280 	const char *orig;
   278 	CharSetFilter afilter;
   281 	CharSetFilter afilter;
   279 	bool handled;
   282 	bool handled;
   280 };
   283 };
   281 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
   284 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
       
   285 
       
   286 struct chatquerystr_d : public querystr_d {
       
   287 	int dest;
       
   288 };
       
   289 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d));
   282 
   290 
   283 struct menu_d {
   291 struct menu_d {
   284 	byte item_count;      ///< follow_vehicle
   292 	byte item_count;      ///< follow_vehicle
   285 	byte sel_index;       ///< scrollpos_x
   293 	byte sel_index;       ///< scrollpos_x
   286 	byte main_button;     ///< scrollpos_y
   294 	byte main_button;     ///< scrollpos_y
   316 	uint32 params[5];
   324 	uint32 params[5];
   317 };
   325 };
   318 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
   326 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
   319 
   327 
   320 struct buildvehicle_d {
   328 struct buildvehicle_d {
   321 	byte vehicle_type;
   329 	VehicleType vehicle_type;
   322 	union {
   330 	union {
   323 		RailTypeByte railtype;
   331 		RailTypeByte railtype;
   324 		AirportFTAClass::Flags flags;
   332 		AirportFTAClass::Flags flags;
       
   333 		RoadTypes roadtypes;
   325 	} filter;
   334 	} filter;
   326 	byte sel_index;  ///< deprecated value, used for 'unified' ship and road
   335 	byte sel_index;  ///< deprecated value, used for 'unified' ship and road
   327 	bool descending_sort_order;
   336 	bool descending_sort_order;
   328 	byte sort_criteria;
   337 	byte sort_criteria;
   329 	bool regenerate_list;
   338 	bool regenerate_list;
   340 	bool wagon_btnstate; ///< true means engine is selected
   349 	bool wagon_btnstate; ///< true means engine is selected
   341 	EngineList list[2];
   350 	EngineList list[2];
   342 	bool update_left;
   351 	bool update_left;
   343 	bool update_right;
   352 	bool update_right;
   344 	bool init_lists;
   353 	bool init_lists;
       
   354 	GroupID sel_group;
   345 };
   355 };
   346 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
   356 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
   347 
   357 
   348 struct depot_d {
   358 struct depot_d {
   349 	VehicleID sel;
   359 	VehicleID sel;
   350 	byte type;
   360 	VehicleType type;
   351 	bool generate_list;
   361 	bool generate_list;
   352 	uint16 engine_list_length;
   362 	uint16 engine_list_length;
   353 	uint16 wagon_list_length;
   363 	uint16 wagon_list_length;
   354 	uint16 engine_count;
   364 	uint16 engine_count;
   355 	uint16 wagon_count;
   365 	uint16 wagon_count;
   392 
   402 
   393 struct vp_d {
   403 struct vp_d {
   394 	VehicleID follow_vehicle;
   404 	VehicleID follow_vehicle;
   395 	int32 scrollpos_x;
   405 	int32 scrollpos_x;
   396 	int32 scrollpos_y;
   406 	int32 scrollpos_y;
       
   407 	int32 dest_scrollpos_x;
       
   408 	int32 dest_scrollpos_y;
   397 };
   409 };
   398 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
   410 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
   399 
   411 
   400 /* vp2_d is the same as vp_d, except for the data_# values.. */
   412 /* vp2_d is the same as vp_d, except for the data_# values.. */
   401 struct vp2_d {
   413 struct vp2_d {
   402 	VehicleID follow_vehicle;
   414 	VehicleID follow_vehicle;
   403 	int32 scrollpos_x;
   415 	int32 scrollpos_x;
   404 	int32 scrollpos_y;
   416 	int32 scrollpos_y;
       
   417 	int32 dest_scrollpos_x;
       
   418 	int32 dest_scrollpos_y;
   405 	byte data_1;
   419 	byte data_1;
   406 	byte data_2;
   420 	byte data_2;
   407 	byte data_3;
   421 	byte data_3;
   408 };
   422 };
   409 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d));
   423 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d));
   410 
   424 
   411 struct news_d {
   425 struct news_d {
   412 	uint16 follow_vehicle;
   426 	uint16 follow_vehicle;
   413 	int32 scrollpos_x;
   427 	int32 scrollpos_x;
   414 	int32 scrollpos_y;
   428 	int32 scrollpos_y;
       
   429 	int32 dest_scrollpos_x;
       
   430 	int32 dest_scrollpos_y;
   415 	NewsItem *ni;
   431 	NewsItem *ni;
   416 };
   432 };
   417 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
   433 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
   418 
   434 
   419 struct highscore_d {
   435 struct highscore_d {
   470 	byte click_delay;
   486 	byte click_delay;
   471 	bool drag_mode;
   487 	bool drag_mode;
   472 };
   488 };
   473 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
   489 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
   474 
   490 
       
   491 struct vehiclelist_d {
       
   492 	const Vehicle** sort_list;  // List of vehicles (sorted)
       
   493 	Listing *_sorting;          // pointer to the appropiate subcategory of _sorting
       
   494 	uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
       
   495 	VehicleType vehicle_type;   // The vehicle type that is sorted
       
   496 	list_d l;                   // General list struct
       
   497 };
       
   498 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
       
   499 
       
   500 struct grouplist_d {
       
   501 	const Group **sort_list;
       
   502 	list_d l;                   // General list struct
       
   503 };
       
   504 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d));
       
   505 
       
   506 struct groupveh_d : vehiclelist_d {
       
   507 	GroupID group_sel;
       
   508 	VehicleID vehicle_sel;
       
   509 
       
   510 	grouplist_d gl;
       
   511 };
       
   512 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d));
   475 
   513 
   476 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   514 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
   477 enum WindowWidgetBehaviours {
   515 enum WindowWidgetBehaviours {
   478 	WWB_PUSHBUTTON  = 1 << 5,
   516 	WWB_PUSHBUTTON  = 1 << 5,
   479 
   517 
   657 
   695 
   658 /**
   696 /**
   659  * Sets the lowered/raised status of a widget.
   697  * Sets the lowered/raised status of a widget.
   660  * @param w : Window on which the widget is located
   698  * @param w : Window on which the widget is located
   661  * @param widget_index : index of this widget in the window
   699  * @param widget_index : index of this widget in the window
   662  * @param hidden_stat : status to use ie: lowered = true, raised = false
   700  * @param lowered_stat : status to use ie: lowered = true, raised = false
   663  */
   701  */
   664 static inline void SetWindowWidgetLoweredState(Window *w, byte widget_index, bool lowered_stat)
   702 static inline void SetWindowWidgetLoweredState(Window *w, byte widget_index, bool lowered_stat)
   665 {
   703 {
   666 	assert(widget_index < w->widget_count);
   704 	assert(widget_index < w->widget_count);
   667 	SB(w->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat);
   705 	SB(w->widget[widget_index].display_flags, WIDG_LOWERED, 1, !!lowered_stat);