ship_gui.c
changeset 867 dffd33233237
parent 842 efc3546bc313
child 877 ce8cb2c09578
equal deleted inserted replaced
866:d242235e6485 867:dffd33233237
   133 	}
   133 	}
   134 }
   134 }
   135 
   135 
   136 
   136 
   137 static const Widget _ship_refit_widgets[] = {
   137 static const Widget _ship_refit_widgets[] = {
   138 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,						STR_018B_CLOSE_WINDOW},
   138 {    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,						STR_018B_CLOSE_WINDOW},
   139 {    WWT_CAPTION,    14,    11,   239,     0,    13, STR_983B_REFIT,			STR_018C_WINDOW_TITLE_DRAG_THIS},
   139 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   239,     0,    13, STR_983B_REFIT,			STR_018C_WINDOW_TITLE_DRAG_THIS},
   140 {     WWT_IMGBTN,    14,     0,   239,    14,   135, 0x0,									STR_983D_SELECT_TYPE_OF_CARGO_FOR},
   140 {     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   239,    14,   135, 0x0,									STR_983D_SELECT_TYPE_OF_CARGO_FOR},
   141 {     WWT_IMGBTN,    14,     0,   239,   136,   157, 0x0,									STR_NULL},
   141 {     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   239,   136,   157, 0x0,									STR_NULL},
   142 { WWT_PUSHTXTBTN,    14,     0,   239,   158,   169, STR_983C_REFIT_SHIP,	STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED},
   142 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   239,   158,   169, STR_983C_REFIT_SHIP,	STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED},
   143 {   WIDGETS_END},
   143 {   WIDGETS_END},
   144 };
   144 };
   145 
   145 
   146 static const WindowDesc _ship_refit_desc = {
   146 static const WindowDesc _ship_refit_desc = {
   147 	-1,-1, 240, 170,
   147 	-1,-1, 240, 170,
   288 	}
   288 	}
   289 }
   289 }
   290 
   290 
   291 
   291 
   292 static const Widget _ship_details_widgets[] = {
   292 static const Widget _ship_details_widgets[] = {
   293 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,				STR_018B_CLOSE_WINDOW},
   293 {    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,				STR_018B_CLOSE_WINDOW},
   294 {    WWT_CAPTION,    14,    11,   364,     0,    13, STR_9811_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS},
   294 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   364,     0,    13, STR_9811_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS},
   295 { WWT_PUSHTXTBTN,    14,   365,   404,     0,    13, STR_01AA_NAME,		STR_982F_NAME_SHIP},
   295 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   365,   404,     0,    13, STR_01AA_NAME,		STR_982F_NAME_SHIP},
   296 {     WWT_IMGBTN,    14,     0,   404,    14,    55, 0x0,							STR_NULL},
   296 {     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   404,    14,    55, 0x0,							STR_NULL},
   297 {     WWT_IMGBTN,    14,     0,   404,    56,    88, 0x0,							STR_NULL},
   297 {     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   404,    56,    88, 0x0,							STR_NULL},
   298 { WWT_PUSHTXTBTN,    14,     0,    10,    89,    94, STR_0188,				STR_884D_INCREASE_SERVICING_INTERVAL},
   298 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    10,    89,    94, STR_0188,				STR_884D_INCREASE_SERVICING_INTERVAL},
   299 { WWT_PUSHTXTBTN,    14,     0,    10,    95,   100, STR_0189,				STR_884E_DECREASE_SERVICING_INTERVAL},
   299 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    10,    95,   100, STR_0189,				STR_884E_DECREASE_SERVICING_INTERVAL},
   300 {     WWT_IMGBTN,    14,    11,   404,    89,   100, 0x0,							STR_NULL},
   300 {     WWT_IMGBTN,   RESIZE_NONE,    14,    11,   404,    89,   100, 0x0,							STR_NULL},
   301 {   WIDGETS_END},
   301 {   WIDGETS_END},
   302 };
   302 };
   303 
   303 
   304 static const WindowDesc _ship_details_desc = {
   304 static const WindowDesc _ship_details_desc = {
   305 	-1,-1, 405, 101,
   305 	-1,-1, 405, 101,
   366 			int selected_id = -1;
   366 			int selected_id = -1;
   367 
   367 
   368 			do {
   368 			do {
   369 				if (HASBIT(e->player_avail, _local_player)) {
   369 				if (HASBIT(e->player_avail, _local_player)) {
   370 					if (sel==0) selected_id = engine_id;
   370 					if (sel==0) selected_id = engine_id;
   371 					if (IS_INT_INSIDE(--pos, -4, 0)) {
   371 					if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
   372 						DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
   372 						DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
   373 						DrawShipEngine(x+35, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
   373 						DrawShipEngine(x+35, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
   374 						y += 24;
   374 						y += 24;
   375 					}
   375 					}
   376 					sel--;
   376 					sel--;
   380 			WP(w,buildtrain_d).sel_engine = selected_id;
   380 			WP(w,buildtrain_d).sel_engine = selected_id;
   381 
   381 
   382 			if (selected_id != -1) {
   382 			if (selected_id != -1) {
   383 				Set_DPARAM_Ship_Build_Window(selected_id);
   383 				Set_DPARAM_Ship_Build_Window(selected_id);
   384 
   384 
   385 				DrawString(2, 111, STR_980A_COST_SPEED_CAPACITY_RUNNING, 0);
   385 				DrawString(2, w->widget[4].top + 1, STR_980A_COST_SPEED_CAPACITY_RUNNING, 0);
   386 			}
   386 			}
   387 		}
   387 		}
   388 		break;
   388 		break;
   389 
   389 
   390 	case WE_CLICK:
   390 	case WE_CLICK:
   391 		switch(e->click.widget) {
   391 		switch(e->click.widget) {
   392 		case 2: { /* listbox */
   392 		case 2: { /* listbox */
   393 			uint i = (e->click.pt.y - 14) / 24;
   393 			uint i = (e->click.pt.y - 14) / 24;
   394 			if (i < 4) {
   394 			if (i < w->vscroll.cap) {
   395 				WP(w,buildtrain_d).sel_index = i + w->vscroll.pos;
   395 				WP(w,buildtrain_d).sel_index = i + w->vscroll.pos;
   396 				SetWindowDirty(w);
   396 				SetWindowDirty(w);
   397 			}
   397 			}
   398 		} break;
   398 		} break;
   399 		case 5: { /* build */
   399 		case 5: { /* build */
   428 			return;
   428 			return;
   429 		memcpy(_decode_parameters, b, 32);
   429 		memcpy(_decode_parameters, b, 32);
   430 		DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9839_CAN_T_RENAME_SHIP_TYPE));
   430 		DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9839_CAN_T_RENAME_SHIP_TYPE));
   431 	} break;
   431 	} break;
   432 
   432 
       
   433 	case WE_RESIZE:
       
   434 		w->vscroll.cap += e->sizing.diff.y / 24;
       
   435 		w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
       
   436 		break;
       
   437 
   433 	}
   438 	}
   434 }
   439 }
   435 
   440 
   436 static const Widget _new_ship_widgets[] = {
   441 static const Widget _new_ship_widgets[] = {
   437 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,						STR_018B_CLOSE_WINDOW},
   442 {    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,						STR_018B_CLOSE_WINDOW},
   438 {    WWT_CAPTION,    14,    11,   254,     0,    13, STR_9808_NEW_SHIPS,	STR_018C_WINDOW_TITLE_DRAG_THIS},
   443 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   254,     0,    13, STR_9808_NEW_SHIPS,	STR_018C_WINDOW_TITLE_DRAG_THIS},
   439 {     WWT_MATRIX,    14,     0,   243,    14,   109, 0x401,								STR_9825_SHIP_SELECTION_LIST_CLICK},
   444 {     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   243,    14,   109, 0x401,								STR_9825_SHIP_SELECTION_LIST_CLICK},
   440 {  WWT_SCROLLBAR,    14,   244,   254,    14,   109, 0x0,									STR_0190_SCROLL_BAR_SCROLLS_LIST},
   445 {  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   244,   254,    14,   109, 0x0,									STR_0190_SCROLL_BAR_SCROLLS_LIST},
   441 {     WWT_IMGBTN,    14,     0,   254,   110,   161, 0x0,									STR_NULL},
   446 {     WWT_IMGBTN,     RESIZE_TB,    14,     0,   254,   110,   161, 0x0,									STR_NULL},
   442 { WWT_PUSHTXTBTN,    14,     0,   126,   162,   173, STR_9809_BUILD_SHIP,	STR_9826_BUILD_THE_HIGHLIGHTED_SHIP},
   447 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   121,   162,   173, STR_9809_BUILD_SHIP,	STR_9826_BUILD_THE_HIGHLIGHTED_SHIP},
   443 { WWT_PUSHTXTBTN,    14,   127,   254,   162,   173, STR_9836_RENAME,			STR_9837_RENAME_SHIP_TYPE},
   448 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   122,   243,   162,   173, STR_9836_RENAME,			STR_9837_RENAME_SHIP_TYPE},
       
   449 {  WWT_RESIZEBOX,     RESIZE_TB,    14,   244,   254,   162,   173, 0x0,											STR_RESIZE_BUTTON},
   444 {   WIDGETS_END},
   450 {   WIDGETS_END},
   445 };
   451 };
   446 
   452 
   447 static const WindowDesc _new_ship_desc = {
   453 static const WindowDesc _new_ship_desc = {
   448 	-1, -1, 255, 174,
   454 	-1, -1, 255, 174,
   460 	DeleteWindowById(WC_BUILD_VEHICLE, tile);
   466 	DeleteWindowById(WC_BUILD_VEHICLE, tile);
   461 
   467 
   462 	w = AllocateWindowDesc(&_new_ship_desc);
   468 	w = AllocateWindowDesc(&_new_ship_desc);
   463 	w->window_number = tile;
   469 	w->window_number = tile;
   464 	w->vscroll.cap = 4;
   470 	w->vscroll.cap = 4;
       
   471 	w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
       
   472 
       
   473 	w->resize.step_height = 24;
   465 
   474 
   466 	if (tile != 0) {
   475 	if (tile != 0) {
   467 		w->caption_color = _map_owner[tile];
   476 		w->caption_color = _map_owner[tile];
   468 	} else {
   477 	} else {
   469 		w->caption_color = _local_player;
   478 		w->caption_color = _local_player;
   568 		break;
   577 		break;
   569 	}
   578 	}
   570 }
   579 }
   571 
   580 
   572 static const Widget _ship_view_widgets[] = {
   581 static const Widget _ship_view_widgets[] = {
   573 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
   582 {    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
   574 {    WWT_CAPTION,    14,    11,   237,     0,    13, STR_980F,	STR_018C_WINDOW_TITLE_DRAG_THIS},
   583 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   237,     0,    13, STR_980F,	STR_018C_WINDOW_TITLE_DRAG_THIS},
   575 {  WWT_STICKYBOX,    14,   238,   249,     0,    13, 0x0,       STR_STICKY_BUTTON},
   584 {  WWT_STICKYBOX,   RESIZE_NONE,    14,   238,   249,     0,    13, 0x0,       STR_STICKY_BUTTON},
   576 {     WWT_IMGBTN,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
   585 {     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
   577 {          WWT_6,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
   586 {          WWT_6,   RESIZE_NONE,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
   578 { WWT_PUSHIMGBTN,    14,     0,   249,   104,   115, 0x0,				STR_9827_CURRENT_SHIP_ACTION_CLICK},
   587 { WWT_PUSHIMGBTN,   RESIZE_NONE,    14,     0,   249,   104,   115, 0x0,				STR_9827_CURRENT_SHIP_ACTION_CLICK},
   579 { WWT_PUSHIMGBTN,    14,   232,   249,    14,    31, 0x2AB,			STR_9829_CENTER_MAIN_VIEW_ON_SHIP},
   588 { WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    14,    31, 0x2AB,			STR_9829_CENTER_MAIN_VIEW_ON_SHIP},
   580 { WWT_PUSHIMGBTN,    14,   232,   249,    32,    49, 0x2B0,			STR_982A_SEND_SHIP_TO_DEPOT},
   589 { WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    32,    49, 0x2B0,			STR_982A_SEND_SHIP_TO_DEPOT},
   581 { WWT_PUSHIMGBTN,    14,   232,   249,    50,    67, 0x2B4,			STR_983A_REFIT_CARGO_SHIP_TO_CARRY},
   590 { WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    50,    67, 0x2B4,			STR_983A_REFIT_CARGO_SHIP_TO_CARRY},
   582 { WWT_PUSHIMGBTN,    14,   232,   249,    68,    85, 0x2B2,			STR_9828_SHOW_SHIP_S_ORDERS},
   591 { WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    68,    85, 0x2B2,			STR_9828_SHOW_SHIP_S_ORDERS},
   583 { WWT_PUSHIMGBTN,    14,   232,   249,    86,   103, 0x2B3,			STR_982B_SHOW_SHIP_DETAILS},
   592 { WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    86,   103, 0x2B3,			STR_982B_SHOW_SHIP_DETAILS},
   584 {   WIDGETS_END},
   593 {   WIDGETS_END},
   585 };
   594 };
   586 
   595 
   587 static const WindowDesc _ship_view_desc = {
   596 static const WindowDesc _ship_view_desc = {
   588 	-1,-1, 250, 116,
   597 	-1,-1, 250, 116,
   623 	Depot *d;
   632 	Depot *d;
   624 
   633 
   625 	tile = w->window_number;
   634 	tile = w->window_number;
   626 
   635 
   627 	/* setup disabled buttons */
   636 	/* setup disabled buttons */
   628 	w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<6));
   637 	w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7));
   629 
   638 
   630 	/* determine amount of items for scroller */
   639 	/* determine amount of items for scroller */
   631 	num = 0;
   640 	num = 0;
   632 	FOR_ALL_VEHICLES(v) {
   641 	FOR_ALL_VEHICLES(v) {
   633 		if (v->type == VEH_Ship && v->u.ship.state == 0x80 &&
   642 		if (v->type == VEH_Ship && v->u.ship.state == 0x80 &&
   634 				v->tile == (TileIndex)tile)
   643 				v->tile == (TileIndex)tile)
   635 					num++;
   644 					num++;
   636 	}
   645 	}
   637 	SetVScrollCount(w, (num+2) / 3);
   646 	SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
   638 
   647 
   639 	/* locate the depot struct */
   648 	/* locate the depot struct */
   640 	for(d=_depots; d->xy != (TileIndex)tile; d++) {}
   649 	for(d=_depots; d->xy != (TileIndex)tile; d++) {}
   641 
   650 
   642 	SetDParam(0, d->town_index);
   651 	SetDParam(0, d->town_index);
   643 	DrawWindowWidgets(w);
   652 	DrawWindowWidgets(w);
   644 
   653 
   645 	x = 2;
   654 	x = 2;
   646 	y = 15;
   655 	y = 15;
   647 	num = w->vscroll.pos * 3;
   656 	num = w->vscroll.pos * w->hscroll.cap;
   648 
   657 
   649 	FOR_ALL_VEHICLES(v) {
   658 	FOR_ALL_VEHICLES(v) {
   650 		if (v->type == VEH_Ship &&
   659 		if (v->type == VEH_Ship &&
   651 				v->u.ship.state == 0x80 &&
   660 				v->u.ship.state == 0x80 &&
   652 				v->tile == (TileIndex)tile &&
   661 				v->tile == (TileIndex)tile &&
   653 				--num < 0 && num >=	-6) {
   662 				--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) {
   654 
   663 
   655 			DrawShipImage(v, x+19, y, WP(w,traindepot_d).sel);
   664 			DrawShipImage(v, x+19, y, WP(w,traindepot_d).sel);
   656 
   665 
   657 			SetDParam(0, v->unitnumber);
   666 			SetDParam(0, v->unitnumber);
   658 			DrawString(x, y, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
   667 			DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
   659 
   668 
   660 			DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y + 9);
   669 			DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y + 9);
   661 
   670 
   662 			if ((x+=90) == 2+90*3) {
   671 			if ((x+=90) == 2 + 90 * w->hscroll.cap) {
   663 				x = 2;
   672 				x = 2;
   664 				y += 24;
   673 				y += 24;
   665 			}
   674 			}
   666 		}
   675 		}
   667 	}
   676 	}
   749 		switch(e->click.widget) {
   758 		switch(e->click.widget) {
   750 		case 3:
   759 		case 3:
   751 			ShipDepotClick(w, e->click.pt.x, e->click.pt.y);
   760 			ShipDepotClick(w, e->click.pt.x, e->click.pt.y);
   752 			break;
   761 			break;
   753 
   762 
   754 		case 6:
   763 		case 7:
   755 			ShowBuildShipWindow(w->window_number);
   764 			ShowBuildShipWindow(w->window_number);
   756 			break;
   765 			break;
   757 
   766 
   758 		case 7: /* scroll to tile */
   767 		case 8: /* scroll to tile */
   759 			ScrollMainWindowToTile(w->window_number);
   768 			ScrollMainWindowToTile(w->window_number);
   760 			break;
   769 			break;
   761 		}
   770 		}
   762 		break;
   771 		break;
   763 
   772 
   779 					sel == v->index) {
   788 					sel == v->index) {
   780 				ShowShipViewWindow(v);
   789 				ShowShipViewWindow(v);
   781 			}
   790 			}
   782 		} break;
   791 		} break;
   783 
   792 
   784 		case 4:
   793 		case 5:
   785 			if (!HASBIT(w->disabled_state, 4) &&
   794 			if (!HASBIT(w->disabled_state, 5) &&
   786 					WP(w,traindepot_d).sel != INVALID_VEHICLE)	{
   795 					WP(w,traindepot_d).sel != INVALID_VEHICLE)	{
   787 				Vehicle *v;
   796 				Vehicle *v;
   788 
   797 
   789 				HandleButtonClick(w, 4);
   798 				HandleButtonClick(w, 5);
   790 
   799 
   791 				v = &_vehicles[WP(w,traindepot_d).sel];
   800 				v = &_vehicles[WP(w,traindepot_d).sel];
   792 				WP(w,traindepot_d).sel = INVALID_VEHICLE;
   801 				WP(w,traindepot_d).sel = INVALID_VEHICLE;
   793 
   802 
   794 				_backup_orders_tile = v->tile;
   803 				_backup_orders_tile = v->tile;
   803 			SetWindowDirty(w);
   812 			SetWindowDirty(w);
   804 		}
   813 		}
   805 		break;
   814 		break;
   806 	}
   815 	}
   807 	break;
   816 	break;
       
   817 
       
   818 	case WE_RESIZE:
       
   819 		w->vscroll.cap += e->sizing.diff.y / 24;
       
   820 		w->hscroll.cap += e->sizing.diff.x / 90;
       
   821 		w->widget[3].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
       
   822 		break;
   808 	}
   823 	}
   809 }
   824 }
   810 
   825 
   811 static const Widget _ship_depot_widgets[] = {
   826 static const Widget _ship_depot_widgets[] = {
   812 {    WWT_TEXTBTN,    14,     0,    10,     0,    13, STR_00C5, STR_018B_CLOSE_WINDOW},
   827 {    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
   813 {    WWT_CAPTION,    14,    11,   292,     0,    13, STR_9803_SHIP_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS},
   828 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   292,     0,    13, STR_9803_SHIP_DEPOT,		STR_018C_WINDOW_TITLE_DRAG_THIS},
   814 {  WWT_STICKYBOX,    14,   293,   304,     0,    13, 0x0,   STR_STICKY_BUTTON},
   829 {  WWT_STICKYBOX,     RESIZE_LR,    14,   293,   304,     0,    13, 0x0,										STR_STICKY_BUTTON},
   815 {     WWT_MATRIX,    14,     0,   269,    14,    61, 0x203, STR_981F_SHIPS_CLICK_ON_SHIP_FOR},
   830 {     WWT_MATRIX,     RESIZE_RB,    14,     0,   269,    14,    61, 0x203,									STR_981F_SHIPS_CLICK_ON_SHIP_FOR},
   816 {     WWT_IMGBTN,    14,   270,   293,    14,    61, 0x2A9, STR_9821_DRAG_SHIP_TO_HERE_TO_SELL},
   831 {      WWT_PANEL,    RESIZE_LRB,    14,   270,   293,    14,    13, 0x0,													STR_NULL},
   817 {  WWT_SCROLLBAR,    14,   294,   304,    14,    61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
   832 {     WWT_IMGBTN,   RESIZE_LRTB,    14,   270,   293,    14,    61, 0x2A9,									STR_9821_DRAG_SHIP_TO_HERE_TO_SELL},
   818 { WWT_PUSHTXTBTN,    14,     0,   151,    62,    73, STR_9804_NEW_SHIPS, STR_9820_BUILD_NEW_SHIP},
   833 {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   294,   304,    14,    61, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   819 { WWT_PUSHTXTBTN,    14,   152,   304,    62,    73, STR_00E4_LOCATION, STR_9822_CENTER_MAIN_VIEW_ON_SHIP},
   834 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   146,    62,    73, STR_9804_NEW_SHIPS,			STR_9820_BUILD_NEW_SHIP},
       
   835 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   147,   293,    62,    73, STR_00E4_LOCATION,			STR_9822_CENTER_MAIN_VIEW_ON_SHIP},
       
   836 {      WWT_PANEL,    RESIZE_RTB,    14,   294,   293,    62,    73, 0x0,													STR_NULL},
       
   837 {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   294,   304,    62,    73, 0x0,										STR_RESIZE_BUTTON},
   820 {   WIDGETS_END},
   838 {   WIDGETS_END},
   821 };
   839 };
   822 
   840 
   823 static const WindowDesc _ship_depot_desc = {
   841 static const WindowDesc _ship_depot_desc = {
   824 	-1, -1, 305, 74,
   842 	-1, -1, 305, 74,
   825 	WC_VEHICLE_DEPOT,0,
   843 	WC_VEHICLE_DEPOT,0,
   826 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
   844 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
   827 	_ship_depot_widgets,
   845 	_ship_depot_widgets,
   828 	ShipDepotWndProc
   846 	ShipDepotWndProc
   829 };
   847 };
   830 
   848 
   831 void ShowShipDepotWindow(uint tile)
   849 void ShowShipDepotWindow(uint tile)
   834 
   852 
   835 	w = AllocateWindowDescFront(&_ship_depot_desc,tile);
   853 	w = AllocateWindowDescFront(&_ship_depot_desc,tile);
   836 	if (w) {
   854 	if (w) {
   837 		w->caption_color = _map_owner[w->window_number];
   855 		w->caption_color = _map_owner[w->window_number];
   838 		w->vscroll.cap = 2;
   856 		w->vscroll.cap = 2;
       
   857 		w->hscroll.cap = 3;
       
   858 		w->resize.step_width = 90;
       
   859 		w->resize.step_height = 24;
   839 		WP(w,traindepot_d).sel = INVALID_VEHICLE;
   860 		WP(w,traindepot_d).sel = INVALID_VEHICLE;
   840 		_backup_orders_tile = 0;
   861 		_backup_orders_tile = 0;
   841 	}
   862 	}
   842 }
   863 }
   843 
   864 
   872 		}
   893 		}
   873 	}
   894 	}
   874 }
   895 }
   875 
   896 
   876 
   897 
   877 static Widget _player_ships_widgets[] = {
   898 static const Widget _player_ships_widgets[] = {
   878 {   WWT_CLOSEBOX,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
   899 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
   879 {    WWT_CAPTION,    14,    11,   247,     0,    13, STR_9805_SHIPS,				STR_018C_WINDOW_TITLE_DRAG_THIS},
   900 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   247,     0,    13, STR_9805_SHIPS,				STR_018C_WINDOW_TITLE_DRAG_THIS},
   880 {  WWT_STICKYBOX,    14,   248,   259,     0,    13, 0x0,                   STR_STICKY_BUTTON},
   901 {  WWT_STICKYBOX,     RESIZE_LR,    14,   248,   259,     0,    13, 0x0,                   STR_STICKY_BUTTON},
   881 { WWT_PUSHTXTBTN,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_ORDER_TIP},
   902 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_ORDER_TIP},
   882 {      WWT_PANEL,    14,    81,   237,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
   903 {      WWT_PANEL,   RESIZE_NONE,    14,    81,   232,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
   883 {   WWT_CLOSEBOX,    14,   238,   248,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
   904 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,   233,   243,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
   884 {      WWT_PANEL,    14,   249,   259,    14,    25, 0x0,										STR_NULL},
   905 {      WWT_PANEL,  RESIZE_RIGHT,    14,   244,   259,    14,    25, 0x0,										STR_NULL},
   885 {     WWT_MATRIX,    14,     0,   248,    26,   169, 0x401,									STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
   906 {     WWT_MATRIX,     RESIZE_RB,    14,     0,   248,    26,   169, 0x401,									STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
   886 {  WWT_SCROLLBAR,    14,   249,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   907 {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   249,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   887 { WWT_PUSHTXTBTN,    14,     0,   129,   170,   181, STR_9804_NEW_SHIPS,		STR_9824_BUILD_NEW_SHIPS_REQUIRES},
   908 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   124,   170,   181, STR_9804_NEW_SHIPS,		STR_9824_BUILD_NEW_SHIPS_REQUIRES},
   888 { WWT_PUSHTXTBTN,    14,   130,   259,   170,   181, STR_REPLACE_VEHICLES,					STR_REPLACE_HELP},
   909 { WWT_PUSHTXTBTN,     RESIZE_TB,    14,   125,   248,   170,   181, STR_REPLACE_VEHICLES,					STR_REPLACE_HELP},
       
   910 {      WWT_PANEL,    RESIZE_RTB,    14,   249,   248,   170,   181, 0x0,											STR_NULL},
       
   911 {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   249,   259,   170,   181, 0x0,											STR_RESIZE_BUTTON},
   889 {   WIDGETS_END},
   912 {   WIDGETS_END},
   890 };
   913 };
   891 
   914 
   892 static Widget _other_player_ships_widgets[] = {
   915 static const Widget _other_player_ships_widgets[] = {
   893 {   WWT_CLOSEBOX,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
   916 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
   894 {    WWT_CAPTION,    14,    11,   247,     0,    13, STR_9805_SHIPS,				STR_018C_WINDOW_TITLE_DRAG_THIS},
   917 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   247,     0,    13, STR_9805_SHIPS,				STR_018C_WINDOW_TITLE_DRAG_THIS},
   895 {  WWT_STICKYBOX,    14,   248,   259,     0,    13, 0x0,                   STR_STICKY_BUTTON},
   918 {  WWT_STICKYBOX,     RESIZE_LR,    14,   248,   259,     0,    13, 0x0,                   STR_STICKY_BUTTON},
   896 { WWT_PUSHTXTBTN,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_ORDER_TIP},
   919 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_ORDER_TIP},
   897 {      WWT_PANEL,    14,    81,   237,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
   920 {      WWT_PANEL,   RESIZE_NONE,    14,    81,   232,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
   898 {   WWT_CLOSEBOX,    14,   238,   248,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
   921 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,   233,   243,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
   899 {      WWT_PANEL,    14,   249,   259,    14,    25, 0x0,										STR_NULL},
   922 {      WWT_PANEL,  RESIZE_RIGHT,    14,   244,   259,    14,    25, 0x0,										STR_NULL},
   900 {     WWT_MATRIX,    14,     0,   248,    26,   169, 0x401,									STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
   923 {     WWT_MATRIX,     RESIZE_RB,    14,     0,   248,    26,   169, 0x401,									STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
   901 {  WWT_SCROLLBAR,    14,   249,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
   924 {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   249,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
       
   925 {      WWT_PANEL,    RESIZE_RTB,    14,   249,   248,   170,   181, 0x0,											STR_NULL},
       
   926 {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   249,   259,   170,   181, 0x0,											STR_RESIZE_BUTTON},
   902 {   WIDGETS_END},
   927 {   WIDGETS_END},
   903 };
   928 };
   904 
   929 
   905 static void PlayerShipsWndProc(Window *w, WindowEvent *e)
   930 static void PlayerShipsWndProc(Window *w, WindowEvent *e)
   906 {
   931 {
   925 			w->disabled_state |= (1 << 3);
   950 			w->disabled_state |= (1 << 3);
   926 
   951 
   927 		/* draw the widgets */
   952 		/* draw the widgets */
   928 		{
   953 		{
   929 			const Player *p = DEREF_PLAYER(owner);
   954 			const Player *p = DEREF_PLAYER(owner);
   930 			/* XXX hack */
       
   931 			if (station == -1) {
   955 			if (station == -1) {
   932 				/* Company Name -- (###) Trains */
   956 				/* Company Name -- (###) Trains */
   933 				SetDParam(0, p->name_1);
   957 				SetDParam(0, p->name_1);
   934 				SetDParam(1, p->name_2);
   958 				SetDParam(1, p->name_2);
   935 				SetDParam(2, w->vscroll.count);
   959 				SetDParam(2, w->vscroll.count);
   936 				_player_ships_widgets[1].unkA = STR_9805_SHIPS;
   960 				w->widget[1].unkA = STR_9805_SHIPS;
   937 				_other_player_ships_widgets[1].unkA = STR_9805_SHIPS;
       
   938 			} else {
   961 			} else {
   939 				/* Station Name -- (###) Trains */
   962 				/* Station Name -- (###) Trains */
   940 				SetDParam(0, DEREF_STATION(station)->index);
   963 				SetDParam(0, DEREF_STATION(station)->index);
   941 				SetDParam(1, w->vscroll.count);
   964 				SetDParam(1, w->vscroll.count);
   942 				_player_ships_widgets[1].unkA = STR_SCHEDULED_SHIPS;
   965 				w->widget[1].unkA = STR_SCHEDULED_SHIPS;
   943 				_other_player_ships_widgets[1].unkA = STR_SCHEDULED_SHIPS;
       
   944 			}
   966 			}
   945 			DrawWindowWidgets(w);
   967 			DrawWindowWidgets(w);
   946 		}
   968 		}
   947 		/* draw sorting criteria string */
   969 		/* draw sorting criteria string */
   948 		DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
   970 		DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
  1012 			}
  1034 			}
  1013 		} break;
  1035 		} break;
  1014 
  1036 
  1015 		case 9: { /* Build new Vehicle */
  1037 		case 9: { /* Build new Vehicle */
  1016 			uint tile;
  1038 			uint tile;
       
  1039 
       
  1040 			if (!IsWindowOfPrototype(w, _player_ships_widgets))
       
  1041 				break;
       
  1042 
  1017 
  1043 
  1018 			tile = _last_built_ship_depot_tile;
  1044 			tile = _last_built_ship_depot_tile;
  1019 			do {
  1045 			do {
  1020 				if (_map_owner[tile] == _local_player && IsShipDepotTile(tile)) {
  1046 				if (_map_owner[tile] == _local_player && IsShipDepotTile(tile)) {
  1021 					ShowShipDepotWindow(tile);
  1047 					ShowShipDepotWindow(tile);
  1026 				tile = TILE_MASK(tile + 1);
  1052 				tile = TILE_MASK(tile + 1);
  1027 			} while(tile != _last_built_ship_depot_tile);
  1053 			} while(tile != _last_built_ship_depot_tile);
  1028 
  1054 
  1029 			ShowBuildShipWindow(0);
  1055 			ShowBuildShipWindow(0);
  1030 		} break;
  1056 		} break;
  1031 		
  1057 
  1032 		case 10: {
  1058 		case 10: {
  1033 			ShowReplaceVehicleWindow(VEH_Ship);
  1059 			ShowReplaceVehicleWindow(VEH_Ship);
  1034 			break;
  1060 			break;
  1035 		}
  1061 		}
  1036 	}
  1062 	}
  1067 			vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
  1093 			vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
  1068 			vl->flags |= VL_RESORT;
  1094 			vl->flags |= VL_RESORT;
  1069 			SetWindowDirty(w);
  1095 			SetWindowDirty(w);
  1070 		}
  1096 		}
  1071 		break;
  1097 		break;
       
  1098 
       
  1099 	case WE_RESIZE:
       
  1100 		/* Update the scroll + matrix */
       
  1101 		w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_BIG;
       
  1102 		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
       
  1103 		break;
  1072 	}
  1104 	}
  1073 }
  1105 }
  1074 
  1106 
  1075 static const WindowDesc _player_ships_desc = {
  1107 static const WindowDesc _player_ships_desc = {
  1076 	-1, -1, 260, 182,
  1108 	-1, -1, 260, 182,
  1077 	WC_SHIPS_LIST,0,
  1109 	WC_SHIPS_LIST,0,
  1078 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
  1110 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  1079 	_player_ships_widgets,
  1111 	_player_ships_widgets,
  1080 	PlayerShipsWndProc
  1112 	PlayerShipsWndProc
  1081 };
  1113 };
  1082 
  1114 
  1083 static const WindowDesc _other_player_ships_desc = {
  1115 static const WindowDesc _other_player_ships_desc = {
  1084 	-1, -1, 260, 170,
  1116 	-1, -1, 260, 182,
  1085 	WC_SHIPS_LIST,0,
  1117 	WC_SHIPS_LIST,0,
  1086 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
  1118 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  1087 	_other_player_ships_widgets,
  1119 	_other_player_ships_widgets,
  1088 	PlayerShipsWndProc
  1120 	PlayerShipsWndProc
  1089 };
  1121 };
  1090 
  1122 
  1091 
  1123 
  1099 		w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player);
  1131 		w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player);
  1100 	}
  1132 	}
  1101 	if (w) {
  1133 	if (w) {
  1102 		w->caption_color = w->window_number;
  1134 		w->caption_color = w->window_number;
  1103 		w->vscroll.cap = 4;
  1135 		w->vscroll.cap = 4;
  1104 	}
  1136 		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
  1105 }
  1137 		w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
       
  1138 	}
       
  1139 }