vehicle_gui.c
changeset 869 f211ac238c8e
parent 867 581154a08a78
child 870 1b8600157298
equal deleted inserted replaced
868:5740fa8b99ed 869:f211ac238c8e
   702 				} else {
   702 				} else {
   703 					SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
   703 					SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED);
   704 				}
   704 				}
   705 
   705 
   706 
   706 
   707 				DrawString(145, (WP(w,replaceveh_d).line_height == 24 ? 67 : 77 ) + ( WP(w,replaceveh_d).line_height * w->vscroll.cap), STR_02BD, 0x10);
   707 				DrawString(145, (w->resize.step_height == 24 ? 67 : 77 ) + ( w->resize.step_height * w->vscroll.cap), STR_02BD, 0x10);
   708 
   708 
   709 
   709 
   710 				/*	now we draw the two arrays according to what we just counted */
   710 				/*	now we draw the two arrays according to what we just counted */
   711 				DrawEngineArrayInReplaceWindow(w, x, y, x2, y2, pos, pos2, sel[0], sel[1], selected_id[0], selected_id[1]);
   711 				DrawEngineArrayInReplaceWindow(w, x, y, x2, y2, pos, pos2, sel[0], sel[1], selected_id[0], selected_id[1]);
   712 
   712 
   774 				}
   774 				}
   775 			}   // end of paint
   775 			}   // end of paint
   776 
   776 
   777 		case WE_CLICK: {
   777 		case WE_CLICK: {
   778 			switch(e->click.widget) {
   778 			switch(e->click.widget) {
   779 				/*case 0:
       
   780 					DeleteWindowById(WC_REPLACE_VEHICLE, WP(w,replaceveh_d).vehicletype );
       
   781 					break;*/
       
   782 
       
   783 				case 14: case 15:/* Select sorting criteria dropdown menu */
   779 				case 14: case 15:/* Select sorting criteria dropdown menu */
   784 				// finds mask for available engines
   780 				// finds mask for available engines
   785 				{
   781 				{
   786 					int engine_avail = 0;
   782 					int engine_avail = 0;
   787 					if ( !(HASBIT(_engines[NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES].player_avail, _local_player))) {
   783 					if ( !(HASBIT(_engines[NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES].player_avail, _local_player))) {
   788 						engine_avail = 4;
   784 						engine_avail = 4;
   789 						if ( !(HASBIT(_engines[NUM_NORMAL_RAIL_ENGINES].player_avail, _local_player)))
   785 						if ( !(HASBIT(_engines[NUM_NORMAL_RAIL_ENGINES].player_avail, _local_player)))
   790 							engine_avail = 6;
   786 							engine_avail = 6;
   791 					}
   787 					}
   792 					ShowDropDownMenu(w, _rail_types_list, WP(w,replaceveh_d).railtype, 15, engine_avail, 1);
   788 					ShowDropDownMenu(w, _rail_types_list, WP(w,replaceveh_d).railtype, 15, engine_avail, 1);
   793 					return;
   789 					break;
   794 				}
   790 				}
   795 				case 4: {
   791 				case 4: {
   796 					_autoreplace_array[WP(w,replaceveh_d).sel_engine[0]] = WP(w,replaceveh_d).sel_engine[1];
   792 					_autoreplace_array[WP(w,replaceveh_d).sel_engine[0]] = WP(w,replaceveh_d).sel_engine[1];
   797 					SetWindowDirty(w);
   793 					SetWindowDirty(w);
   798 					break;
   794 					break;
   809 					// this way, the code for 9 handles both sides
   805 					// this way, the code for 9 handles both sides
   810 					click_scroll_pos = w->vscroll.pos;
   806 					click_scroll_pos = w->vscroll.pos;
   811 					click_scroll_cap = w->vscroll.cap;
   807 					click_scroll_cap = w->vscroll.cap;
   812 					click_side = 0;
   808 					click_side = 0;
   813 				case 9: {
   809 				case 9: {
   814 					uint i = (e->click.pt.y - 14) / WP(w,replaceveh_d).line_height;
   810 					uint i = (e->click.pt.y - 14) / w->resize.step_height;
   815 					if (i < click_scroll_cap) {
   811 					if (i < click_scroll_cap) {
   816 						WP(w,replaceveh_d).sel_index[click_side] = i + click_scroll_pos;
   812 						WP(w,replaceveh_d).sel_index[click_side] = i + click_scroll_pos;
   817 						SetWindowDirty(w);
   813 						SetWindowDirty(w);
   818 					}
   814 					}
   819 				} break;
   815 				} break;
   837 	}
   833 	}
   838 }
   834 }
   839 
   835 
   840 static const Widget _replace_rail_vehicle_widgets[] = {
   836 static const Widget _replace_rail_vehicle_widgets[] = {
   841 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
   837 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
   842 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES,		STR_018C_WINDOW_TITLE_DRAG_THIS},
   838 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS},
   843 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, 0x0,						STR_STICKY_BUTTON},
   839 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, 0x0,						STR_STICKY_BUTTON},
   844 {      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   126,   187, 0x0,						STR_NULL},
   840 {      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   126,   187, 0x0,						STR_NULL},
   845 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   200,   211, STR_REPLACE_VEHICLES_START,STR_REPLACE_HELP_START_BUTTON},
   841 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   200,   211, STR_REPLACE_VEHICLES_START,STR_REPLACE_HELP_START_BUTTON},
   846 {      WWT_PANEL,     RESIZE_TB,    14,   139,   316,   188,   199, 0x0,						STR_REPLACE_HELP_REPLACE_INFO_TAB},
   842 {      WWT_PANEL,     RESIZE_TB,    14,   139,   316,   188,   199, 0x0,						STR_REPLACE_HELP_REPLACE_INFO_TAB},
   847 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   444,   200,   211, STR_REPLACE_VEHICLES_STOP,	STR_REPLACE_HELP_STOP_BUTTON},
   843 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   444,   200,   211, STR_REPLACE_VEHICLES_STOP,	STR_REPLACE_HELP_STOP_BUTTON},
   848 {     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   216,    14,   125, 0x801,			STR_REPLACE_HELP_LEFT_ARRAY},
   844 {     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   216,    14,   125, 0x801,						STR_REPLACE_HELP_LEFT_ARRAY},
   849 {  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   217,   227,    14,   125, 0x0,			STR_0190_SCROLL_BAR_SCROLLS_LIST},
   845 {  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   217,   227,    14,   125, 0x0,						STR_0190_SCROLL_BAR_SCROLLS_LIST},
   850 {     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   455,    14,   125, 0x801,			STR_REPLACE_HELP_RIGHT_ARRAY},
   846 {     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   455,    14,   125, 0x801,						STR_REPLACE_HELP_RIGHT_ARRAY},
   851 { WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   445,   455,    14,   125, 0x0,			STR_0190_SCROLL_BAR_SCROLLS_LIST},
   847 { WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   445,   455,    14,   125, 0x0,						STR_0190_SCROLL_BAR_SCROLLS_LIST},
   852 {      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   126,   187, 0x0,			STR_NULL},
   848 {      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   126,   187, 0x0,						STR_NULL},
   853 // the rest are train specific stuff
   849 // train specific stuff
   854 {      WWT_PANEL,     RESIZE_TB,    14,     0,   138,   188,   199, 0x0,			STR_NULL},
   850 {      WWT_PANEL,     RESIZE_TB,    14,     0,   138,   188,   199, 0x0,						STR_NULL},
   855 {      WWT_PANEL,     RESIZE_TB,     3,   139,   153,   200,   211, 0x0,			STR_NULL},
   851 {      WWT_PANEL,     RESIZE_TB,	14,   139,   153,   200,   211, 0x0,						STR_NULL},
   856 {      WWT_PANEL,     RESIZE_TB,    14,   154,   289,   200,   211, 0x0,			STR_REPLACE_HELP_RAILTYPE},
   852 {      WWT_PANEL,     RESIZE_TB,    14,   154,   289,   200,   211, 0x0,						STR_REPLACE_HELP_RAILTYPE},
   857 {   WWT_CLOSEBOX,     RESIZE_TB,    14,   279,   287,   201,   210, STR_0225,		STR_REPLACE_HELP_RAILTYPE},
   853 {   WWT_CLOSEBOX,     RESIZE_TB,    14,   279,   287,   201,   210, STR_0225,					STR_REPLACE_HELP_RAILTYPE},
   858 {      WWT_PANEL,     RESIZE_TB,     3,   290,   305,   200,   211, 0x0,			STR_NULL},
   854 {      WWT_PANEL,     RESIZE_TB,	14,   290,   305,   200,   211, 0x0,						STR_NULL},
   859 {      WWT_PANEL,     RESIZE_TB,    14,   317,   455,   188,   199, 0x0,			STR_NULL},
   855 {      WWT_PANEL,     RESIZE_TB,    14,   317,   455,   188,   199, 0x0,						STR_NULL},
   860 {  WWT_RESIZEBOX,     RESIZE_TB,    14,   445,   455,   200,   211, 0x0,												STR_RESIZE_BUTTON},
   856 // end of train specific stuff
       
   857 {  WWT_RESIZEBOX,     RESIZE_TB,    14,   445,   455,   200,   211, 0x0,						STR_RESIZE_BUTTON},
   861 {   WIDGETS_END},
   858 {   WIDGETS_END},
   862 };
   859 };
   863 
   860 
   864 static const Widget _replace_road_vehicle_widgets[] = {
   861 static const Widget _replace_road_vehicle_widgets[] = {
   865 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,										STR_018B_CLOSE_WINDOW},
   862 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
   866 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES,				STR_018C_WINDOW_TITLE_DRAG_THIS},
   863 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS},
   867 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, 0x0,												STR_STICKY_BUTTON},
   864 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, 0x0,						STR_STICKY_BUTTON},
   868 {      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   126,   187, 0x0,												STR_NULL},
   865 {      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   126,   187, 0x0,						STR_NULL},
   869 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   188,   199, STR_REPLACE_VEHICLES_START,	STR_REPLACE_HELP_START_BUTTON},
   866 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   188,   199, STR_REPLACE_VEHICLES_START,	STR_REPLACE_HELP_START_BUTTON},
   870 {      WWT_PANEL,     RESIZE_TB,    14,   139,   305,   188,   199, 0x0,												STR_REPLACE_HELP_REPLACE_INFO_TAB},
   867 {      WWT_PANEL,     RESIZE_TB,    14,   139,   305,   188,   199, 0x0,						STR_REPLACE_HELP_REPLACE_INFO_TAB},
   871 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   444,   188,   199, STR_REPLACE_VEHICLES_STOP,	STR_REPLACE_HELP_STOP_BUTTON},
   868 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   444,   188,   199, STR_REPLACE_VEHICLES_STOP,	STR_REPLACE_HELP_STOP_BUTTON},
   872 {     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   216,    14,   125, 0x801,											STR_REPLACE_HELP_LEFT_ARRAY},
   869 {     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   216,    14,   125, 0x801,						STR_REPLACE_HELP_LEFT_ARRAY},
   873 {  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   217,   227,    14,   125, 0x0,												STR_0190_SCROLL_BAR_SCROLLS_LIST},
   870 {  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   217,   227,    14,   125, 0x0,						STR_0190_SCROLL_BAR_SCROLLS_LIST},
   874 {     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   455,    14,   125, 0x801,											STR_REPLACE_HELP_RIGHT_ARRAY},
   871 {     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   455,    14,   125, 0x801,						STR_REPLACE_HELP_RIGHT_ARRAY},
   875 { WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   445,   455,    14,   125, 0x0,												STR_0190_SCROLL_BAR_SCROLLS_LIST},
   872 { WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   445,   455,    14,   125, 0x0,						STR_0190_SCROLL_BAR_SCROLLS_LIST},
   876 {      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   126,   187, 0x0,												STR_NULL},
   873 {      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   126,   187, 0x0,						STR_NULL},
   877 {  WWT_RESIZEBOX,     RESIZE_TB,    14,   445,   455,   188,   199, 0x0,												STR_RESIZE_BUTTON},
   874 {  WWT_RESIZEBOX,     RESIZE_TB,    14,   445,   455,   188,   199, 0x0,						STR_RESIZE_BUTTON},
   878 {   WIDGETS_END},
   875 {   WIDGETS_END},
   879 };
   876 };
   880 
   877 
   881 static const Widget _replace_ship_aircraft_vehicle_widgets[] = {
   878 static const Widget _replace_ship_aircraft_vehicle_widgets[] = {
   882 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,										STR_018B_CLOSE_WINDOW},
   879 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
   883 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES,				STR_018C_WINDOW_TITLE_DRAG_THIS},
   880 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   443,     0,    13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS},
   884 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, 0x0,												STR_STICKY_BUTTON},
   881 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   444,   455,     0,    13, 0x0,						STR_STICKY_BUTTON},
   885 {      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   110,   161, 0x0,												STR_NULL},
   882 {      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   110,   161, 0x0,						STR_NULL},
   886 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   162,   173, STR_REPLACE_VEHICLES_START,	STR_REPLACE_HELP_START_BUTTON},
   883 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   138,   162,   173, STR_REPLACE_VEHICLES_START,	STR_REPLACE_HELP_START_BUTTON},
   887 {      WWT_PANEL,     RESIZE_TB,    14,   139,   305,   162,   173, 0x0,												STR_REPLACE_HELP_REPLACE_INFO_TAB},
   884 {      WWT_PANEL,     RESIZE_TB,    14,   139,   305,   162,   173, 0x0,						STR_REPLACE_HELP_REPLACE_INFO_TAB},
   888 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   444,   162,   173, STR_REPLACE_VEHICLES_STOP,	STR_REPLACE_HELP_STOP_BUTTON},
   885 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   306,   444,   162,   173, STR_REPLACE_VEHICLES_STOP,	STR_REPLACE_HELP_STOP_BUTTON},
   889 {     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   216,    14,   109, 0x401,											STR_REPLACE_HELP_LEFT_ARRAY},
   886 {     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   216,    14,   109, 0x401,						STR_REPLACE_HELP_LEFT_ARRAY},
   890 {  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   217,   227,    14,   109, 0x0,												STR_0190_SCROLL_BAR_SCROLLS_LIST},
   887 {  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   217,   227,    14,   109, 0x0,						STR_0190_SCROLL_BAR_SCROLLS_LIST},
   891 {     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   455,    14,   109, 0x401,											STR_REPLACE_HELP_RIGHT_ARRAY},
   888 {     WWT_MATRIX, RESIZE_BOTTOM,    14,   228,   455,    14,   109, 0x401,						STR_REPLACE_HELP_RIGHT_ARRAY},
   892 { WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   445,   455,    14,   109, 0x0,												STR_0190_SCROLL_BAR_SCROLLS_LIST},
   889 { WWT_SCROLL2BAR, RESIZE_BOTTOM,    14,   445,   455,    14,   109, 0x0,						STR_0190_SCROLL_BAR_SCROLLS_LIST},
   893 {      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   110,   161, 0x0,												STR_NULL},
   890 {      WWT_PANEL,     RESIZE_TB,    14,   228,   455,   110,   161, 0x0,						STR_NULL},
   894 {  WWT_RESIZEBOX,     RESIZE_TB,    14,   445,   455,   162,   173, 0x0,												STR_RESIZE_BUTTON},
   891 {  WWT_RESIZEBOX,     RESIZE_TB,    14,   445,   455,   162,   173, 0x0,						STR_RESIZE_BUTTON},
   895 {   WIDGETS_END},
   892 {   WIDGETS_END},
   896 };
   893 };
   897 
   894 
   898 static const WindowDesc _replace_rail_vehicle_desc = {
   895 static const WindowDesc _replace_rail_vehicle_desc = {
   899 	-1, -1, 456, 212,
   896 	-1, -1, 456, 212,
   929 	switch (vehicletype) {
   926 	switch (vehicletype) {
   930 		case VEH_Train:
   927 		case VEH_Train:
   931 			w = AllocateWindowDescFront(&_replace_rail_vehicle_desc, vehicletype);
   928 			w = AllocateWindowDescFront(&_replace_rail_vehicle_desc, vehicletype);
   932 			w->vscroll.cap  = 8;
   929 			w->vscroll.cap  = 8;
   933 			w->resize.step_height = 14;
   930 			w->resize.step_height = 14;
   934 			WP(w,replaceveh_d).line_height = 14;
   931 			w->widget[13].color = _player_colors[_local_player];
       
   932 			w->widget[16].color = _player_colors[_local_player];
   935 			break;
   933 			break;
   936 		case VEH_Road:
   934 		case VEH_Road:
   937 			w = AllocateWindowDescFront(&_replace_road_vehicle_desc, vehicletype);
   935 			w = AllocateWindowDescFront(&_replace_road_vehicle_desc, vehicletype);
   938 			w->vscroll.cap  = 8;
   936 			w->vscroll.cap  = 8;
   939 			w->resize.step_height = 14;
   937 			w->resize.step_height = 14;
   940 			WP(w,replaceveh_d).line_height = 14;
       
   941 			break;
   938 			break;
   942 		case VEH_Ship: case VEH_Aircraft:
   939 		case VEH_Ship: case VEH_Aircraft:
   943 			w = AllocateWindowDescFront(&_replace_ship_aircraft_vehicle_desc, vehicletype);
   940 			w = AllocateWindowDescFront(&_replace_ship_aircraft_vehicle_desc, vehicletype);
   944 			w->vscroll.cap  = 4;
   941 			w->vscroll.cap  = 4;
   945 			w->resize.step_height = 24;
   942 			w->resize.step_height = 24;
   946 			WP(w,replaceveh_d).line_height = 24;
       
   947 			break;
   943 			break;
   948 		default: return;
   944 		default: return;
   949 	}
   945 	}
       
   946 	w->caption_color = _local_player;
   950 	WP(w,replaceveh_d).vehicletype = vehicletype;
   947 	WP(w,replaceveh_d).vehicletype = vehicletype;
   951 	w->vscroll2.cap = w->vscroll.cap;   // these two are always the same
   948 	w->vscroll2.cap = w->vscroll.cap;   // these two are always the same
   952 }
   949 }