ship_gui.c
changeset 755 80091de50044
parent 727 f2737e7461ef
child 757 7bfd863750a7
equal deleted inserted replaced
754:43b2e1b18154 755:80091de50044
   470 
   470 
   471 static void ShipViewWndProc(Window *w, WindowEvent *e) {
   471 static void ShipViewWndProc(Window *w, WindowEvent *e) {
   472 	switch(e->event) {
   472 	switch(e->event) {
   473 	case WE_PAINT: {
   473 	case WE_PAINT: {
   474 		Vehicle *v = &_vehicles[w->window_number];
   474 		Vehicle *v = &_vehicles[w->window_number];
   475 		uint32 disabled = 1<<7;
   475 		uint32 disabled = 1<<8;
   476 		StringID str;
   476 		StringID str;
   477 
   477 
   478 		// Possible to refit?
   478 		// Possible to refit?
   479 		if (ShipVehInfo(v->engine_type)->refittable &&
   479 		if (ShipVehInfo(v->engine_type)->refittable &&
   480 				v->vehstatus&VS_STOPPED &&
   480 				v->vehstatus&VS_STOPPED &&
   481 				v->u.ship.state == 0x80 &&
   481 				v->u.ship.state == 0x80 &&
   482 				IsShipDepotTile(v->tile))
   482 				IsShipDepotTile(v->tile))
   483 			disabled = 0;
   483 			disabled = 0;
   484 
   484 
   485 		if (v->owner != _local_player)
   485 		if (v->owner != _local_player)
   486 			disabled |= 1<<7 | 1<<6;
   486 			disabled |= 1<<8 | 1<<7;
   487 		w->disabled_state = disabled;
   487 		w->disabled_state = disabled;
   488 
   488 
   489 		/* draw widgets & caption */
   489 		/* draw widgets & caption */
   490 		SetDParam(0, v->string_id);
   490 		SetDParam(0, v->string_id);
   491 		SetDParam(1, v->unitnumber);
   491 		SetDParam(1, v->unitnumber);
   534 
   534 
   535 	case WE_CLICK: {
   535 	case WE_CLICK: {
   536 		Vehicle *v = &_vehicles[w->window_number];
   536 		Vehicle *v = &_vehicles[w->window_number];
   537 
   537 
   538 		switch(e->click.widget) {
   538 		switch(e->click.widget) {
   539 		case 4: /* start stop */
   539 		case 5: /* start stop */
   540 			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP));
   540 			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP));
   541 			break;
   541 			break;
   542 		case 5: /* center main view */
   542 		case 6: /* center main view */
   543 			ScrollMainWindowTo(v->x_pos, v->y_pos);
   543 			ScrollMainWindowTo(v->x_pos, v->y_pos);
   544 			break;
   544 			break;
   545 		case 6: /* goto hangar */
   545 		case 7: /* goto hangar */
   546 			DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT));
   546 			DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT));
   547 			break;
   547 			break;
   548 		case 7: /* refit */
   548 		case 8: /* refit */
   549 			ShowShipRefitWindow(v);
   549 			ShowShipRefitWindow(v);
   550 			break;
   550 			break;
   551 		case 8: /* show orders */
   551 		case 9: /* show orders */
   552 			ShowOrdersWindow(v);
   552 			ShowOrdersWindow(v);
   553 			break;
   553 			break;
   554 		case 9: /* show details */
   554 		case 10: /* show details */
   555 			ShowShipDetailsWindow(v);
   555 			ShowShipDetailsWindow(v);
   556 			break;
   556 			break;
   557 		}
   557 		}
   558 	} break;
   558 	} break;
   559 
   559 
   565 	}
   565 	}
   566 }
   566 }
   567 
   567 
   568 static const Widget _ship_view_widgets[] = {
   568 static const Widget _ship_view_widgets[] = {
   569 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
   569 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
   570 {    WWT_CAPTION,    14,    11,   249,     0,    13, STR_980F,	STR_018C_WINDOW_TITLE_DRAG_THIS},
   570 {    WWT_CAPTION,    14,    11,   237,     0,    13, STR_980F,	STR_018C_WINDOW_TITLE_DRAG_THIS},
       
   571 {  WWT_STICKYBOX,    14,   238,   249,     0,    13, 0x0,       STR_STICKY_BUTTON},
   571 {     WWT_IMGBTN,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
   572 {     WWT_IMGBTN,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
   572 {          WWT_6,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
   573 {          WWT_6,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
   573 { WWT_PUSHIMGBTN,    14,     0,   249,   104,   115, 0x0,				STR_9827_CURRENT_SHIP_ACTION_CLICK},
   574 { WWT_PUSHIMGBTN,    14,     0,   249,   104,   115, 0x0,				STR_9827_CURRENT_SHIP_ACTION_CLICK},
   574 { WWT_PUSHIMGBTN,    14,   232,   249,    14,    31, 0x2AB,			STR_9829_CENTER_MAIN_VIEW_ON_SHIP},
   575 { WWT_PUSHIMGBTN,    14,   232,   249,    14,    31, 0x2AB,			STR_9829_CENTER_MAIN_VIEW_ON_SHIP},
   575 { WWT_PUSHIMGBTN,    14,   232,   249,    32,    49, 0x2B0,			STR_982A_SEND_SHIP_TO_DEPOT},
   576 { WWT_PUSHIMGBTN,    14,   232,   249,    32,    49, 0x2B0,			STR_982A_SEND_SHIP_TO_DEPOT},
   580 };
   581 };
   581 
   582 
   582 static const WindowDesc _ship_view_desc = {
   583 static const WindowDesc _ship_view_desc = {
   583 	-1,-1, 250, 116,
   584 	-1,-1, 250, 116,
   584 	WC_VEHICLE_VIEW,0,
   585 	WC_VEHICLE_VIEW,0,
   585 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
   586 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
   586 	_ship_view_widgets,
   587 	_ship_view_widgets,
   587 	ShipViewWndProc
   588 	ShipViewWndProc
   588 };
   589 };
   589 
   590 
   590 void ShowShipViewWindow(Vehicle *v)
   591 void ShowShipViewWindow(Vehicle *v)