order_gui.c
author bjarni
Mon, 14 Aug 2006 15:03:01 +0000
changeset 4262 4657d940a84c
parent 4182 20d711816338
child 4344 5d0e40cd67b9
permissions -rw-r--r--
(svn r5888) -Fix: [autoreplace] if vehicles breakdowns and service are turned off, the vehicles failed to enter any depots
now they will quickly go to a depot if set to be replaced
the tradeoff is that a vehicle set to be replaced and without a depot in the orders will forget about the orders and head for a depot. If the replace fails (lack of money), it will exit and try to head for the depot again
also all vehicles of that type will rush to the depots at once, risking causing traffic jams. This is because there is no way to even it out like normal depot visits offers
Tip: add a depot to the orders of all vehicles, set it to service only and it will always be skipped unless the vehicle is set to be replaced. This should help on the jam issue and if the replace fails, the vehicle will go though a whole round of the orders and make more money before trying again
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1857
diff changeset
     4
#include "openttd.h"
3144
426b825578f9 (svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents: 3071
diff changeset
     5
#include "road_map.h"
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents: 3269
diff changeset
     6
#include "station_map.h"
1363
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1334
diff changeset
     7
#include "table/sprites.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 395
diff changeset
     8
#include "table/strings.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2064
diff changeset
     9
#include "functions.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
    10
#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
    11
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "station.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "town.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
#include "viewport.h"
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1256
diff changeset
    20
#include "depot.h"
1542
2ca6d1624e6d (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1530
diff changeset
    21
#include "waypoint.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2668
diff changeset
    22
#include "train.h"
3392
7c330e18dfe1 (svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents: 3387
diff changeset
    23
#include "water_map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
    25
static int OrderGetSel(const Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
    27
	const Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
	int num = WP(w,order_d).sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
    30
	return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    33
static StringID StationOrderStrings[] = {
1937
0c1f7f4083c7 (svn r2443) -Fix: somehow I delete one line too many :(
celestar
parents: 1935
diff changeset
    34
	STR_8806_GO_TO,
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    35
	STR_8807_GO_TO_TRANSFER,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    36
	STR_8808_GO_TO_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    37
	STR_8809_GO_TO_TRANSFER_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    38
	STR_880A_GO_TO_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    39
	STR_880B_GO_TO_TRANSFER_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    40
	STR_NULL,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    41
	STR_NULL,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    42
	STR_880C_GO_NON_STOP_TO,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    43
	STR_880D_GO_TO_NON_STOP_TRANSFER,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    44
	STR_880E_GO_NON_STOP_TO_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    45
	STR_880F_GO_TO_NON_STOP_TRANSFER_UNLOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    46
	STR_8810_GO_NON_STOP_TO_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    47
	STR_8811_GO_TO_NON_STOP_TRANSFER_LOAD,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    48
	STR_NULL
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    49
};
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    50
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
static void DrawOrdersWindow(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    53
	const Vehicle *v;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    54
	const Order *order;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    55
	StringID str;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    56
	int sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	int y, i;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    58
	bool shared_orders;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    59
	byte color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
    61
	v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    63
	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
    64
		1 << 4 |   //skip
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    65
		1 << 5 |   //delete
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    66
		1 << 6 |   //non-stop
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    67
		1 << 7 |   //go-to
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    68
		1 << 8 |   //full load
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    69
		1 << 9 |   //unload
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    70
		1 << 10    //transfer
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
    71
		);
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
    72
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
    73
	if (v->type != VEH_Train)
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
    74
		SETBIT(w->disabled_state, 6); //disable non-stop for non-trains
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    76
	shared_orders = IsOrderListShared(v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
1857
7321b4c1d4e1 (svn r2363) - Codechange: [NPF] Removed caching the endnode check. The code for this was buggy, fundamentally flawed and barely useful. (Hackykid)
matthijs
parents: 1752
diff changeset
    78
	if ((uint)v->num_orders + (shared_orders?1:0) <= (uint)WP(w,order_d).sel)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
		SETBIT(w->disabled_state, 5); /* delete */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    81
	if (v->num_orders == 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
		SETBIT(w->disabled_state, 4); /* skip */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    84
	SetVScrollCount(w, v->num_orders + 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	sel = OrderGetSel(w);
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    87
	SetDParam(2, STR_8827_FULL_LOAD);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    88
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    89
	order = GetVehicleOrder(v, sel);
725
d6543c8b2428 (svn r1177) Enable non-stop flag for waypoints
tron
parents: 679
diff changeset
    90
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    91
	if (order != NULL) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    92
		switch (order->type) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    93
			case OT_GOTO_STATION:
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    94
				break;
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
    95
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    96
			case OT_GOTO_DEPOT:
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
    97
				SETBIT(w->disabled_state, 9);  /* unload */
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
    98
				SETBIT(w->disabled_state, 10); /* transfer */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
    99
				SetDParam(2,STR_SERVICE);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   100
				break;
725
d6543c8b2428 (svn r1177) Enable non-stop flag for waypoints
tron
parents: 679
diff changeset
   101
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   102
			case OT_GOTO_WAYPOINT:
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   103
				SETBIT(w->disabled_state, 8);  /* full load */
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   104
				SETBIT(w->disabled_state, 9);  /* unload */
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   105
				SETBIT(w->disabled_state, 10); /* transfer */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   106
				break;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   107
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   108
			default:
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   109
				SETBIT(w->disabled_state, 6);  /* nonstop */
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   110
				SETBIT(w->disabled_state, 8);  /* full load */
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   111
				SETBIT(w->disabled_state, 9);  /* unload */
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   112
		}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   113
	} else {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   114
		SETBIT(w->disabled_state, 6);          /* nonstop */
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   115
		SETBIT(w->disabled_state, 8);          /* full load */
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   116
		SETBIT(w->disabled_state, 9);          /* unload */
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   117
		SETBIT(w->disabled_state, 10);         /* transfer */
0
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
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   120
	SetDParam(0, v->string_id);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   121
	SetDParam(1, v->unitnumber);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	y = 15;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   126
	i = w->vscroll.pos;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   127
	order = GetVehicleOrder(v, i);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   128
	while (order != NULL) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   129
		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
   130
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   131
		if (i - w->vscroll.pos < w->vscroll.cap) {
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   132
			SetDParam(1, 6);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   133
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   134
			switch (order->type) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   135
				case OT_GOTO_STATION:
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   136
					SetDParam(1, StationOrderStrings[order->flags]);
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   137
					SetDParam(2, order->station);
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   138
					break;
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   139
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   140
				case OT_GOTO_DEPOT: {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   141
					StringID s = STR_NULL;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   142
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   143
					if (v->type == VEH_Aircraft) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   144
						s = STR_GO_TO_AIRPORT_HANGAR;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   145
						SetDParam(2, order->station);
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   146
					} else {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   147
						SetDParam(2, GetDepot(order->station)->town_index);
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   148
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   149
						switch (v->type) {
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   150
							case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   151
							case VEH_Road:  s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   152
							case VEH_Ship:  s = STR_GO_TO_SHIP_DEPOT; break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   153
							default: break;
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   154
						}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
					}
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   156
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   157
					if (order->flags & OF_FULL_LOAD) s++; /* service at */
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   158
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   159
					SetDParam(1, s);
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   160
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
				}
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   162
2631
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   163
				case OT_GOTO_WAYPOINT:
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   164
					SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   165
					SetDParam(2, order->station);
13daba67f217 (svn r3173) Use the trinary operator and switch to improve readability
tron
parents: 2549
diff changeset
   166
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
			}
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   168
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   169
			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
   170
			SetDParam(0, i + 1);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   171
			if (order->type != OT_DUMMY) {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   172
				DrawString(2, y, str, color);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   173
			} else {
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   174
				SetDParam(1, STR_INVALID_ORDER);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   175
				SetDParam(2, order->station);
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   176
				DrawString(2, y, str, color);
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
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
		i++;
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   182
		order = order->next;
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   183
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   185
	if (i - w->vscroll.pos < w->vscroll.cap) {
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   186
		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
   187
		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
   188
		DrawString(2, y, str, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
	}
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
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   192
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
{
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   194
	Order order;
3387
5d14492dce35 (svn r4195) - Codechange: Initialize order variables to avoid a compiler warning. These are unused anyway... (smells of r3476-7, but not the same)
peter1138
parents: 3338
diff changeset
   195
	order.next  = NULL;
5d14492dce35 (svn r4195) - Codechange: Initialize order variables to avoid a compiler warning. These are unused anyway... (smells of r3476-7, but not the same)
peter1138
parents: 3338
diff changeset
   196
	order.index = 0;
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
	// check depot first
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
	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
   200
		switch (GetTileType(tile)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
		case MP_RAILWAY:
1901
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   202
			if (v->type == VEH_Train && IsTileOwner(tile, _local_player)) {
4182
20d711816338 (svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents: 4171
diff changeset
   203
				if (IsRailDepot(tile)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   204
					order.type = OT_GOTO_DEPOT;
1530
caa16c506a22 (svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents: 1363
diff changeset
   205
					order.flags = OF_PART_OF_ORDERS;
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1256
diff changeset
   206
					order.station = GetDepotByTile(tile)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   207
					return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   208
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
		case MP_STREET:
3793
33cdb5bf7b21 (svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents: 3792
diff changeset
   213
			if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   214
				order.type = OT_GOTO_DEPOT;
1530
caa16c506a22 (svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents: 1363
diff changeset
   215
				order.flags = OF_PART_OF_ORDERS;
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1256
diff changeset
   216
				order.station = GetDepotByTile(tile)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   217
				return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   218
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
		case MP_STATION:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
			if (v->type != VEH_Aircraft) break;
3338
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3315
diff changeset
   223
			if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   224
				order.type = OT_GOTO_DEPOT;
2778
0002d4b696a0 (svn r3325) - Fix: You couldn't send an airplane to a hangar for mandatory servicing, the NON_STOP flag failed the command.
Darkvater
parents: 2725
diff changeset
   225
				order.flags = OF_PART_OF_ORDERS;
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents: 3269
diff changeset
   226
				order.station = GetStationIndex(tile);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   227
				return order;
560
bd8a572dc8b9 (svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents: 559
diff changeset
   228
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
		case MP_WATER:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
			if (v->type != VEH_Ship) break;
1334
e33a521c3e12 (svn r1838) Ship depots are on water, not roads
tron
parents: 1330
diff changeset
   233
			if (IsTileDepotType(tile, TRANSPORT_WATER) &&
e33a521c3e12 (svn r1838) Ship depots are on water, not roads
tron
parents: 1330
diff changeset
   234
					IsTileOwner(tile, _local_player)) {
3392
7c330e18dfe1 (svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents: 3387
diff changeset
   235
				TileIndex tile2 = GetOtherShipDepotTile(tile);
7c330e18dfe1 (svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents: 3387
diff changeset
   236
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   237
				order.type = OT_GOTO_DEPOT;
1530
caa16c506a22 (svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents: 1363
diff changeset
   238
				order.flags = OF_PART_OF_ORDERS;
3392
7c330e18dfe1 (svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents: 3387
diff changeset
   239
				order.station = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   240
				return order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
			}
1214
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   242
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   243
			default:
33e07bbb7779 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   244
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
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
   248
	// check waypoint
1901
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   249
	if (IsTileType(tile, MP_RAILWAY) &&
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   250
			v->type == VEH_Train &&
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   251
			IsTileOwner(tile, _local_player) &&
2668
54d9f9d4dca3 (svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
truelight
parents: 2643
diff changeset
   252
			IsRailWaypoint(tile)) {
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   253
		order.type = OT_GOTO_WAYPOINT;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   254
		order.flags = 0;
1542
2ca6d1624e6d (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1530
diff changeset
   255
		order.station = GetWaypointByTile(tile)->index;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   256
		return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   257
	}
319
1891d07574d6 (svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents: 193
diff changeset
   258
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
   259
	if (IsTileType(tile, MP_STATION)) {
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents: 3269
diff changeset
   260
		StationID st_index = GetStationIndex(tile);
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   261
		const Station *st = GetStation(st_index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
		if (st->owner == _current_player || st->owner == OWNER_NONE) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
			byte facil;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
			(facil=FACIL_DOCK, v->type == VEH_Ship) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
			(facil=FACIL_TRAIN, v->type == VEH_Train) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
			(facil=FACIL_AIRPORT, v->type == VEH_Aircraft) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
			(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
   269
			(facil=FACIL_TRUCK_STOP, 1);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   270
			if (st->facilities & facil) {
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   271
				order.type = OT_GOTO_STATION;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   272
				order.flags = 0;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   273
				order.station = st_index;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   274
				return order;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   275
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	// not found
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   280
	order.type = OT_NOTHING;
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   281
	order.flags = 0;
2921
c6d012dd525f (svn r3477) -Fix: a fix that fixed the last commit.. I shouldn't be committing here :)
truelight
parents: 2920
diff changeset
   282
	order.station = INVALID_STATION;
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   283
	return order;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   286
static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   288
	if (u->type != v->type) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2668
diff changeset
   290
	if (u->type == VEH_Train && !IsFrontEngine(u)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
		u = GetFirstVehicleInChain(u);
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2668
diff changeset
   292
		if (!IsFrontEngine(u)) return false;
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	// 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
   296
	// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   297
	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
   298
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
	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
   300
		_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
   301
		WP(w,order_d).sel = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
		ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
	return true;
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
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   308
static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w)
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
	Order cmd;
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   311
	const Vehicle *u;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   312
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
	// 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
   314
	u = CheckMouseOverVehicle();
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   315
	if (u != NULL && HandleOrderVehClick(v, u, w)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
	cmd = GetOrderCmdFromTile(v, tile);
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   318
	if (cmd.type == OT_NOTHING) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
558
9b115b39c515 (svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents: 555
diff changeset
   320
	if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   321
		if (WP(w,order_d).sel != -1) WP(w,order_d).sel++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
		ResetObjectToPlace();
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
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   326
static void OrderClick_Goto(Window *w, const Vehicle *v)
1000
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
	InvalidateWidget(w, 7);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   329
	TOGGLEBIT(w->click_state, 7);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   330
	if (HASBIT(w->click_state, 7)) {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   331
		_place_clicked_vehicle = NULL;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   332
		SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, 1, w);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   333
	} else {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   334
		ResetObjectToPlace();
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   335
	}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   336
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   337
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   338
static void OrderClick_FullLoad(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   339
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   340
	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
   341
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   342
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   343
static void OrderClick_Unload(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   344
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   345
	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
   346
}
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   347
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   348
static void OrderClick_Nonstop(Window *w, const Vehicle *v)
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   349
{
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   350
	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
   351
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   352
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   353
static void OrderClick_Transfer(Window* w, const Vehicle* v)
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   354
{
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   355
	DoCommandP(v->tile, v->index + (OrderGetSel(w) <<  16), OFB_TRANSFER, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   356
}
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   357
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   358
static void OrderClick_Skip(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   359
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   360
	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
   361
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   362
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   363
static void OrderClick_Delete(Window *w, const Vehicle *v)
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   364
{
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   365
	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
   366
}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   367
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   368
typedef void OnButtonVehClick(Window *w, const Vehicle *v);
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   369
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   370
static OnButtonVehClick* const _order_button_proc[] = {
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   371
	OrderClick_Skip,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   372
	OrderClick_Delete,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   373
	OrderClick_Nonstop,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   374
	OrderClick_Goto,
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   375
	OrderClick_FullLoad,
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   376
	OrderClick_Unload,
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   377
	OrderClick_Transfer
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   378
};
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   379
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   380
static const uint16 _order_keycodes[] = {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   381
	'D', //skip order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   382
	'F', //delete order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   383
	'G', //non-stop
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   384
	'H', //goto order
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   385
	'J', //full load
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   386
	'K'  //unload
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   387
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
static void OrdersWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
{
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   391
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
		DrawOrdersWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
	case WE_CLICK: {
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   397
		Vehicle *v = GetVehicle(w->window_number);
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2921
diff changeset
   398
		switch (e->click.widget) {
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   399
		case 2: { /* orders list */
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   400
			int sel = (e->click.pt.y - 15) / 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   402
			if ((uint)sel >= w->vscroll.cap) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
			sel += w->vscroll.pos;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   406
			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
   407
				const Order *ord = GetVehicleOrder(v, sel);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   408
				TileIndex xy;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   409
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1019
diff changeset
   410
				switch (ord->type) {
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   411
					case OT_GOTO_STATION:  xy = GetStation(ord->station)->xy ; break;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   412
					case OT_GOTO_DEPOT:    xy = GetDepot(ord->station)->xy;    break;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   413
					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->station)->xy; break;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   414
					default:               xy = 0; break;
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
   415
				}
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
   416
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4012
diff changeset
   417
				if (xy != 0) ScrollMainWindowToTile(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
   418
				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
   419
			}
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
   420
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
			if (sel == WP(w,order_d).sel) sel = -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
			WP(w,order_d).sel = sel;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
			SetWindowDirty(w);
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
		case 4: /* skip button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   427
			OrderClick_Skip(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
		case 5: /* delete button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   431
			OrderClick_Delete(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
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   434
		case 6: /* non stop button */
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   435
			OrderClick_Nonstop(w, v);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   436
			break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   437
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
		case 7: /* goto button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   439
			OrderClick_Goto(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
		case 8: /* full load button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   443
			OrderClick_FullLoad(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
		case 9: /* unload button */
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   447
			OrderClick_Unload(w, v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
			break;
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   449
		case 10: /* transfer button */
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   450
			OrderClick_Transfer(w, v);
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   451
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
	} break;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   454
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   455
	case WE_KEYPRESS: {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   456
		Vehicle *v = GetVehicle(w->window_number);
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   457
		uint i;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   458
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2921
diff changeset
   459
		for (i = 0; i < lengthof(_order_keycodes); i++) {
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   460
			if (e->keypress.keycode == _order_keycodes[i]) {
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   461
				e->keypress.cont = false;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   462
				//see if the button is disabled
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3793
diff changeset
   463
				if (!HASBIT(w->disabled_state, i + 4)) _order_button_proc[i](w, v);
1000
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   464
				break;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   465
			}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   466
		}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   467
		break;
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   468
	}
a418026097f6 (svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents: 995
diff changeset
   469
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
	case WE_RCLICK: {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   471
		const Vehicle *v = GetVehicle(w->window_number);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   472
		int s = OrderGetSel(w);
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   473
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   474
		if (e->click.widget != 8) break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   475
		if (s == v->num_orders || GetVehicleOrder(v, s)->type != OT_GOTO_DEPOT) {
1256
696eba311737 (svn r1760) -Fix: [ 1113399 ] Game no longer crashes when right-clicking a disabled Full Load button
celestar
parents: 1242
diff changeset
   476
			GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   477
		} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
			GuiShowTooltips(STR_SERVICE_HINT);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   479
		}
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   480
	} break;
0
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 WE_PLACE_OBJ: {
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   483
		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
   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
	case WE_ABORT_PLACE_OBJ: {
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   487
		CLRBIT(w->click_state, 7);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
		InvalidateWidget(w, 7);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
	// check if a vehicle in a depot was clicked..
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
	case WE_MOUSELOOP: {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   493
		const Vehicle *v = _place_clicked_vehicle;
25
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   494
		/*
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   495
		 * Check if we clicked on a vehicle
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   496
		 * and if the GOTO button of this window is pressed
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   497
		 * This is because of all open order windows WE_MOUSELOOP is called
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   498
		 * and if you have 3 windows open, and this check is not done
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   499
		 * the order is copied to the last open window instead of the
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   500
		 * one where GOTO is enalbed
cf54d03fa22f (svn r26) Fix orderwindow issue
truelight
parents: 0
diff changeset
   501
		 */
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   502
		if (v != NULL && HASBIT(w->click_state, 7)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
			_place_clicked_vehicle = NULL;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 893
diff changeset
   504
			HandleOrderVehClick(GetVehicle(w->window_number), v, w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
	} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   507
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   508
	case WE_RESIZE:
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   509
		/* Update the scroll + matrix */
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   510
		w->vscroll.cap = (w->widget[2].bottom - w->widget[2].top) / 10;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   511
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   515
static const Widget _orders_train_widgets[] = {
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   516
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,									STR_018B_CLOSE_WINDOW},
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   517
{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   384,     0,    13, STR_8829_ORDERS,					STR_018C_WINDOW_TITLE_DRAG_THIS},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   518
{      WWT_PANEL,   RESIZE_RB,      14,     0,   372,    14,    75, 0x0,											STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   519
{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   373,   384,    14,    75, 0x0,											STR_0190_SCROLL_BAR_SCROLLS_LIST},
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   520
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,    52,    76,    87, STR_8823_SKIP,						STR_8853_SKIP_THE_CURRENT_ORDER},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   521
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,    53,   105,    76,    87, STR_8824_DELETE,					STR_8854_DELETE_THE_HIGHLIGHTED},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   522
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   106,   158,    76,    87, STR_8825_NON_STOP,				STR_8855_MAKE_THE_HIGHLIGHTED_ORDER},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   523
{WWT_NODISTXTBTN,   RESIZE_TB,      14,   159,   211,    76,    87, STR_8826_GO_TO,						STR_8856_INSERT_A_NEW_ORDER_BEFORE},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   524
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   212,   264,    76,    87, STR_FULLLOAD_OR_SERVICE,	STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   525
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   265,   319,    76,    87, STR_8828_UNLOAD,					STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   526
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   320,   372,    76,    87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   527
{      WWT_PANEL,   RESIZE_RTB,     14,   373,   372,    76,    87, 0x0,											STR_NULL},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   528
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   373,   384,    76,    87, 0x0,											STR_RESIZE_BUTTON},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 127
diff changeset
   529
{   WIDGETS_END},
0
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
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   532
static const WindowDesc _orders_train_desc = {
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   533
	-1,-1, 385, 88,
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   534
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2049
diff changeset
   535
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   536
	_orders_train_widgets,
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   537
	OrdersWndProc
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   538
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   539
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   540
static const Widget _orders_widgets[] = {
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   541
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,									STR_018B_CLOSE_WINDOW},
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   542
{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   395,     0,    13, STR_8829_ORDERS,					STR_018C_WINDOW_TITLE_DRAG_THIS},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   543
{      WWT_PANEL,   RESIZE_RB,      14,     0,   383,    14,    75, 0x0,											STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   544
{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   384,   395,    14,    75, 0x0,											STR_0190_SCROLL_BAR_SCROLLS_LIST},
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   545
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,     0,    63,    76,    87, STR_8823_SKIP,						STR_8853_SKIP_THE_CURRENT_ORDER},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   546
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,    64,   128,    76,    87, STR_8824_DELETE,					STR_8854_DELETE_THE_HIGHLIGHTED},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   547
{      WWT_EMPTY,   RESIZE_TB,      14,     0,     0,    76,    87, 0x0,											0x0},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   548
{WWT_NODISTXTBTN,   RESIZE_TB,      14,   129,   192,    76,    87, STR_8826_GO_TO,						STR_8856_INSERT_A_NEW_ORDER_BEFORE},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   549
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   193,   256,    76,    87, STR_FULLLOAD_OR_SERVICE,	STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   550
{ WWT_PUSHTXTBTN,   RESIZE_TB,      14,   257,   319,    76,    87, STR_8828_UNLOAD,					STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   551
{ WWT_PUSHTXTBTN,   RESIZE_TB,    14,   320,   383,    76,    87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   552
{      WWT_PANEL,   RESIZE_RTB,     14,   384,   383,    76,    87, 0x0,											STR_NULL},
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   553
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   384,   395,    76,    87, 0x0,											STR_RESIZE_BUTTON},
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   554
{   WIDGETS_END},
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   555
};
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   556
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   557
static const WindowDesc _orders_desc = {
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1901
diff changeset
   558
	-1,-1, 396, 88,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2049
diff changeset
   560
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   561
	_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
	OrdersWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   565
static const Widget _other_orders_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2676
diff changeset
   566
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,					STR_018B_CLOSE_WINDOW},
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   567
{    WWT_CAPTION,   RESIZE_RIGHT,   14,    11,   331,     0,    13, STR_A00B_ORDERS,	STR_018C_WINDOW_TITLE_DRAG_THIS},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   568
{      WWT_PANEL,   RESIZE_RB,      14,     0,   319,    14,    75, 0x0,							STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   569
{  WWT_SCROLLBAR,   RESIZE_LRB,     14,   320,   331,    14,    75, 0x0,							STR_0190_SCROLL_BAR_SCROLLS_LIST},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   570
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                     STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   571
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                     STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   572
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                     STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   573
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                     STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   574
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                     STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   575
{      WWT_EMPTY,   RESIZE_NONE,    14,     0,   319,    76,    87, 0x0,                     STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   576
{      WWT_PANEL,   RESIZE_RTB,     14,     0,   319,    76,    87, 0x0,							STR_NULL},
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   577
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   320,   331,    76,    87, 0x0,							STR_RESIZE_BUTTON},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 127
diff changeset
   578
{   WIDGETS_END},
0
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
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   581
static const WindowDesc _other_orders_desc = {
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   582
	-1,-1, 332, 88,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
	WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   584
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
995
96e9f70280d7 (svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents: 919
diff changeset
   585
	_other_orders_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
	OrdersWndProc
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
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4077
diff changeset
   589
void ShowOrdersWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   596
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
	_alloc_wnd_parent_num = veh;
1019
6363b8a4273e (svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents: 1000
diff changeset
   598
1081
b22fd4020122 (svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents: 1067
diff changeset
   599
	if (v->owner != _local_player) {
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   600
		w = AllocateWindowDesc(&_other_orders_desc);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   601
	} else {
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   602
		w = AllocateWindowDesc((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc);
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   603
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
1242
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   605
	if (w != NULL) {
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   606
		w->window_number = veh;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   607
		w->caption_color = v->owner;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   608
		w->vscroll.cap = 6;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   609
		w->resize.step_height = 10;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   610
		WP(w,order_d).sel = -1;
bd3e74f757b4 (svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents: 1214
diff changeset
   611
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
}