aircraft_gui.c
author tron
Sat, 05 Feb 2005 15:58:59 +0000
changeset 1299 39c06aba09aa
parent 1294 4cdf0e76c093
child 1313 f1013ec3d318
permissions -rw-r--r--
(svn r1803) Move debugging stuff into files of it's own
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#include "stdafx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     2
#include "ttd.h"
1299
39c06aba09aa (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1294
diff changeset
     3
#include "debug.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 382
diff changeset
     4
#include "table/strings.h"
679
04ca2cd69420 (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 588
diff changeset
     5
#include "map.h"
1209
2e00193652b2 (svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents: 1055
diff changeset
     6
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "engine.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "player.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    18
void Set_DPARAM_Aircraft_Build_Window(uint16 engine_number)
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    19
{
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    20
	const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    21
	Engine *e;
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    22
	YearMonthDay ymd;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
    23
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    24
	SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    25
	SetDParam(1, avi->max_speed * 8);
922
10035216cbaf (svn r1410) Replaced all occurences of 'passanger' by 'passenger' in the code
celestar
parents: 919
diff changeset
    26
	SetDParam(2, avi->passenger_capacity);
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    27
	SetDParam(3, avi->mail_capacity);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    28
	SetDParam(4, avi->running_cost * _price.aircraft_running >> 8);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    29
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    30
	e = &_engines[engine_number];
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    31
	SetDParam(6, e->lifelength);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    32
	SetDParam(7, e->reliability * 100 >> 16);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    33
	ConvertDayToYMD(&ymd, e->intro_date);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    34
	SetDParam(5, ymd.year + 1920);
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
    35
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    36
}
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
    37
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
static void DrawAircraftImage(Vehicle *v, int x, int y, VehicleID selection)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	int image = GetAircraftImage(v, 6);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
	uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	if (v->vehstatus & VS_CRASHED) ormod = 0x3248000;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
	DrawSprite(image | ormod, x+25, y+10);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	if (v->subtype == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
		DrawSprite(0xF3D, x+25, y+5);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
	if (v->index == selection) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
		DrawFrameRect(x-1, y-1, x+58, y+21, 0xF, 0x10);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 538
diff changeset
    51
void CcBuildAircraft(bool success, uint tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	if (success) {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
    56
		v = GetVehicle(_new_aircraft_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
		if (v->tile == _backup_orders_tile) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
			_backup_orders_tile = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
			RestoreVehicleOrders(v, _backup_orders_data);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
		ShowAircraftViewWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
static void NewAircraftWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
		if (w->window_number == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
			SETBIT(w->disabled_state, 5);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
		{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
			int count = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
			int num = NUM_AIRCRAFT_ENGINES;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
			Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
				if (HASBIT(e->player_avail, _local_player))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
					count++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
			} while (++e,--num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
			SetVScrollCount(w, count);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
		{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
			int num = NUM_AIRCRAFT_ENGINES;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
			Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
			int x = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
			int y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
			int sel = WP(w,buildtrain_d).sel_index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
			int pos = w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
			int engine_id = AIRCRAFT_ENGINES_INDEX;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
			int selected_id = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
				if (HASBIT(e->player_avail, _local_player)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
					if (sel==0) selected_id = engine_id;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   100
					if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
						DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
						DrawAircraftEngine(x+29, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
						y += 24;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
					sel--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
			} while (++engine_id, ++e,--num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
			WP(w,buildtrain_d).sel_engine = selected_id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
			if (selected_id != -1) {
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
   112
				Set_DPARAM_Aircraft_Build_Window(selected_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   114
				DrawString(2, w->widget[4].top + 1, STR_A007_COST_SPEED_CAPACITY_PASSENGERS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
		case 2: { /* listbox */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
			uint i = (e->click.pt.y - 14) / 24;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   123
			if (i < w->vscroll.cap) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
				WP(w,buildtrain_d).sel_index = i + w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
				SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
		case 5: { /* build */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
			int sel_eng = WP(w,buildtrain_d).sel_engine;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
			if (sel_eng != -1)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
				DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
968
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   135
		case 6:	{ /* rename */
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   136
			int sel_eng = WP(w,buildtrain_d).sel_engine;
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   137
			if (sel_eng != -1) {
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   138
				WP(w,buildtrain_d).rename_engine = sel_eng;
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   139
				ShowQueryString(GetCustomEngineName(sel_eng),
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   140
					STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number);
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   141
			}
84a870c7a585 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents: 924
diff changeset
   142
		} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	case WE_4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
		if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
	case WE_ON_EDIT_TEXT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
		byte *b = e->edittext.str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
		if (*b == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
		memcpy(_decode_parameters, b, 32);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
		DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	} break;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   159
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   160
	case WE_RESIZE:
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   161
		w->vscroll.cap += e->sizing.diff.y / 24;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   162
		w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   163
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
static const Widget _new_aircraft_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   168
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   169
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   239,     0,    13, STR_A005_NEW_AIRCRAFT,		STR_018C_WINDOW_TITLE_DRAG_THIS},
893
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   170
{     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   227,    14,   109, 0x401,										STR_A025_AIRCRAFT_SELECTION_LIST},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   171
{  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   228,   239,    14,   109, 0x0,											STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   172
{     WWT_IMGBTN,     RESIZE_TB,    14,     0,   239,   110,   161, 0x0,											STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   173
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   114,   162,   173, STR_A006_BUILD_AIRCRAFT,	STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT},
893
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   174
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   115,   227,   162,   173, STR_A037_RENAME,					STR_A038_RENAME_AIRCRAFT_TYPE},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   175
{  WWT_RESIZEBOX,     RESIZE_TB,    14,   228,   239,   162,   173, 0x0,											STR_RESIZE_BUTTON},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   176
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
static const WindowDesc _new_aircraft_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	-1, -1, 240, 174,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
	WC_BUILD_VEHICLE,0,
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   182
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	_new_aircraft_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	NewAircraftWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
static void ShowBuildAircraftWindow(uint tile)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	DeleteWindowById(WC_BUILD_VEHICLE, tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
	w = AllocateWindowDesc(&_new_aircraft_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
	w->window_number = tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
	w->vscroll.cap = 4;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   196
	w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   197
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   198
	w->resize.step_height = 24;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
	if (tile != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
		w->caption_color = _map_owner[tile];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
		w->caption_color = _local_player;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   207
#define MAX_REFIT 0xFF
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   208
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 982
diff changeset
   209
const byte _aircraft_refit_normal[] = {
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   210
	CT_PASSENGERS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   211
	CT_MAIL,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   212
	CT_GOODS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   213
	CT_VALUABLES,
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 982
diff changeset
   214
	MAX_REFIT
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   215
};
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   216
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 982
diff changeset
   217
const byte _aircraft_refit_arctic[] = {
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   218
	CT_PASSENGERS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   219
	CT_MAIL,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   220
	CT_GOODS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   221
	CT_FOOD,
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 982
diff changeset
   222
	MAX_REFIT
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   223
};
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   224
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 982
diff changeset
   225
const byte _aircraft_refit_desert[] = {
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   226
	CT_PASSENGERS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   227
	CT_MAIL,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   228
	CT_FRUIT,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   229
	CT_GOODS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   230
	CT_DIAMONDS,
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 982
diff changeset
   231
	MAX_REFIT
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   232
};
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   233
1019
6bae6c11e865 (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 982
diff changeset
   234
const byte _aircraft_refit_candy[] = {
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   235
	CT_PASSENGERS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   236
	CT_SUGAR,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   237
	CT_TOYS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   238
	CT_CANDY,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   239
	CT_COLA,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   240
	CT_COTTON_CANDY,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   241
	CT_BUBBLES,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   242
	CT_TOFFEE,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   243
	CT_BATTERIES,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   244
	CT_PLASTIC,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   245
	CT_FIZZY_DRINKS,
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   246
	MAX_REFIT
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   247
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
const byte * const _aircraft_refit_types[4] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
	_aircraft_refit_normal, _aircraft_refit_arctic, _aircraft_refit_desert, _aircraft_refit_candy
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
924
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   253
#undef MAX_REFIT
6fbd4419db2a (svn r1412) -Feature/Fix: Aircraft refit options have been restricted to "sane"
celestar
parents: 922
diff changeset
   254
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
static void AircraftRefitWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
	case WE_PAINT: {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   259
		Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
		const byte *b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
		int sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
		int x,y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
		byte color;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
		int cargo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   266
		SetDParam(0, v->string_id);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   267
		SetDParam(1, v->unitnumber);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
		DrawString(1, 15, STR_A040_SELECT_CARGO_TYPE_TO_CARRY, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
381
527e47c8feec (svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents: 243
diff changeset
   272
		/* TODO: Support for custom GRFSpecial-specified refitting! --pasky */
527e47c8feec (svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents: 243
diff changeset
   273
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
		cargo = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
		x = 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
		y = 25;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
		sel = WP(w,refit_d).sel;
382
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   278
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   279
#define show_cargo(ctype) { \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   280
		color = 16; \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   281
		if (sel == 0) { \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   282
			cargo = ctype; \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   283
			color = 12; \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   284
		} \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   285
		sel--; \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   286
		DrawString(x, y, _cargoc.names_s[ctype], color); \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   287
		y += 10; \
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   288
		}
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   289
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   290
		if (_engine_refit_masks[v->engine_type]) {
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   291
			uint32 mask = _engine_refit_masks[v->engine_type];
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   292
			int cid = 0;
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   293
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   294
			for (; mask; mask >>= 1, cid++) {
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   295
				if (!(mask & 1)) // not this cid
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   296
					continue;
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   297
				if (!(_local_cargo_id_landscape[cid] & (1 << _opt.landscape))) // not in this landscape
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   298
					continue;
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   299
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   300
				show_cargo(_local_cargo_id_ctype[cid]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
			}
382
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   302
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   303
		} else { // generic refit list
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   304
			b = _aircraft_refit_types[_opt.landscape];
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   305
			do {
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   306
				show_cargo(*b);
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   307
			} while (*++b != 0xFF);
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   308
		}
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   309
9f80e5141ef1 (svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents: 381
diff changeset
   310
#undef show_cargo
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
		WP(w,refit_d).cargo = cargo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
		if (cargo != -1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
			int32 cost = DoCommandByTile(v->tile, v->index, cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
			if (cost != CMD_ERROR) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   317
				SetDParam(2, cost);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   318
				SetDParam(0, _cargoc.names_long_p[cargo]);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   319
				SetDParam(1, _aircraft_refit_capacity);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
				DrawString(1, 137, STR_A041_NEW_CAPACITY_COST_OF_REFIT, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
		case 2: { /* listbox */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
				int y = e->click.pt.y - 25;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
				if (y >= 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
					WP(w,refit_d).sel = y / 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
					SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
			} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
		case 4: /* refit button */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
			if (WP(w,refit_d).cargo != 0xFF) {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   338
				Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
				if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT)))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
					DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
		  break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
static const Widget _aircraft_refit_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   349
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,				STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   350
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   239,     0,    13, STR_A03C_REFIT,	STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   351
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   239,    14,   135, 0x0,							STR_A03E_SELECT_TYPE_OF_CARGO_FOR},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   352
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   239,   136,   157, 0x0,							STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   353
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   239,   158,   169, STR_A03D_REFIT_AIRCRAFT, STR_A03F_REFIT_AIRCRAFT_TO_CARRY},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   354
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
static const WindowDesc _aircraft_refit_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
	-1,-1, 240, 170,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
	WC_VEHICLE_REFIT,WC_VEHICLE_VIEW,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
	_aircraft_refit_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	AircraftRefitWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
static void ShowAircraftRefitWindow(Vehicle *v)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
	DeleteWindowById(WC_VEHICLE_REFIT, v->index);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
	_alloc_wnd_parent_num = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	w = AllocateWindowDesc(&_aircraft_refit_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
	w->window_number = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
	WP(w,refit_d).sel = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
	int mod;
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   381
	Vehicle *v = GetVehicle(w->window_number), *u;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
		w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   386
		if (!_patches.servint_aircraft) // disable service-scroller when interval is set to disabled
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   387
			w->disabled_state |= (1 << 5) | (1 << 6);
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   388
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   389
		SetDParam(0, v->string_id);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   390
		SetDParam(1, v->unitnumber);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
		/* Draw running cost */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
		{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
			int year = v->age / 366;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
			StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   398
			SetDParam(1, year);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
			str = STR_0199_YEAR;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
			if (year != 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
				str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
				if (v->max_age - 366 < v->age)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
					str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
			}
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   406
			SetDParam(0, str);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   407
			SetDParam(2, v->max_age / 366);
538
24fdb517fbe5 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents: 534
diff changeset
   408
			SetDParam(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
			DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
		/* Draw max speed */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
		{
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   414
			SetDParam(0, v->max_speed * 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
			DrawString(2, 25, STR_A00E_MAX_SPEED, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
		/* Draw profit */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
		{
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   420
			SetDParam(0, v->profit_this_year);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   421
			SetDParam(1, v->profit_last_year);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
			DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
		/* Draw breakdown & reliability */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
		{
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   427
			SetDParam(0, v->reliability * 100 >> 16);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   428
			SetDParam(1, v->breakdowns_since_last_service);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
			DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
		/* Draw service interval text */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
		{
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   434
			SetDParam(0, v->service_interval);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   435
			SetDParam(1, v->date_of_last_service);
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   436
			DrawString(13, 103, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
		DrawAircraftImage(v, 3, 57, INVALID_VEHICLE);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
		{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
			int y = 57;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
				if (v->subtype <= 2) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   446
					SetDParam(0, GetCustomEngineName(v->engine_type));
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   447
					SetDParam(1, 1920 + v->build_year);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   448
					SetDParam(2, v->value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
					DrawString(60, y, STR_A011_BUILT_VALUE, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
					y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   452
					SetDParam(0, _cargoc.names_long_p[v->cargo_type]);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   453
					SetDParam(1, v->cargo_cap);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
					u = v->next;
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   455
					SetDParam(2, _cargoc.names_long_p[u->cargo_type]);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   456
					SetDParam(3, u->cargo_cap);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
					DrawString(60, y, STR_A019_CAPACITY + (u->cargo_cap == 0), 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
					y += 14;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
				if (v->cargo_count != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
					/* Cargo names (fix pluralness) */
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   464
					SetDParam(0, v->cargo_type);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   465
					SetDParam(1, v->cargo_count);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   466
					SetDParam(2, v->cargo_source);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
					DrawString(60, y, STR_8813_FROM, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
					y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
			} while ( (v=v->next) != NULL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
		switch(e->click.widget) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
		case 2: /* rename */
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   478
			SetDParam(0, v->unitnumber);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
			ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
		case 5: /* increase int */
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   483
			mod = _ctrl_pressed? 5 : 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
			goto change_int;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
		case 6: /* decrease int */
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   486
			mod = _ctrl_pressed?- 5 : -10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
change_int:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
			mod += v->service_interval;
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   489
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   490
			/*	%-based service interval max 5%-90%
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   491
					day-based service interval max 30-800 days */
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   492
			mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1);
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   493
			if (mod == v->service_interval)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
				return;
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 10
diff changeset
   495
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
			DoCommandP(v->tile, v->index, mod, NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
				CMD_CHANGE_AIRCRAFT_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
	case WE_4:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
		if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
	case WE_ON_EDIT_TEXT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
		byte *b = e->edittext.str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
		if (*b == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
		memcpy(_decode_parameters, b, 32);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
		DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
static const Widget _aircraft_details_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   520
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   521
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   349,     0,    13, STR_A00C_DETAILS,	STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   522
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   350,   389,     0,    13, STR_01AA_NAME,			STR_A032_NAME_AIRCRAFT},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   523
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   389,    14,    55, 0x0,								STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   524
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   389,    56,   101, 0x0,								STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   525
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    10,   102,   107, STR_0188,					STR_884D_INCREASE_SERVICING_INTERVAL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   526
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    10,   108,   113, STR_0189,					STR_884E_DECREASE_SERVICING_INTERVAL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   527
{     WWT_IMGBTN,   RESIZE_NONE,    14,    11,   389,   102,   113, 0x0,								STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   528
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
static const WindowDesc _aircraft_details_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
	-1,-1, 390, 114,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
	WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
	_aircraft_details_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
	AircraftDetailsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
static void ShowAircraftDetailsWindow(Vehicle *v)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
	_alloc_wnd_parent_num = veh;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
	w = AllocateWindowDesc(&_aircraft_details_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
	w->window_number = veh;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
	w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
//	w->vscroll.cap = 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
//	w->traindetails_d.tab = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
static const Widget _aircraft_view_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   558
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   559
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   237,     0,    13, STR_A00A,	STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   560
{  WWT_STICKYBOX,   RESIZE_NONE,    14,   238,   249,     0,    13, 0x0,       STR_STICKY_BUTTON},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   561
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   231,    14,   103, 0x0,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   562
{          WWT_6,   RESIZE_NONE,    14,     2,   229,    16,   101, 0x0,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   563
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,     0,   249,   104,   115, 0x0,				STR_A027_CURRENT_AIRCRAFT_ACTION},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   564
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    14,    31, 0x2AB,			STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   565
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    32,    49, 0x2AF,			STR_A02A_SEND_AIRCRAFT_TO_HANGAR},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   566
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    50,    67, 0x2B4,			STR_A03B_REFIT_AIRCRAFT_TO_CARRY},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   567
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    68,    85, 0x2B2,			STR_A028_SHOW_AIRCRAFT_S_ORDERS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   568
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,   232,   249,    86,   103, 0x2B3,			STR_A02B_SHOW_AIRCRAFT_DETAILS},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   569
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
static void AircraftViewWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
	case WE_PAINT: {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   576
		Vehicle *v = GetVehicle(w->window_number);
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   577
		uint32 disabled = 1<<8;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
		StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
		{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
			uint tile = v->tile;
1035
812f837ee03f (svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents: 1024
diff changeset
   582
			if (IsTileType(tile, MP_STATION) &&
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
					(_map5[tile] == 32 || _map5[tile] == 65) &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
					v->vehstatus&VS_STOPPED)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
						disabled = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
		if (v->owner != _local_player)
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   589
			disabled |= 1<<8 | 1<<7;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
		w->disabled_state = disabled;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
		/* draw widgets & caption */
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   593
		SetDParam(0, v->string_id);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   594
		SetDParam(1, v->unitnumber);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
		/* draw the flag */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
		DrawSprite((v->vehstatus & VS_STOPPED) ? 0xC12  : 0xC13, 2, 105);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
		if (v->vehstatus & VS_CRASHED) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
			str = STR_8863_CRASHED;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
		} else if (v->vehstatus & VS_STOPPED) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
			str = STR_8861_STOPPED;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
		} else {
555
02df8a1b7f33 (svn r955) Replace uint16 for orders with struct Order
tron
parents: 543
diff changeset
   605
			switch (v->current_order.type) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
			case OT_GOTO_STATION: {
555
02df8a1b7f33 (svn r955) Replace uint16 for orders with struct Order
tron
parents: 543
diff changeset
   607
				SetDParam(0, v->current_order.station);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   608
				SetDParam(1, v->cur_speed * 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
			} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
			case OT_GOTO_DEPOT: {
555
02df8a1b7f33 (svn r955) Replace uint16 for orders with struct Order
tron
parents: 543
diff changeset
   613
				SetDParam(0, v->current_order.station);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   614
				SetDParam(1, v->cur_speed * 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
				str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
			} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
			case OT_LOADING:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
				str = STR_882F_LOADING_UNLOADING;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
			default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
				if (v->num_orders == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
					str = STR_NO_ORDERS + _patches.vehicle_speed;
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   625
					SetDParam(0, v->cur_speed * 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
				} else
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
					str = STR_EMPTY;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
		DrawStringCentered(125, 105, str, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
		DrawWindowViewport(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
	case WE_CLICK: {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   637
		Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		switch(e->click.widget) {
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   640
		case 5: /* start stop */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
			break;
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   643
		case 6: /* center main view */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
			ScrollMainWindowTo(v->x_pos, v->y_pos);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
			break;
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   646
		case 7: /* goto hangar */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
			DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
			break;
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   649
		case 8: /* refit */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
			ShowAircraftRefitWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
			break;
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   652
		case 9: /* show orders */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
			ShowOrdersWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
			break;
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   655
		case 10: /* show details */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
			ShowAircraftDetailsWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
	case WE_DESTROY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
		DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   663
		DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   664
		DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
static const WindowDesc _aircraft_view_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
	-1,-1, 250, 116,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
	WC_VEHICLE_VIEW ,0,
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   673
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
	_aircraft_view_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
	AircraftViewWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
void ShowAircraftViewWindow(Vehicle *v)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
	w = AllocateWindowDescFront(&_aircraft_view_desc, v->index);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
	if (w) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
		w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   690
static void DrawAircraftDepotWindow(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
	uint tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
	Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
	int num,x,y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   695
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
	tile = w->window_number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
	/* setup disabled buttons */
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   699
	w->disabled_state = (_map_owner[tile]==_local_player) ? 0 : ((1<<4)|(1<<7));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
	/* determine amount of items for scroller */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
	num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
	FOR_ALL_VEHICLES(v) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
		if (v->type == VEH_Aircraft && v->subtype <= 2 && v->vehstatus&VS_HIDDEN &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
				v->tile == (TileIndex)tile)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
					num++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
	}
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   708
	SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   710
	SetDParam(0, _map2[tile]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
	x = 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
	y = 15;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   715
	num = w->vscroll.pos * w->hscroll.cap;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
	FOR_ALL_VEHICLES(v) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
		if (v->type == VEH_Aircraft &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
				v->subtype <= 2 &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   720
				v->vehstatus&VS_HIDDEN &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   721
				v->tile == (TileIndex)tile &&
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   722
				--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   723
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
			DrawAircraftImage(v, x+12, y, WP(w,traindepot_d).sel);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   726
			SetDParam(0, v->unitnumber);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
			DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   728
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
			DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y+12);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   730
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   731
			if ((x+=74) == 2 + 74 * w->hscroll.cap) {
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   732
				x = 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
				y += 24;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   734
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   735
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **veh) {
969
862685f513ca (svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents: 968
diff changeset
   740
	uint xt,row,xm,ym;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
	Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
	uint tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
	int pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
	xt = x / 74;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
	xm = x % 74;
971
374251680a61 (svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents: 969
diff changeset
   747
	if (xt >= w->hscroll.cap)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
		return 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
969
862685f513ca (svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents: 968
diff changeset
   750
	row = (y - 14) / 24;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
	ym = (y - 14) % 24;
969
862685f513ca (svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents: 968
diff changeset
   752
	if (row >= w->vscroll.cap)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   753
		return 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   754
971
374251680a61 (svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents: 969
diff changeset
   755
	pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   756
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   757
	tile = w->window_number;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
	FOR_ALL_VEHICLES(v) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   759
		if (v->type == VEH_Aircraft &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   760
				v->subtype <= 2 &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
				v->vehstatus&VS_HIDDEN &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
				v->tile == (TileIndex)tile &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   763
				--pos < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
					*veh = v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
					if (xm >= 12)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
						return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   767
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
					if (ym <= 12)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
						return -1; /* show window */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   771
					return -2; /* start stop */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
	return 1; /* outside */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   775
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
static void AircraftDepotClickAircraft(Window *w, int x, int y)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   778
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   779
	Vehicle *v;
10
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   780
	int mode = GetVehicleFromAircraftDepotWndPt(w, x, y, &v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   781
10
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   782
	// share / copy orders
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   783
	if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = v; return; }
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   784
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   785
	switch(mode) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   786
	case 1:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   787
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
10
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   789
	case 0: // start dragging of vehicle
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   790
		if (v != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   791
			WP(w,traindepot_d).sel = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
			SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetAircraftImage(v, 6), 4, w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   795
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   796
10
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   797
	case -1: // show info window
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   798
		ShowAircraftViewWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   799
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   800
10
c35ab8426202 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents: 0
diff changeset
   801
	case -2: // click start/stop flag
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   802
		DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   803
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
	default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   806
		NOT_REACHED();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
static void AircraftDepotWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   811
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   812
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   814
		DrawAircraftDepotWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   816
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   817
	case WE_CLICK:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   818
		switch(e->click.widget) {
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   819
		case 5: /* click aircraft */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   820
			AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   821
			break;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   822
		case 7: /* show build aircraft window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
			ShowBuildAircraftWindow(w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   824
			break;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   825
		case 8: /* scroll to tile */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   826
			ScrollMainWindowToTile(w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   827
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   828
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   829
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   830
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
	case WE_DESTROY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   832
		DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   833
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   834
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   835
	case WE_DRAGDROP: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   836
		switch(e->click.widget) {
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   837
		case 5: {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   838
			Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   839
			VehicleID sel = WP(w,traindepot_d).sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   840
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   841
			WP(w,traindepot_d).sel = INVALID_VEHICLE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   842
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
			if (GetVehicleFromAircraftDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   845
					v != NULL &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   846
					sel == v->index) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
				ShowAircraftViewWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   848
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   849
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   850
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   851
		case 4:
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   852
			if (!HASBIT(w->disabled_state, 4) &&
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
					WP(w,traindepot_d).sel != INVALID_VEHICLE)	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
				Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   856
				HandleButtonClick(w, 4);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   857
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   858
				v = GetVehicle(WP(w,traindepot_d).sel);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   859
				WP(w,traindepot_d).sel = INVALID_VEHICLE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   860
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   861
				_backup_orders_tile = v->tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
				BackupVehicleOrders(v, _backup_orders_data);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   863
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   864
				if (!DoCommandP(v->tile, v->index, 0, NULL,  CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT)))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   865
					_backup_orders_tile = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   866
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   867
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   868
		default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   869
			WP(w,traindepot_d).sel = INVALID_VEHICLE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   870
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   871
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   872
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   873
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   874
	break;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   875
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   876
	case WE_RESIZE:
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   877
		w->vscroll.cap += e->sizing.diff.y / 24;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   878
		w->hscroll.cap += e->sizing.diff.x / 74;
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   879
		w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   880
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   881
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   882
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   883
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   884
static const Widget _aircraft_depot_widgets[] = {
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   885
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,									STR_018B_CLOSE_WINDOW},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   886
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   318,     0,    13, STR_A002_AIRCRAFT_HANGAR,	STR_018C_WINDOW_TITLE_DRAG_THIS},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   887
{  WWT_STICKYBOX,     RESIZE_LR,    14,   319,   330,     0,    13, 0x0,											STR_STICKY_BUTTON},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   888
{      WWT_PANEL,    RESIZE_LRB,    14,   296,   318,    14,    13, 0x0,													STR_NULL},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   889
{     WWT_IMGBTN,   RESIZE_LRTB,    14,   296,   318,    14,    61, 0x2A9,										STR_A023_DRAG_AIRCRAFT_TO_HERE_TO},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   890
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   891
{     WWT_MATRIX,     RESIZE_RB,    14,     0,   295,    14,    61, 0x204,										STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   892
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   319,   330,    14,    61, 0x0,											STR_0190_SCROLL_BAR_SCROLLS_LIST},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   893
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   159,    62,    73, STR_A003_NEW_AIRCRAFT,		STR_A022_BUILD_NEW_AIRCRAFT},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   894
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   160,   318,    62,    73, STR_00E4_LOCATION,				STR_A024_CENTER_MAIN_VIEW_ON_HANGAR},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   895
{      WWT_PANEL,    RESIZE_RTB,    14,   319,   318,    62,    73, 0x0,													STR_NULL},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   896
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   319,   330,    62,    73, 0x0,											STR_RESIZE_BUTTON},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   897
{   WIDGETS_END},
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 971
diff changeset
   898
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   899
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   900
static const WindowDesc _aircraft_depot_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   901
	-1, -1, 331, 74,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   902
	WC_VEHICLE_DEPOT,0,
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   903
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   904
	_aircraft_depot_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
	AircraftDepotWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
void ShowAircraftDepotWindow(uint tile)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   911
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   912
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   913
	w = AllocateWindowDescFront(&_aircraft_depot_desc, tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   914
	if (w) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   915
		w->caption_color = _map_owner[tile];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
		w->vscroll.cap = 2;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   917
		w->hscroll.cap = 4;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   918
		w->resize.step_width = 74;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   919
		w->resize.step_height = 24;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   920
		WP(w,traindepot_d).sel = INVALID_VEHICLE;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   921
		_backup_orders_tile = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   922
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   923
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   924
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   925
static void DrawSmallOrderList(Vehicle *v, int x, int y) {
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   926
	const Order *order;
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   927
	int sel, i = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   928
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   929
	sel = v->cur_order_index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   931
	FOR_VEHICLE_ORDERS(v, order) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   932
		if (sel == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
			_stringwidth_base = 0xE0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   934
			DoDrawString( "\xAF", x-6, y, 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   935
			_stringwidth_base = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   936
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   937
		sel--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   938
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   939
		if (order->type == OT_GOTO_STATION) {
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   940
			SetDParam(0, order->station);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   941
			DrawString(x, y, STR_A036, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   943
			y += 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   944
			if (++i == 4)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   945
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   946
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   947
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   948
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   949
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 193
diff changeset
   950
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   951
static const Widget _player_aircraft_widgets[] = {
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   952
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   953
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   247,     0,    13, STR_A009_AIRCRAFT,			STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   954
{  WWT_STICKYBOX,     RESIZE_LR,    14,   248,   259,     0,    13, 0x0,                   STR_STICKY_BUTTON},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   955
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_ORDER_TIP},
893
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   956
{      WWT_PANEL,   RESIZE_NONE,    14,    81,   235,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   957
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,   236,   247,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   958
{      WWT_PANEL,  RESIZE_RIGHT,    14,   248,   259,    14,    25, 0x0,										STR_NULL},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   959
{     WWT_MATRIX,     RESIZE_RB,    14,     0,   247,    26,   169, 0x401,									STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   960
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   248,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   961
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   124,   170,   181, STR_A003_NEW_AIRCRAFT,	STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES},
893
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   962
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   125,   247,   170,   181, STR_REPLACE_VEHICLES,						STR_REPLACE_HELP},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   963
{      WWT_PANEL,    RESIZE_RTB,    14,   248,   247,   170,   181, 0x0,											STR_NULL},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   964
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   248,   259,   170,   181, 0x0,											STR_RESIZE_BUTTON},
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   965
{   WIDGETS_END},
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   966
};
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
   967
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   968
static const Widget _other_player_aircraft_widgets[] = {
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   969
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   970
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   247,     0,    13, STR_A009_AIRCRAFT,			STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   971
{  WWT_STICKYBOX,     RESIZE_LR,    14,   248,   259,     0,    13, 0x0,                   STR_STICKY_BUTTON},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   972
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_ORDER_TIP},
893
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   973
{      WWT_PANEL,   RESIZE_NONE,    14,    81,   235,    14,    25, 0x0,										STR_SORT_CRITERIA_TIP},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   974
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,   236,   247,    14,    25, STR_0225,							STR_SORT_CRITERIA_TIP},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   975
{      WWT_PANEL,  RESIZE_RIGHT,    14,   248,   259,    14,    25, 0x0,										STR_NULL},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   976
{     WWT_MATRIX,     RESIZE_RB,    14,     0,   247,    26,   169, 0x401,									STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   977
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   248,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   978
{      WWT_PANEL,    RESIZE_RTB,    14,     0,   247,   170,   181, 0x0,											STR_NULL},
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 886
diff changeset
   979
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   248,   259,   170,   181, 0x0,											STR_RESIZE_BUTTON},
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   980
{   WIDGETS_END},
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   981
};
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
   982
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   983
static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   984
{
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   985
	int station = (int)w->window_number >> 16;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   986
	int owner = w->window_number & 0xff;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   987
	vehiclelist_d *vl = &WP(w, vehiclelist_d);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   988
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   989
	switch(e->event) {
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
   990
	case WE_PAINT: {
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   991
		int x = 2;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   992
		int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   993
		int max;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   994
		int i;
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 193
diff changeset
   995
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   996
		BuildVehicleList(vl, VEH_Aircraft, owner, station);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   997
		SortVehicleList(vl);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   998
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
   999
		SetVScrollCount(w, vl->list_length);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1000
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1001
		// disable 'Sort By' tooltip on Unsorted sorting criteria
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1002
		if (vl->sort_type == SORT_BY_UNSORTED)
757
7bfd863750a7 (svn r1213) -Feature: Stickified vehicle lists
darkvater
parents: 755
diff changeset
  1003
			w->disabled_state |= (1 << 3);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1004
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1005
		/* draw the widgets */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
		{
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1007
			const Player *p = DEREF_PLAYER(owner);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1008
			if (station == -1) {
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1009
				/* Company Name -- (###) Aircraft */
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1010
				SetDParam(0, p->name_1);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1011
				SetDParam(1, p->name_2);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1012
				SetDParam(2, w->vscroll.count);
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1013
				w->widget[1].unkA = STR_A009_AIRCRAFT;
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1014
			} else {
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1015
				/* Station Name -- (###) Aircraft */
1294
4cdf0e76c093 (svn r1798) GetFoo(i)->index is per definition i, so replace the former with the latter
tron
parents: 1246
diff changeset
  1016
				SetDParam(0, station);
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1017
				SetDParam(1, w->vscroll.count);
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1018
				w->widget[1].unkA = STR_SCHEDULED_AIRCRAFT;
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1019
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1020
			DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1021
		}
168
79f9ed5b23e6 (svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents: 164
diff changeset
  1022
		/* draw sorting criteria string */
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1023
		DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1024
		/* draw arrow pointing up/down for ascending/descending sorting */
1246
eb66ff34348f (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents: 1209
diff changeset
  1025
		DoDrawString(vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1026
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1027
		max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1028
		for (i = w->vscroll.pos; i < max; ++i) {
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
  1029
			Vehicle *v = GetVehicle(vl->sort_list[i].index);
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1030
			StringID str;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1031
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1032
			assert(v->type == VEH_Aircraft && v->subtype <= 2);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1033
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1034
			DrawAircraftImage(v, x + 19, y + 6, INVALID_VEHICLE);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1035
			DrawVehicleProfitButton(v, x, y + 13);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1036
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1037
			SetDParam(0, v->unitnumber);
1055
cc4f60cc9102 (svn r1556) -Fix: Vehicle list updates should now really work
Celestar
parents: 1035
diff changeset
  1038
			if (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_HIDDEN))
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1039
				str = STR_021F;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1040
			else
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1041
				str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1042
			DrawString(x, y + 2, str, 0);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1043
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1044
			SetDParam(0, v->profit_this_year);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1045
			SetDParam(1, v->profit_last_year);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1046
			DrawString(x + 19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1047
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1048
			if (v->string_id != STR_SV_AIRCRAFT_NAME) {
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1049
				SetDParam(0, v->string_id);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1050
				DrawString(x + 19, y, STR_01AB, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1051
			}
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1052
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
  1053
			DrawSmallOrderList(v, x + 136, y);
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1054
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1055
			y += PLY_WND_PRC__SIZE_OF_ROW_BIG;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1056
		}
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1057
		}	break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1059
	case WE_CLICK: {
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1060
		switch(e->click.widget) {
757
7bfd863750a7 (svn r1213) -Feature: Stickified vehicle lists
darkvater
parents: 755
diff changeset
  1061
		case 3: /* Flip sorting method ascending/descending */
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1062
			vl->flags ^= VL_DESC;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1063
			vl->flags |= VL_RESORT;
1246
eb66ff34348f (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents: 1209
diff changeset
  1064
			_sorting.aircraft.order = !!(vl->flags & VL_DESC);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1065
			SetWindowDirty(w);
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1066
			break;
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1067
757
7bfd863750a7 (svn r1213) -Feature: Stickified vehicle lists
darkvater
parents: 755
diff changeset
  1068
		case 4: case 5:/* Select sorting criteria dropdown menu */
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
  1069
			ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1070
			return;
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1071
757
7bfd863750a7 (svn r1213) -Feature: Stickified vehicle lists
darkvater
parents: 755
diff changeset
  1072
		case 7: { /* Matrix to show vehicles */
174
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 168
diff changeset
  1073
			uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1074
174
bd79fb899824 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents: 168
diff changeset
  1075
			if (id_v >= w->vscroll.cap) { return;} // click out of bounds
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1076
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1077
			id_v += w->vscroll.pos;
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1078
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1079
			{
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1080
				Vehicle *v;
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1081
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1082
				if (id_v >= vl->list_length) return; // click out of list bound
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1083
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
  1084
				v = GetVehicle(vl->sort_list[id_v].index);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1085
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1086
				assert(v->type == VEH_Aircraft && v->subtype <= 2);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1087
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1088
				ShowAircraftViewWindow(v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1089
			}
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1090
		} break;
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1091
757
7bfd863750a7 (svn r1213) -Feature: Stickified vehicle lists
darkvater
parents: 755
diff changeset
  1092
		case 9: { /* Build new Vehicle */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1093
			uint tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1094
886
3f8be7ff7b9c (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents: 867
diff changeset
  1095
			if (!IsWindowOfPrototype(w, _player_aircraft_widgets))
3f8be7ff7b9c (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents: 867
diff changeset
  1096
				break;
3f8be7ff7b9c (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents: 867
diff changeset
  1097
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1098
			tile = _last_built_aircraft_depot_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1099
			do {
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1100
				if (_map_owner[tile] == _local_player && IsAircraftHangarTile(tile)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1101
					ShowAircraftDepotWindow(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
					ShowBuildAircraftWindow(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1103
					return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1104
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1105
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1106
				tile = TILE_MASK(tile + 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1107
			} while(tile != _last_built_aircraft_depot_tile);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1108
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1109
			ShowBuildAircraftWindow(0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1110
		} break;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1111
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1112
		case 10:
886
3f8be7ff7b9c (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents: 867
diff changeset
  1113
			if (!IsWindowOfPrototype(w, _player_aircraft_widgets))
3f8be7ff7b9c (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents: 867
diff changeset
  1114
				break;
3f8be7ff7b9c (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents: 867
diff changeset
  1115
842
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
  1116
			ShowReplaceVehicleWindow(VEH_Aircraft);
efc3546bc313 (svn r1323) Adding autoreplace feature
bjarni
parents: 767
diff changeset
  1117
			break;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1118
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1119
		}
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1120
	}	break;
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1121
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1122
	case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1123
		if (vl->sort_type != e->dropdown.index) {
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1124
			// value has changed -> resort
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1125
			vl->flags |= VL_RESORT;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1126
			vl->sort_type = e->dropdown.index;
1246
eb66ff34348f (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents: 1209
diff changeset
  1127
			_sorting.aircraft.criteria = vl->sort_type;
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1128
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1129
			// enable 'Sort By' if a sorter criteria is chosen
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1130
			if (vl->sort_type != SORT_BY_UNSORTED)
1246
eb66ff34348f (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents: 1209
diff changeset
  1131
				CLRBIT(w->disabled_state, 3);
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1132
		}
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1133
		SetWindowDirty(w);
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1134
		break;
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1135
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1136
	case WE_CREATE: /* set up resort timer */
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1137
		vl->sort_list = NULL;
1246
eb66ff34348f (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents: 1209
diff changeset
  1138
		vl->flags = VL_REBUILD | (_sorting.aircraft.order << (VL_DESC - 1));
eb66ff34348f (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents: 1209
diff changeset
  1139
		vl->sort_type = _sorting.aircraft.criteria;
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1140
		vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1141
		break;
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1142
767
27edbcad701c (svn r1232) Plug memory leak
tron
parents: 757
diff changeset
  1143
	case WE_DESTROY:
27edbcad701c (svn r1232) Plug memory leak
tron
parents: 757
diff changeset
  1144
		free(vl->sort_list);
27edbcad701c (svn r1232) Plug memory leak
tron
parents: 757
diff changeset
  1145
		break;
27edbcad701c (svn r1232) Plug memory leak
tron
parents: 757
diff changeset
  1146
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1147
	case WE_TICK: /* resort the list every 20 seconds orso (10 days) */
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1148
		if (--vl->resort_timer == 0) {
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1149
			DEBUG(misc, 1) ("Periodic resort aircraft list player %d station %d",
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1150
				owner, station);
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1151
			vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1152
			vl->flags |= VL_RESORT;
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1153
			SetWindowDirty(w);
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1154
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1155
		break;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1156
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1157
	case WE_RESIZE:
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1158
		/* Update the scroll + matrix */
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1159
		w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_BIG;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1160
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1161
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1162
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1163
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1164
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1165
static const WindowDesc _player_aircraft_desc = {
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1166
	-1, -1, 260, 182,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1167
	WC_AIRCRAFT_LIST,0,
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1168
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1169
	_player_aircraft_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1170
	PlayerAircraftWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1171
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1172
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1173
static const WindowDesc _other_player_aircraft_desc = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1174
	-1, -1, 260, 182,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1175
	WC_AIRCRAFT_LIST,0,
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1176
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1177
	_other_player_aircraft_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1178
	PlayerAircraftWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1179
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1180
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1181
void ShowPlayerAircraft(int player, int station)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1182
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1183
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1184
164
0cbdf3c9bde1 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents: 156
diff changeset
  1185
	if (player == _local_player) {
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1186
		w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1187
	} else  {
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 555
diff changeset
  1188
		w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1189
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1190
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1191
	if (w) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1192
		w->caption_color = w->window_number;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1193
		w->vscroll.cap = 4;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1194
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1195
		w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1196
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1197
}