order_gui.c
author tron
Sat, 29 Jan 2005 15:12:40 +0000
changeset 1214 33e07bbb7779
parent 1209 a1ac96655b79
child 1242 bd3e74f757b4
permissions -rw-r--r--
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
This makes it necessary to rename TileType() to GetTileType() because a type and a function may not share the same name.
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"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 395
diff changeset
     3
#include "table/strings.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 560
diff changeset
     4
#include "map.h"
1209
a1ac96655b79 (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: 1095
diff changeset
     5
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include "gfx.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 "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "town.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 "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
static int OrderGetSel(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
{
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
    17
	Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
	int num = WP(w,order_d).sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    20
	if (num < 0 || num > v->num_orders)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    21
		return v->num_orders;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    23
	return num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
static void DrawOrdersWindow(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    28
	const Vehicle *v;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    29
	const Order *order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    30
	StringID str;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    31
	int sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	int y, i;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    33
	bool shared_orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    34
	byte color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
    36
	v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    38
	w->disabled_state = (v->owner == _local_player) ? 0 : (
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    39
		1 << 4 |   //skip
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    40
		1 << 5 |   //delete
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    41
		1 << 6 |   //non-stop
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    42
		1 << 7 |   //go-to
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    43
		1 << 8 |   //full load
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    44
		1 << 9     //unload
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    45
		);
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
    46
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    47
	//disable non-stop for non-trains
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    48
	if (v->type != VEH_Train) {
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    49
		w->disabled_state |= 1 << 6;
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    50
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    52
	shared_orders = IsOrderListShared(v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    54
	if ((uint)v->num_orders + shared_orders <= (uint)WP(w,order_d).sel)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
		SETBIT(w->disabled_state, 5); /* delete */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    57
	if (v->num_orders == 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
		SETBIT(w->disabled_state, 4); /* skip */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    60
	SetVScrollCount(w, v->num_orders + 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	sel = OrderGetSel(w);
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    63
	SetDParam(2, STR_8827_FULL_LOAD);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    64
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    65
	order = GetVehicleOrder(v, sel);
725
d6543c8b2428 (svn r1177) Enable non-stop flag for waypoints
tron
parents: 679
diff changeset
    66
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    67
	if (order != NULL) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    68
		switch (order->type) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    69
			case OT_GOTO_STATION:
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    70
				break;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    71
			case OT_GOTO_DEPOT:
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    72
				SETBIT(w->disabled_state, 9);	/* unload */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    73
				SetDParam(2,STR_SERVICE);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    74
				break;
725
d6543c8b2428 (svn r1177) Enable non-stop flag for waypoints
tron
parents: 679
diff changeset
    75
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    76
			case OT_GOTO_WAYPOINT:
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    77
				SETBIT(w->disabled_state, 8); /* full load */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    78
				SETBIT(w->disabled_state, 9); /* unload */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    79
				break;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    80
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    81
			default:
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    82
				SETBIT(w->disabled_state, 6); /* nonstop */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    83
				SETBIT(w->disabled_state, 8);	/* full load */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    84
				SETBIT(w->disabled_state, 9);	/* unload */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    85
		}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    86
	} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
		SETBIT(w->disabled_state, 6); /* nonstop */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
		SETBIT(w->disabled_state, 8);	/* full load */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    89
		SETBIT(w->disabled_state, 9);	/* unload */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    92
	SetDParam(0, v->string_id);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
    93
	SetDParam(1, v->unitnumber);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    98
	i = w->vscroll.pos;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    99
	order = GetVehicleOrder(v, i);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   100
	while (order != NULL) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   101
		str = (v->cur_order_index == i) ? STR_8805 : STR_8804;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   103
		if (i - w->vscroll.pos < 6) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   104
			SetDParam(1, 6);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   105
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   106
			if (order->type == OT_GOTO_STATION) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   107
				SetDParam(1, STR_8806_GO_TO + (order->flags >> 1));
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   108
				SetDParam(2, order->station);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   109
			} else if (order->type == OT_GOTO_DEPOT) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   110
				StringID s = STR_NULL;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   111
				if (v->type == VEH_Aircraft) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   112
					s = STR_GO_TO_AIRPORT_HANGAR;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   113
					SetDParam(2, order->station);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   114
				} else {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   115
					SetDParam(2, _depots[order->station].town_index);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   116
					switch (v->type) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   117
						case VEH_Train: s = STR_880E_GO_TO_TRAIN_DEPOT;   break;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   118
						case VEH_Road:  s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   119
						case VEH_Ship:  s = STR_GO_TO_SHIP_DEPOT;         break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
				}
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   122
				if (v->type == VEH_Train && order->flags & OF_NON_STOP)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   123
					s += 2;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   124
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   125
				if (order->flags & OF_FULL_LOAD)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   126
					s++; /* XXX service */
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   127
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   128
				SetDParam(1, s);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   129
			} else if (order->type == OT_GOTO_WAYPOINT) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   130
				SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   131
				SetDParam(2, order->station);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
			}
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   133
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   134
			color = (i == WP(w,order_d).sel) ? 0xC : 0x10;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   135
			SetDParam(0, i + 1);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   136
			if (order->type != OT_DUMMY) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   137
				DrawString(2, y, str, color);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   138
			} else {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   139
				SetDParam(1, STR_INVALID_ORDER);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   140
				SetDParam(2, order->station);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   141
				DrawString(2, y, str, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
		}
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
		i++;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   147
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   148
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   150
	if (i - w->vscroll.pos < 6) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   151
		str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   152
		color = (i == WP(w,order_d).sel) ? 0xC : 0x10;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   153
		DrawString(2, y, str, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
// lookup a vehicle on a tile
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
typedef struct {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
	TileIndex tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	byte owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	byte type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
} FindVehS;
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
static void *FindVehicleCallb(Vehicle *v, FindVehS *f)
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
	if (v->tile != f->tile || v->owner != f->owner || v->vehstatus & VS_HIDDEN ) return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	return v;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   169
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
1095
90220990fd7c (svn r1596) Add some more statics
tron
parents: 1081
diff changeset
   171
static Vehicle *GetVehicleOnTile(TileIndex tile, byte owner)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
{
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 725
diff changeset
   173
	FindVehS fs;
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 725
diff changeset
   174
	fs.tile = tile;
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 725
diff changeset
   175
	fs.owner = owner;
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 725
diff changeset
   176
	fs.type = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
	return VehicleFromPos(tile, &fs, (VehicleFromPosProc*)FindVehicleCallb);
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
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   180
static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
{
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   182
	Order order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	Station *st;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	int st_index;
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
	// check depot first
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
	if (_patches.gotodepot) {
1214
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   188
		switch (GetTileType(tile)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
		case MP_RAILWAY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
			if (v->type == VEH_Train && _map_owner[tile] == _local_player) {
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   191
				if ((_map5[tile]&0xFC)==0xC0) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   192
					order.type = OT_GOTO_DEPOT;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   193
					order.flags = OF_UNLOAD;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   194
					order.station = GetDepotByTile(tile);
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   195
					return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   196
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
			break;
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
		case MP_STREET:
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   201
			if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   202
				order.type = OT_GOTO_DEPOT;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   203
				order.flags = OF_UNLOAD;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   204
				order.station = GetDepotByTile(tile);
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   205
				return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   206
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
		case MP_STATION:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
			if (v->type != VEH_Aircraft) break;
559
2003549c0ddb (svn r961) Fixed a problem with the new order system due to missing '{}'
Celestar
parents: 558
diff changeset
   211
			if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   212
				order.type = OT_GOTO_DEPOT;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   213
				order.flags = OF_UNLOAD | OF_NON_STOP;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   214
				order.station = _map2[tile];
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   215
				return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   216
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
		case MP_WATER:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
			if (v->type != VEH_Ship) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
			if ( IsShipDepotTile(tile) && _map_owner[tile] == _local_player) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
				switch (_map5[tile]) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
				case 0x81: tile--; break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
				case 0x83: tile-= TILE_XY(0,1); break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
				}
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   226
				order.type = OT_GOTO_DEPOT;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   227
				order.flags = OF_UNLOAD;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   228
				order.station = GetDepotByTile(tile);
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   229
				return order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
			}
1214
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   231
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   232
			default:
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   233
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
395
4c990f33dab7 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 319
diff changeset
   237
	// check waypoint
1035
0a170deb6e33 (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
   238
	if (IsTileType(tile, MP_RAILWAY)
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   239
	&& v->type == VEH_Train
319
1891d07574d6 (svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents: 193
diff changeset
   240
	&& _map_owner[tile] == _local_player
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   241
	&& (_map5[tile]&0xFE)==0xC4) {
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   242
		order.type = OT_GOTO_WAYPOINT;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   243
		order.flags = 0;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   244
		order.station = GetWaypointByTile(tile);
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   245
		return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   246
	}
319
1891d07574d6 (svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents: 193
diff changeset
   247
1035
0a170deb6e33 (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
   248
	if (IsTileType(tile, MP_STATION)) {
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   249
		st = GetStation(st_index = _map2[tile]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
		if (st->owner == _current_player || st->owner == OWNER_NONE) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
			byte facil;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
			(facil=FACIL_DOCK, v->type == VEH_Ship) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
			(facil=FACIL_TRAIN, v->type == VEH_Train) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
			(facil=FACIL_AIRPORT, v->type == VEH_Aircraft) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
			(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
			(facil=FACIL_TRUCK_STOP, 1);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   258
			if (st->facilities & facil) {
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   259
				order.type = OT_GOTO_STATION;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   260
				order.flags = 0;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   261
				order.station = st_index;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   262
				return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   263
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
	// not found
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   268
	order.type = OT_NOTHING;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   269
	order.flags = 0;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   270
	return order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	if (u->type != v->type)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
1067
a083a6dd1419 (svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents: 1043
diff changeset
   278
	if (u->type == VEH_Train && u->subtype != TS_Front_Engine) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
		u = GetFirstVehicleInChain(u);
1067
a083a6dd1419 (svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents: 1043
diff changeset
   280
		if (u->subtype != TS_Front_Engine)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
			return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
	// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
	if (v->num_orders != 0 && _ctrl_pressed == 0) {return false;}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   287
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
		_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
		WP(w,order_d).sel = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
{
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   299
	Order cmd;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
	Vehicle *u;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   301
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
	// check if we're clicking on a vehicle first.. clone orders in that case.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	u = CheckMouseOverVehicle();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
	if (u && HandleOrderVehClick(v, u, w))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
		return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
	cmd = GetOrderCmdFromTile(v, tile);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   308
	if (cmd.type == OT_NOTHING) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   310
	if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
		if (WP(w,order_d).sel != -1)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
			WP(w,order_d).sel++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   317
static void OrderClick_Goto(Window *w, Vehicle *v)
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   318
{
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   319
	InvalidateWidget(w, 7);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   320
	TOGGLEBIT(w->click_state, 7);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   321
	if (HASBIT(w->click_state, 7)) {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   322
		_place_clicked_vehicle = NULL;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   323
		SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, 1, w);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   324
	} else {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   325
		ResetObjectToPlace();
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   326
	}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   327
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   328
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   329
static void OrderClick_FullLoad(Window *w, Vehicle *v)
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   330
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   331
	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_FULL_LOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   332
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   333
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   334
static void OrderClick_Unload(Window *w, Vehicle *v)
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   335
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   336
	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_UNLOAD,    NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   337
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   338
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   339
static void OrderClick_Nonstop(Window *w, Vehicle *v)
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   340
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   341
	DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_NON_STOP,  NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   342
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   343
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   344
static void OrderClick_Skip(Window *w, Vehicle *v)
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   345
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   346
	DoCommandP(v->tile, v->index, 0, NULL, CMD_SKIP_ORDER);
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   347
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   348
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   349
static void OrderClick_Delete(Window *w, Vehicle *v)
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   350
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   351
	DoCommandP(v->tile, v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER));
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   352
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   353
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   354
typedef void OnButtonClick(Window *w, Vehicle *v);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   355
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   356
static OnButtonClick * const _order_button_proc[] = {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   357
	OrderClick_Skip,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   358
	OrderClick_Delete,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   359
	OrderClick_Nonstop,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   360
	OrderClick_Goto,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   361
	OrderClick_FullLoad,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   362
	OrderClick_Unload
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   363
};
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   364
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   365
static const uint16 _order_keycodes[] = {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   366
	'D', //skip order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   367
	'F', //delete order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   368
	'G', //non-stop
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   369
	'H', //goto order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   370
	'J', //full load
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   371
	'K'  //unload
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   372
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
static void OrdersWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
	switch(e->event) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
		DrawOrdersWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
	case WE_CLICK: {
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   382
		Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
		switch(e->click.widget) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   384
		case 2:	{/* orders list */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
			int sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
			sel = (e->click.pt.y - 15) / 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
			if ( (uint) sel >= 6)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
			sel += w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   393
			if (_ctrl_pressed && sel < v->num_orders) {
1043
123072ba6ced (svn r1544) -Fix: SwapOrder did not use AssignOrder, which caused the saveroutine to
truelight
parents: 1035
diff changeset
   394
				const Order *ord = GetVehicleOrder(v, sel);
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   395
				int xy = 0;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   396
				switch (ord->type) {
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   397
				case OT_GOTO_STATION:			/* station order */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   398
					xy = GetStation(ord->station)->xy ;
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   399
					break;
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   400
				case OT_GOTO_DEPOT:				/* goto depot order */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   401
					xy = _depots[ord->station].xy;
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   402
					break;
395
4c990f33dab7 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 319
diff changeset
   403
				case OT_GOTO_WAYPOINT:	/* goto waypoint order */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   404
					xy = _waypoints[ord->station].xy;
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   405
				}
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   406
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   407
				if (xy)
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   408
					ScrollMainWindowToTile(xy);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   409
44
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   410
				return;
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   411
			}
1923acc255d1 (svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents: 25
diff changeset
   412
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
			if (sel == WP(w,order_d).sel) sel = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
			WP(w,order_d).sel = sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
		}	break;
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
		case 4: /* skip button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   419
			OrderClick_Skip(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
		case 5: /* delete button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   423
			OrderClick_Delete(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   426
		case 6: /* non stop button */
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   427
			OrderClick_Nonstop(w, v);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   428
			break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   429
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
		case 7: /* goto button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   431
			OrderClick_Goto(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
		case 8: /* full load button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   435
			OrderClick_FullLoad(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
			break;
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
		case 9: /* unload button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   439
			OrderClick_Unload(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
			break;
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
	} break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   443
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   444
	case WE_KEYPRESS: {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   445
		Vehicle *v = GetVehicle(w->window_number);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   446
		uint i;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   447
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   448
		for(i = 0; i < lengthof(_order_keycodes); i++) {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   449
			if (e->keypress.keycode == _order_keycodes[i]) {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   450
				e->keypress.cont = false;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   451
				//see if the button is disabled
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   452
				if (!(HASBIT(w->disabled_state, (i + 4)))) {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   453
					_order_button_proc[i](w, v);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   454
				}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   455
				break;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   456
			}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   457
		}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   458
		break;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   459
	}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   460
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
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
	case WE_RCLICK: {
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   464
		Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
		if (e->click.widget != 8) break;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   466
		if (GetVehicleOrder(v, OrderGetSel(w))->type == OT_GOTO_DEPOT)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
			GuiShowTooltips(STR_SERVICE_HINT);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
		else
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
			GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
	case WE_4: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
		if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
	case WE_PLACE_OBJ: {
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   478
		OrdersPlaceObj(GetVehicle(w->window_number), e->place.tile, w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
	case WE_ABORT_PLACE_OBJ: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
		w->click_state &= ~(1<<7);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
		InvalidateWidget(w, 7);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
	// check if a vehicle in a depot was clicked..
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
	case WE_MOUSELOOP: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
		Vehicle *v = _place_clicked_vehicle;
25
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   489
		/*
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   490
		 * Check if we clicked on a vehicle
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   491
		 * and if the GOTO button of this window is pressed
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   492
		 * This is because of all open order windows WE_MOUSELOOP is called
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   493
		 * and if you have 3 windows open, and this check is not done
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   494
		 * the order is copied to the last open window instead of the
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   495
		 * one where GOTO is enalbed
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   496
		 */
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   497
		if (v && HASBIT(w->click_state, 7)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
			_place_clicked_vehicle = NULL;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   499
			HandleOrderVehClick(GetVehicle(w->window_number), v, w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   502
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   506
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   507
static const Widget _orders_train_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   508
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   509
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   319,     0,    13, STR_8829_ORDERS,					STR_018C_WINDOW_TITLE_DRAG_THIS},
893
d9e69e5060ba (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: 867
diff changeset
   510
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   307,    14,    75, 0x0,											STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
d9e69e5060ba (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: 867
diff changeset
   511
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   308,   319,    14,    75, 0x0,											STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   512
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    52,    76,    87, STR_8823_SKIP,						STR_8853_SKIP_THE_CURRENT_ORDER},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   513
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    53,   105,    76,    87, STR_8824_DELETE,					STR_8854_DELETE_THE_HIGHLIGHTED},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   514
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   106,   158,    76,    87, STR_8825_NON_STOP,				STR_8855_MAKE_THE_HIGHLIGHTED_ORDER},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   515
{WWT_NODISTXTBTN,   RESIZE_NONE,    14,   159,   211,    76,    87, STR_8826_GO_TO,					STR_8856_INSERT_A_NEW_ORDER_BEFORE},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   516
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   212,   264,    76,    87, STR_FULLLOAD_OR_SERVICE,	STR_NULL},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   517
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   265,   319,    76,    87, STR_8828_UNLOAD,					STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 127
diff changeset
   518
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   521
static const WindowDesc _orders_train_desc = {
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   522
	-1,-1, 320, 88,
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   523
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   524
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   525
	_orders_train_widgets,
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   526
	OrdersWndProc
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   527
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   528
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   529
static const Widget _orders_widgets[] = {
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   530
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   531
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   319,     0,    13, STR_8829_ORDERS,					STR_018C_WINDOW_TITLE_DRAG_THIS},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   532
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   307,    14,    75, 0x0,											STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   533
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   308,   319,    14,    75, 0x0,											STR_0190_SCROLL_BAR_SCROLLS_LIST},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   534
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   535
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    63,    76,    87, STR_8823_SKIP,						STR_8853_SKIP_THE_CURRENT_ORDER},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   536
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,    64,   128,    76,    87, STR_8824_DELETE,					STR_8854_DELETE_THE_HIGHLIGHTED},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   537
{ WWT_EMPTY,        RESIZE_NONE,    14,     0,     0,    76,    87, 0x0,											0x0},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   538
{WWT_NODISTXTBTN,   RESIZE_NONE,    14,   129,   192,    76,    87, STR_8826_GO_TO,					STR_8856_INSERT_A_NEW_ORDER_BEFORE},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   539
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   193,   256,    76,    87, STR_FULLLOAD_OR_SERVICE,	STR_NULL},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   540
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   257,   319,    76,    87, STR_8828_UNLOAD,					STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   541
{   WIDGETS_END},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   542
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   543
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   544
static const WindowDesc _orders_desc = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
	-1,-1, 320, 88,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   548
	_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
	OrdersWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   552
static const Widget _other_orders_widgets[] = {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   553
{    WWT_TEXTBTN,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,				STR_018B_CLOSE_WINDOW},
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 781
diff changeset
   554
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   319,     0,    13, STR_A00B_ORDERS,	STR_018C_WINDOW_TITLE_DRAG_THIS},
893
d9e69e5060ba (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: 867
diff changeset
   555
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   307,    14,    75, 0x0,							STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
d9e69e5060ba (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: 867
diff changeset
   556
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   308,   319,    14,    75, 0x0,							STR_0190_SCROLL_BAR_SCROLLS_LIST},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 127
diff changeset
   557
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   560
static const WindowDesc _other_orders_desc = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
	-1,-1, 320, 76,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   564
	_other_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
	OrdersWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
void ShowOrdersWindow(Vehicle *v)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   575
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
	_alloc_wnd_parent_num = veh;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   577
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   578
	if (v->owner != _local_player) {
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   579
		w = AllocateWindowDesc( &_other_orders_desc);
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   580
	} else {
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   581
		w = AllocateWindowDesc( (v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc);
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   582
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
	w->window_number = veh;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
	w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
	w->vscroll.cap = 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
	WP(w,order_d).sel = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
}