train_gui.c
changeset 982 d3ce4d6a65f8
parent 968 84a870c7a585
child 1002 9d83f1842257
equal deleted inserted replaced
981:f74abee65b7b 982:d3ce4d6a65f8
   305 	Depot *d;
   305 	Depot *d;
   306 
   306 
   307 	tile = w->window_number;
   307 	tile = w->window_number;
   308 
   308 
   309 	/* setup disabled buttons */
   309 	/* setup disabled buttons */
   310 	w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<5)|(1<<6)|(1<<8));
   310 	w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<5)|(1<<8));
   311 
   311 
   312 	/* determine amount of items for scroller */
   312 	/* determine amount of items for scroller */
   313 	num = 0;
   313 	num = 0;
   314 	hnum = 1;
   314 	hnum = 1;
   315 	FOR_ALL_VEHICLES(v) {
   315 	FOR_ALL_VEHICLES(v) {
   525 			ShowBuildTrainWindow(w->window_number);
   525 			ShowBuildTrainWindow(w->window_number);
   526 			break;
   526 			break;
   527 		case 9:
   527 		case 9:
   528 			ScrollMainWindowToTile(w->window_number);
   528 			ScrollMainWindowToTile(w->window_number);
   529 			break;
   529 			break;
   530 		case 3:
   530 		case 6:
   531 			TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y);
   531 			TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y);
   532 			break;
   532 			break;
   533 		}
   533 		}
   534 	} break;
   534 	} break;
   535 
   535 
   537 		DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
   537 		DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
   538 		break;
   538 		break;
   539 
   539 
   540 	case WE_DRAGDROP: {
   540 	case WE_DRAGDROP: {
   541 		switch(e->click.widget) {
   541 		switch(e->click.widget) {
   542 		case 5:
   542 		case 4: case 5: {
   543 		case 6: {
       
   544 			Vehicle *v;
   543 			Vehicle *v;
   545 			int sell_cmd;
   544 			int sell_cmd;
   546 
   545 
   547 			/* sell vehicle */
   546 			/* sell vehicle */
   548 			if (w->disabled_state & (1 << e->click.widget))
   547 			if (w->disabled_state & (1 << e->click.widget))
   556 			WP(w,traindepot_d).sel = INVALID_VEHICLE;
   555 			WP(w,traindepot_d).sel = INVALID_VEHICLE;
   557 			SetWindowDirty(w);
   556 			SetWindowDirty(w);
   558 
   557 
   559 			HandleButtonClick(w, e->click.widget);
   558 			HandleButtonClick(w, e->click.widget);
   560 
   559 
   561 			sell_cmd = (e->click.widget == 6 || _ctrl_pressed) ? 1 : 0;
   560 			sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0;
   562 
   561 
   563 			if (v->subtype != 0) {
   562 			if (v->subtype != 0) {
   564 				DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE));
   563 				DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE));
   565 			} else {
   564 			} else {
   566 				_backup_orders_tile = v->tile;
   565 				_backup_orders_tile = v->tile;
   568 				if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)))
   567 				if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)))
   569 					_backup_orders_tile = 0;
   568 					_backup_orders_tile = 0;
   570 			}
   569 			}
   571 		}	break;
   570 		}	break;
   572 
   571 
   573 		case 3: {
   572 		case 6: {
   574 				GetDepotVehiclePtData gdvp;
   573 				GetDepotVehiclePtData gdvp;
   575 				VehicleID sel = WP(w,traindepot_d).sel;
   574 				VehicleID sel = WP(w,traindepot_d).sel;
   576 
   575 
   577 				WP(w,traindepot_d).sel = INVALID_VEHICLE;
   576 				WP(w,traindepot_d).sel = INVALID_VEHICLE;
   578 				SetWindowDirty(w);
   577 				SetWindowDirty(w);
   595 		} break;
   594 		} break;
   596 	case WE_RESIZE: {
   595 	case WE_RESIZE: {
   597 		/* Update the scroll + matrix */
   596 		/* Update the scroll + matrix */
   598 		w->vscroll.cap += e->sizing.diff.y / 14;
   597 		w->vscroll.cap += e->sizing.diff.y / 14;
   599 		w->hscroll.cap += e->sizing.diff.x / 29;
   598 		w->hscroll.cap += e->sizing.diff.x / 29;
   600 		w->widget[3].unkA = (w->vscroll.cap << 8) + 1;
   599 		w->widget[6].unkA = (w->vscroll.cap << 8) + 1;
   601 	} break;
   600 	} break;
   602 	}
   601 	}
   603 }
   602 }
   604 
   603 
   605 static const Widget _train_depot_widgets[] = {
   604 static const Widget _train_depot_widgets[] = {
   606 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
   605 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
   607 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   336,     0,    13, STR_8800_TRAIN_DEPOT,	STR_018C_WINDOW_TITLE_DRAG_THIS},
   606 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   336,     0,    13, STR_8800_TRAIN_DEPOT,		STR_018C_WINDOW_TITLE_DRAG_THIS},
   608 {  WWT_STICKYBOX,     RESIZE_LR,    14,   337,   348,     0,    13, 0x0,                   STR_STICKY_BUTTON},
   607 {  WWT_STICKYBOX,     RESIZE_LR,    14,   337,   348,     0,    13, 0x0,										STR_STICKY_BUTTON},
   609 {     WWT_MATRIX,     RESIZE_RB,    14,     0,   313,    14,    97, 0x601,									STR_883F_TRAINS_CLICK_ON_TRAIN_FOR},
   608 
   610 {      WWT_PANEL,    RESIZE_LRB,    14,   314,   336,    14,    13, 0x0,										STR_NULL},
   609 {      WWT_PANEL,    RESIZE_LRB,    14,   314,   336,    14,    13, 0x0,										STR_NULL},
   611 {      WWT_PANEL,   RESIZE_LRTB,    14,   314,   336,    14,    54, 0x2A9,									STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE},
   610 {      WWT_PANEL,   RESIZE_LRTB,    14,   314,   336,    14,    54, 0x2A9,									STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE},
   612 {      WWT_PANEL,   RESIZE_LRTB,    14,   314,   336,    55,   109, 0x2BF,									STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP},
   611 {      WWT_PANEL,   RESIZE_LRTB,    14,   314,   336,    55,   109, 0x2BF,									STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP},
   613 
   612 
       
   613 {     WWT_MATRIX,     RESIZE_RB,    14,     0,   313,    14,    97, 0x601,									STR_883F_TRAINS_CLICK_ON_TRAIN_FOR},
   614 {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   337,   348,    14,   109, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   614 {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   337,   348,    14,   109, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   615 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   167,   110,   121, STR_8815_NEW_VEHICLES,	STR_8840_BUILD_NEW_TRAIN_VEHICLE},
   615 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   167,   110,   121, STR_8815_NEW_VEHICLES,	STR_8840_BUILD_NEW_TRAIN_VEHICLE},
   616 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   168,   336,   110,   121, STR_00E4_LOCATION,			STR_8842_CENTER_MAIN_VIEW_ON_TRAIN},
   616 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   168,   336,   110,   121, STR_00E4_LOCATION,			STR_8842_CENTER_MAIN_VIEW_ON_TRAIN},
   617 { WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,   313,    98,   109, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   617 { WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,   313,    98,   109, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   618 {      WWT_PANEL,    RESIZE_RTB,    14,   337,   336,   110,   121, 0x0,										STR_NULL},
   618 {      WWT_PANEL,    RESIZE_RTB,    14,   337,   336,   110,   121, 0x0,										STR_NULL},